Skip to main content

Python SDK for AgentTier — manage isolated AI agent sandboxes on Kubernetes

Project description

AgentTier Python SDK

Programmatic client for AgentTier — manage isolated, persistent Kubernetes sandboxes for 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.1.1.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.1.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: agenttier-0.1.1.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.1.1.tar.gz
Algorithm Hash digest
SHA256 0b400a6b5467467824f53035f818036ebef86396fb0c18331079f856a9bc558b
MD5 a1a4d9c12ee21c70e37d85bd0048a292
BLAKE2b-256 0a77b9b40adb8da25af21b28722a7e420e943b4d4edbf3d8b82431012da8f9b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agenttier-0.1.1-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.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 08238251d2a2c094d3f9e30cf3690a545421f9f96b10152b5f642ce8b6881b6e
MD5 9afe568ed6bbdb7f0c24b014628c0d86
BLAKE2b-256 a7f5f850e53d5db965d5f8cf1c0215ec581f50d812de32d03b586a83b308c057

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