Skip to main content

Python SDK for Universal Sandbox API

Project description

Universal Sandbox Python SDK

Python SDK for Universal Sandbox API.

📦 PyPI Package

📖 API Documentation

Installation

pip install universal-sandbox

Usage

For more detailed usage, please refer to example.py

from universal_sandbox import Sandbox

# Initialize client
# Get Sandbox API Token from https://ai-infra.org/
sandbox = Sandbox(token="sandbox-api-token")

# Check API health
health = sandbox.check_health()
print(health.status)

# Create a code interpreter sandbox
sb = sandbox.code_interpreter.create()
print(f"Sandbox ID: {sb.id}")
print(f"Provider: {sb.provider}")

# Execute code
result = sandbox.sandboxes.execute(sb.id, command="print('Hello, World!')")
print(result.stdout)

# Get sandbox info
info = sandbox.sandboxes.get(sb.id)
print(f"Status: {info.status}")

# List all sandboxes
sandbox_list = sandbox.sandboxes.list()
print(f"Total: {sandbox_list.total}")

# Delete sandbox
sandbox.sandboxes.delete(sb.id)

API to SDK Mapping

API Endpoint SDK Interface
GET /health sandbox.check_health()
GET /regions sandbox.list_regions()
GET /limits sandbox.get_limits()
POST /sandboxes/code-interpreter sandbox.code_interpreter.create()
POST /sandboxes/browser sandbox.browser.create()
POST /sandboxes/aio sandbox.aio.create()
GET /sandboxes sandbox.sandboxes.list()
GET /sandboxes/{id} sandbox.sandboxes.get()
DELETE /sandboxes/{id} sandbox.sandboxes.delete()
POST /sandboxes/{id}/execute sandbox.sandboxes.execute()
POST /admin/tokens sandbox.tokens.issue()
POST /admin/tokens/{prefix}/revoke sandbox.tokens.revoke()
GET /admin/users/{user_id}/token sandbox.tokens.get()

API Reference

Sandbox Client

from universal_sandbox import Sandbox

sandbox = Sandbox(
    token="your-token",           # API token (optional if auth disabled)
    base_url="https://...",       # Optional, defaults to production
)

Root Methods

  • sandbox.check_health() - Check API health status
  • sandbox.list_regions() - List available regions for all providers
  • sandbox.get_limits() - Get resource limits and current usage

Sandbox Creation

  • sandbox.code_interpreter.create(provider, timeout_minutes, region, metadata) - Create code interpreter
  • sandbox.browser.create(provider, timeout_minutes, region, metadata) - Create browser sandbox
  • sandbox.aio.create(provider, timeout_minutes, region, metadata) - Create all-in-one sandbox (only supports provider="volcengine")

Sandbox Management

  • sandbox.sandboxes.list() - List all sandboxes
  • sandbox.sandboxes.get(sandbox_id) - Get sandbox by ID
  • sandbox.sandboxes.delete(sandbox_id) - Delete a sandbox
  • sandbox.sandboxes.execute(sandbox_id, command, timeout) - Execute command

Token Management (Admin)

  • sandbox.tokens.issue(...) - Create a personal access token
  • sandbox.tokens.revoke(prefix) - Revoke a token
  • sandbox.tokens.get(user_id) - Get user's token

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

universal_sandbox-0.0.12.tar.gz (30.6 kB view details)

Uploaded Source

Built Distribution

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

universal_sandbox-0.0.12-py3-none-any.whl (55.3 kB view details)

Uploaded Python 3

File details

Details for the file universal_sandbox-0.0.12.tar.gz.

File metadata

  • Download URL: universal_sandbox-0.0.12.tar.gz
  • Upload date:
  • Size: 30.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for universal_sandbox-0.0.12.tar.gz
Algorithm Hash digest
SHA256 ef6c72acf81ea882a7e50e2d7633e1f6cdc7eb17f6118613c97f72e3fd3a1714
MD5 43f1b0a2fb87c771ce290625b2cdfa8c
BLAKE2b-256 12f40148a0e92c042059fb4c4d5593ad8c1069d9af5a26ce2fe93367bfe33b4b

See more details on using hashes here.

File details

Details for the file universal_sandbox-0.0.12-py3-none-any.whl.

File metadata

File hashes

Hashes for universal_sandbox-0.0.12-py3-none-any.whl
Algorithm Hash digest
SHA256 fa924e541d1adc6d4c52530cdac5fa7afdab53e73cd3792f7897c43fc47ce223
MD5 5d36a298178be47134bc71e712aa65a9
BLAKE2b-256 fe64fef9c192a6e9ab226e8337df48f59f3fd1844f3b5e60e95e0c9779958ed2

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