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.4.1.tar.gz (38.2 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.4.1-py3-none-any.whl (37.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for agenttier-0.4.1.tar.gz
Algorithm Hash digest
SHA256 9d9d6003d882c090d809d1a312730de45b956e49fb39d2a4aef31cdd5574aa18
MD5 5b2832402a5a58700368792428c6f30c
BLAKE2b-256 9f671e750f9bd89b6d17a15b4d6c7ee91522b4eef319326a6394258754d43560

See more details on using hashes here.

File details

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

File metadata

  • Download URL: agenttier-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 37.9 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.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f41c9314b99293078c40c31be5a33d3c7ef91cf48a94dd739e09bf28b9c7b871
MD5 c3a234e32d38982a3a34746b00033b24
BLAKE2b-256 5f3a609f049d7cdf165449eaf5728e543bd35c0600c30e31c8f40f8449c57f91

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