Skip to main content

aphub-sdk

Python SDK for aphub - The Docker Hub for AI Agents

Installation

pip install aphub-sdk

Quick Start

Basic Usage

from aphub_sdk import HubClient
from pathlib import Path

# Initialize client
client = HubClient(
    base_url="https://hub.aipartnerup.com",
    api_key="your-api-key"  # Optional, can use token instead
)

# Pull an Agent
result = client.pull(
    name="customer-service-agent",
    tag="latest",
    output_path=Path("./agents")
)

# Push an Agent
result = client.push(
    manifest=Path("./agent.yaml"),
    tag="latest",
    files_path=Path("./agent-files/")
)

# Search Agents
results = client.search(
    query="customer service",
    framework="aipartnerupflow",
    page_size=20
)

# Get Agent details
agent = client.get_agent("customer-service-agent")

# List tags
tags = client.list_tags("customer-service-agent")

Use Cases

1. CI/CD Pipeline Integration

Automatically deploy agents after successful builds:

import os
from aphub_sdk import HubClient

def deploy_in_cicd():
    client = HubClient(api_key=os.environ["APHUB_API_KEY"])
    result = client.push(
        manifest=Path("./dist/agent.yaml"),
        tag=os.environ.get("VERSION", "latest"),
        files_path=Path("./dist/agent-files"),
    )
    print(f"Deployed: {result.name}:{result.version}")

2. Custom Web Application

Build custom UIs and backends:

from fastapi import FastAPI
from aphub_sdk import HubClient

app = FastAPI()
client = HubClient()

@app.get("/api/agents")
def list_agents():
    result = client.search(query="", page_size=50)
    return {"agents": [item.agent.name for item in result.results]}

3. Agent Management Scripts

Batch operations and automation:

client = HubClient(api_key="your-key")

# Bulk operations
for agent_name in ["agent1", "agent2", "agent3"]:
    client.pull(agent_name, output_path=Path(f"./backups/{agent_name}"))

4. Agent Testing and Validation

Validate agents before pushing:

def validate_and_push(manifest_path, files_path):
    # Your validation logic here
    if validate_agent(manifest_path, files_path):
        return client.push(manifest_path, files_path=files_path)
    else:
        raise ValueError("Validation failed")

Advanced Features

Retry Configuration

from aphub_sdk import HubClient
from aphub_sdk.retry import RetryConfig

client = HubClient(
    retry_config=RetryConfig(
        max_retries=5,
        backoff_factor=2.0,
    )
)

Token Auto-Refresh

client = HubClient(
    access_token="your-access-token",
    refresh_token="your-refresh-token",
)
# Tokens automatically refreshed when expired

Progress Tracking

def progress(bytes_sent, total_bytes):
    print(f"Progress: {bytes_sent}/{total_bytes}")

client = HubClient(progress_callback=progress)
client.pull("my-agent", output_path=Path("./agents"))

When to Use SDK vs CLI

Use Case SDK CLI
CI/CD Pipelines ✅ ❌
Custom Applications ✅ ❌
Scripts/Automation ✅ ⚠️
Interactive Use ⚠️ ✅
Batch Operations ✅ ❌

Documentation

License

Apache-2.0

Metadata

Release files for aphub-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aphub-sdk 0.1.0
File Size Uploaded
aphub_sdk-0.1.0.tar.gz 28.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aphub-sdk 0.1.0
File Interpreter ABI Platform
aphub_sdk-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 60.8 kB

Release files / aphub_sdk-0.1.0.tar.gz

Download URL aphub_sdk-0.1.0.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0845c6ac4331d663c129e3766de682df363119a3b6222e64dcd008754e67ee37
BLAKE2b-256 checksum
How to use checksums
0da0d9f6f5b5960fe090e3677f9b8d6bf42ed197eeece291c09db56e08d4bb75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / aphub_sdk-0.1.0-py3-none-any.whl

Download URL aphub_sdk-0.1.0-py3-none-any.whl
Size 32.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8d842b4c9248efc6d5be58623bdc08c015546a5eb8e2378e6f381818b64bbf3d
BLAKE2b-256 checksum
How to use checksums
a8eb73aa961e930e4e04b7b625d4429690b88593c66479490aedebca883a53a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page