Skip to main content

Python SDK for AgentTier — isolated, persistent Kubernetes sandboxes for humans and AI agents

Project description

AgentTier Python SDK

Programmatic client for AgentTier — manage isolated, persistent Kubernetes sandboxes for humans and AI agents from Python.

pip install agenttier

Synchronous quick start

from agenttier import AgentTierClient

with AgentTierClient(api_url="https://agenttier.company.com") as client:
    sandbox = client.create_sandbox(template="general-coding", name="demo")
    sandbox.wait_until_running()

    result = sandbox.exec("echo 'hello from AgentTier'")
    print(result.stdout, "exit", result.exit_code)

    port = sandbox.forward_port(8080)
    print("Forwarded:", port.preview_url or port.internal_url)

    sandbox.terminate()

Async

import asyncio
from agenttier import AsyncAgentTierClient

async def main():
    async with AsyncAgentTierClient(api_url="https://agenttier.company.com") as client:
        sandbox = await client.create_sandbox(template="general-coding", name="demo")
        await sandbox.wait_until_running()
        result = await sandbox.exec("uname -a")
        print(result.stdout)
        await sandbox.terminate()

asyncio.run(main())

Authentication

The SDK auto-detects credentials in this order:

  1. AGENTTIER_API_KEY — sent as X-API-Key.
  2. AGENTTIER_TOKEN — sent as Authorization: Bearer <token> (OIDC JWT).
  3. In-cluster ServiceAccount token at /var/run/secrets/kubernetes.io/serviceaccount/token.
  4. Unauthenticated (accepted only in the Router's dev mode).

Or pass an explicit provider:

from agenttier import AgentTierClient, APIKeyAuth, BearerTokenAuth

client = AgentTierClient(
    api_url="https://agenttier.company.com",
    auth=APIKeyAuth("sk_live_..."),
)

Error handling

Every error inherits from AgentTierError so you can catch them all at once. The common subclasses you'll want to handle individually:

Exception When
AuthenticationError 401 — token / API key missing or invalid
AuthorizationError 403 — authenticated but not permitted
PolicyViolationError 403 with governance body; exposes .violations
NotFoundError 404 — resource doesn't exist
ConflictError 409 — operation invalid for current state
SandboxTimeoutError wait_until_running timed out
SandboxErrorState sandbox entered the Error phase while waiting
APIError anything else; carries .status_code and .body

Supported API surface (v0.1.1)

Only endpoints that the Router server implements in v0.1.0 are exposed:

  • Sandboxescreate_sandbox, list_sandboxes, get_sandbox, stop, resume, terminate, exec, wait_until_running, status.
  • Port forwardingforward_port, list_ports, remove_port.
  • Templateslist_templates, get_template.
  • Identitycurrent_user.

Endpoints that are not yet implemented on the server (file transfer, sharing, cloning, WebSocket terminal from Python) are not exposed by the SDK and will be added in a future release once the server ships them.

Supported Python versions

3.10, 3.11, 3.12, 3.13. Runtime dependencies: httpx and pydantic.

License

Apache-2.0. Source at github.com/agenttier/agenttier/tree/main/python-sdk.

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

agenttier-0.2.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

agenttier-0.2.0-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file agenttier-0.2.0.tar.gz.

File metadata

  • Download URL: agenttier-0.2.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for agenttier-0.2.0.tar.gz
Algorithm Hash digest
SHA256 541a65643e46659eb91a7d0cc566698522dc67c18734f758c013e00604da034f
MD5 01110166398f739e4ddbeb77f765a520
BLAKE2b-256 cf1327406ba3c9574cd91811b855f642ba8de5d771afa93bb951d2a9d2d894d7

See more details on using hashes here.

File details

Details for the file agenttier-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agenttier-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for agenttier-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 635ca37527a54b4e265b6f23638f5e355b781808f3cfca7f8d2e7f9e05edecb4
MD5 83f4aa11c47e379b7ae535a70f194e4b
BLAKE2b-256 2a67f3c61d76740b4c36816e826920da7aac0d14684cdaea26bd79e709dd1102

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