Skip to main content

Python SDK for the Agent Orchestration API.

Project description

trelent-agents

Python SDK for the Trelent Agent Orchestration API.

Installation

pip install trelent-agents

Quick Start

Without authentication

from trelent_agents import Client

client = Client(api_url="http://localhost:8000")

images = client.images.list()
print(images)

run = client.runs.create(
    sandbox="example-agent:latest",
    prompt="Create hello.txt with a greeting",
)
print(run.id, run.status, run.harness.kind)

With authentication

When the API has authentication enabled, provide your OAuth2 client credentials:

from trelent_agents import Client

client = Client(
    api_url="https://agents.trelent.com",
    client_id="your-client-id",
    client_secret="your-client-secret",
)

images = client.images.list()
run = client.runs.create(
    sandbox="my-image:latest",
    prompt="Do something useful",
)

The SDK handles token acquisition automatically — it exchanges your client credentials for a JWT via the API's /token endpoint before making authenticated requests.

If you need to call the token proxy directly, use client.tokens.create(...).

The client also supports context manager usage:

with Client(api_url="https://agents.trelent.com", client_id="...", client_secret="...") as client:
    runs = client.runs.list()

Client Options

client = Client(
    api_url="https://agents.trelent.com",  # API base URL (default: https://agents.trelent.com)
    client_id="...",                        # OAuth2 client ID (optional)
    client_secret="...",                    # OAuth2 client secret (optional)
    scope="...",                            # Override default OAuth2 scope (optional)
)

Both client_id and client_secret must be provided together, or both omitted.

Resources

client.images

images = client.images.list()
# => list[RegistryImage] — [RegistryImage(name="my-image", tags=["latest", "v1"])]

When auth is enabled, images are automatically filtered to your namespace. Image names are returned without the namespace prefix.

client.tokens

token = client.tokens.create(
    client_id="your-client-id",
    client_secret="your-client-secret",
    scope="AgentOrchestrator:runs:list",
)

client.runs

from trelent_agents import ClaudeCodeHarnessSpec, LocalImporter, S3Exporter

# Create a run
run = client.runs.create(
    sandbox="my-image:latest",
    prompt="Build a web server",
    harness=ClaudeCodeHarnessSpec(),  # optional, default: ClaudeCodeHarnessSpec()
    timeout_seconds=3600,          # optional, default: 3600
    imports=[LocalImporter(path="./data")],  # optional
    exports=[S3Exporter()],                  # optional
)

# List runs (optionally filter by sandbox)
runs = client.runs.list()
filtered = client.runs.list(sandbox="my-image:latest")

# Get a specific run
run = client.runs.get("run-id")

# Check status
status = client.runs.get_status("run-id")

# Cancel a run
cancel = client.runs.cancel("run-id")

# Get checkpoints
chain = client.runs.get_checkpoint_chain("run-id")
checkpoint = client.runs.get_checkpoint("run-id", "checkpoint-id")

Run operations

# Fork (resume from checkpoint)
forked = run.fork(
    "Continue from where you left off",
    timeout_seconds=1800,
)

# Refresh run state
run.refresh()
print(run.status)  # updated status

client.health()

health = client.health()
# => HealthResponse(status="ok")

Connectors

Importing local files

from trelent_agents import LocalImporter

run = client.runs.create(
    sandbox="my-image:latest",
    prompt="Process the data",
    imports=[LocalImporter(path="./my-data-dir")],
)

The LocalImporter tarballs and base64-encodes the local path, sending it inline with the request.

Exporting to S3

from trelent_agents import S3Exporter

run = client.runs.create(
    sandbox="my-image:latest",
    prompt="Generate a report",
    exports=[S3Exporter(bucket="my-bucket", path="reports/")],
)

Docker Registry Setup

When auth is enabled, push images to your user namespace on the registry:

# Login with your OAuth2 credentials
docker login registry.example.com -u <client_id> -p <client_secret>

# Push to your namespace
docker tag my-image:latest registry.example.com/<client_id>/my-image:latest
docker push registry.example.com/<client_id>/my-image:latest

When creating runs via the SDK, just use the image name without the namespace prefix:

run = client.runs.create(
    sandbox="my-image:latest",  # not "<client_id>/my-image:latest"
    prompt="...",
)

The API resolves the full registry path automatically based on your authenticated identity.

Types

The SDK exports the following types:

from trelent_agents import (
    Client,
    ClaudeCodeHarnessSpec,
    CodexHarnessSpec,
    GeminiHarnessSpec,
    Run,
    RunStatus,
    RunResult,
    RunStatusResponse,
    RegistryImage,
    CheckpointResponse,
    CancelRunResponse,
    ChatHistoryEntry,
    FileOutput,
    OutputFile,
    HealthResponse,
    HarnessInfo,
    HarnessKind,
    HarnessSpec,
    TokenRequest,
    TokenResponse,
    WorkflowIds,
    LocalImporter,
    S3Exporter,
    APIError,
    NotFoundError,
    ValidationError,
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trelent_agents-0.2.3.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trelent_agents-0.2.3-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file trelent_agents-0.2.3.tar.gz.

File metadata

  • Download URL: trelent_agents-0.2.3.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for trelent_agents-0.2.3.tar.gz
Algorithm Hash digest
SHA256 5ef07d32944ce280d40cee6d0af7e60a5c20f0e67e27d6a87788bc0069cea44c
MD5 151814bc03860714252309e9af95c56d
BLAKE2b-256 ef67fa8d847577360c498561674f1afd0115ea83eb08b182424ec1076d316404

See more details on using hashes here.

File details

Details for the file trelent_agents-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: trelent_agents-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for trelent_agents-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3940d0345477b4cc8a9dca048fbd37165b706aa632aa93b1610de5304246d282
MD5 91ae6694900e1fbd873ae26ac76804b5
BLAKE2b-256 a254a5a1eefc59cbe99a26e34116193c64b53cf19f7a69b0e441c76022b3a4f2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page