Skip to main content

Python SDK for Tenki Sandbox

Project description

Tenki Sandbox Python SDK

Python SDK for Tenki Sandbox: cloud sandboxes for AI agents and code execution.

pip install tenki-sandbox
from tenki_sandbox import Sandbox

with Sandbox.create(project_id="proj_123", cpu_cores=2, memory_mb=4096) as sb:
    result = sb.exec("python3", "-c", "print('hello')")
    result.check()
    print(result.stdout_text)

    sb.fs.write_text("/workspace/input.txt", "data")
    print(sb.fs.read_text("/workspace/input.txt"))

    preview = sb.expose_port(3000, ttl=3600)
    print(preview.url)

Auth

Auth resolution:

  1. auth_token= passed to Client or Sandbox.create
  2. TENKI_AUTH_TOKEN
  3. TENKI_API_KEY

TENKI_API_ENDPOINT overrides the API URL; legacy TENKI_API_URL is also accepted.

Process API

exec collects stdout/stderr and returns a result:

result = sb.exec("npm", "test", timeout=60, env={"CI": "1"})
print(result.stdout_text)
result.check()

start returns a live process:

proc = sb.start("bash", "-lc", "read name; echo hello $name")
proc.write_stdin("tenki\n")
proc.close_stdin()
for chunk in proc.stdout:
    print(chunk.decode(), end="")
proc.wait().check()

Use shell() when you want shell parsing:

sb.shell("python3 -m http.server 3000 >/tmp/server.log 2>&1 &")

Resource APIs

from tenki_sandbox import Client, GiB

client = Client()

volume = client.volumes.create(
    workspace_id="ws_123",
    name="cache",
    size_bytes=10 * GiB,
    project_id="proj_123",
)

preview = client.preview_urls.create(
    project_id="proj_123",
    slug="demo",
    session_id=sb.id,
    port=3000,
)

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

tenki_sandbox-0.1.0.tar.gz (101.8 kB view details)

Uploaded Source

Built Distribution

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

tenki_sandbox-0.1.0-py3-none-any.whl (91.0 kB view details)

Uploaded Python 3

File details

Details for the file tenki_sandbox-0.1.0.tar.gz.

File metadata

  • Download URL: tenki_sandbox-0.1.0.tar.gz
  • Upload date:
  • Size: 101.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tenki_sandbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 26f81b8f2924c2c7c3e6e9730822999de09eddb6facda1c449f3de050166b4e8
MD5 9d11280b90963f503494419a095ca52e
BLAKE2b-256 978b176f71a69fa24699a97139baf9ec314db3113b01576267f961445e7cf2da

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenki_sandbox-0.1.0.tar.gz:

Publisher: pypi-publish.yml on TenkiCloud/tenki-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tenki_sandbox-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tenki_sandbox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 91.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tenki_sandbox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 83ac36b86476351dd41203138aac84bec7e4c067e053a1a8cfece7501346f9a6
MD5 ecd396d1416ffd5e3c8f9069a0e58b32
BLAKE2b-256 572ef527ae9a43893482fc12d96b54157dbe4580e72c2714e123719b78564e55

See more details on using hashes here.

Provenance

The following attestation bundles were made for tenki_sandbox-0.1.0-py3-none-any.whl:

Publisher: pypi-publish.yml on TenkiCloud/tenki-sdk-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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