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.3.0.tar.gz (24.7 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.3.0-py3-none-any.whl (26.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agenttier-0.3.0.tar.gz
Algorithm Hash digest
SHA256 15bb84e2db4a4f0f344063d8b4e36786471a457ba70f71b8ae896a02cabd7364
MD5 48fa2717581857503cb64cde9a7fb378
BLAKE2b-256 e5b2131ddf7a53418297dfcf92f8d80ba08f757f380e7e199aa1c5b1b808f980

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agenttier-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 26.5 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5c41d88289a17b3756b154a7c2ee3fdf80aadf27b7af7b791640ffda591921ae
MD5 0632228da67ce85571fb35f4419c749b
BLAKE2b-256 c47c2f32c9dfb802a2d737f5e186e7eef8c93fca6bce18adb3ca938128cc2f94

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