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.2.tar.gz (17.3 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.2-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agenttier-0.2.2.tar.gz
  • Upload date:
  • Size: 17.3 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.2.tar.gz
Algorithm Hash digest
SHA256 6654d4c1b73beaf0161a604a4fb070a19c6cbacd5b9d14708d07d3409ed52223
MD5 0f9a69500f5b009b59089aa59ce24eca
BLAKE2b-256 f5ed2eb5504382d772f680ce18a2c39a4c509ee764e760d32f0a1f85e69b290e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agenttier-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 18.4 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9864160494bdd0071f465af248ea56fda9a79f73925325b6712036d4ae3faec3
MD5 e1120d4022fa91134cae224df605be71
BLAKE2b-256 27485b35aacd7d23bc6bc112a13fe5875a45e814c2db8d797e75cc7bc73a5a60

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