Python SDK for Universal Sandbox API
Project description
Universal Sandbox Python SDK
Python SDK for Universal Sandbox API.
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 statussandbox.list_regions()- List available regions for all providerssandbox.get_limits()- Get resource limits and current usage
Sandbox Creation
sandbox.code_interpreter.create(provider, timeout_minutes, region, metadata)- Create code interpretersandbox.browser.create(provider, timeout_minutes, region, metadata)- Create browser sandboxsandbox.aio.create(provider, timeout_minutes, region, metadata)- Create all-in-one sandbox (only supportsprovider="volcengine")
Sandbox Management
sandbox.sandboxes.list()- List all sandboxessandbox.sandboxes.get(sandbox_id)- Get sandbox by IDsandbox.sandboxes.delete(sandbox_id)- Delete a sandboxsandbox.sandboxes.execute(sandbox_id, command, timeout)- Execute command
Token Management (Admin)
sandbox.tokens.issue(...)- Create a personal access tokensandbox.tokens.revoke(prefix)- Revoke a tokensandbox.tokens.get(user_id)- Get user's token
Project details
Release history Release notifications | RSS feed
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.10.tar.gz
(30.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file universal_sandbox-0.0.10.tar.gz.
File metadata
- Download URL: universal_sandbox-0.0.10.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3db0c7b28edea57aba1117fd0668bc6827fb653dcb2f8bd02c06a69d55797eb6
|
|
| MD5 |
269d52234d7ce48f3dba3f02c52cf34f
|
|
| BLAKE2b-256 |
ded6954ea319dd792723a81010f782a30dc494b2c8e79894ce1b400aeaf19430
|
File details
Details for the file universal_sandbox-0.0.10-py3-none-any.whl.
File metadata
- Download URL: universal_sandbox-0.0.10-py3-none-any.whl
- Upload date:
- Size: 55.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35ca3db8800f805f2cb0f135c1313f7daa5335e1473253f2f901b7f6af2a7522
|
|
| MD5 |
7633a545f98b03707c0bef82d9db40f0
|
|
| BLAKE2b-256 |
54c2b97983eb799a081eab17a797e4db4b76ae8d6853d91c49abc9b0ecbd49af
|