Sandbox0 Python SDK
Project description
Sandbox0 Python SDK
The official Python SDK for Sandbox0, providing typed models and ergonomic high-level APIs for managing secure code execution sandboxes.
Installation
pip install sandbox0
Requirements
- Python 3.9 or later
Configuration
| Environment Variable | Required | Default | Description |
|---|---|---|---|
SANDBOX0_TOKEN |
Yes | - | API authentication token |
SANDBOX0_BASE_URL |
No | https://api.sandbox0.ai |
API base URL |
Quick Start
import os
from sandbox0 import Client, CmdOptions
client = Client(token=os.environ["SANDBOX0_TOKEN"])
# Using context manager for automatic cleanup
with client.sandboxes.open("default") as sandbox:
# Execute Python code (REPL - stateful)
result = sandbox.run("python", "print('Hello, Sandbox0!')")
print(result.output_raw, end="")
CMD Streaming
stream = sandbox.cmd_stream(
"sh -c 'echo hello && echo warn >&2'",
CmdOptions(command=["sh", "-c", "echo hello && echo warn >&2"]),
)
for output in stream.iter_outputs():
print(output.data, end="")
done = stream.wait()
print(f"exit={done.exit_code} state={done.state}")
Documentation
Bootstrap Mounts At Claim Time
from sandbox0.apispec.models.claim_mount_request import ClaimMountRequest
from sandbox0.apispec.models.create_sandbox_volume_request import CreateSandboxVolumeRequest
volume = client.volumes.create(CreateSandboxVolumeRequest())
sandbox = client.sandboxes.claim(
"default",
mounts=[
ClaimMountRequest(
sandboxvolume_id=volume.id,
mount_point="/workspace/data",
)
],
)
for mount in sandbox.bootstrap_mounts:
print(mount.sandboxvolume_id, mount.state)
Links
License
Apache-2.0
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
sandbox0-0.4.4.tar.gz
(155.9 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
sandbox0-0.4.4-py3-none-any.whl
(486.4 kB
view details)
File details
Details for the file sandbox0-0.4.4.tar.gz.
File metadata
- Download URL: sandbox0-0.4.4.tar.gz
- Upload date:
- Size: 155.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
344d811fbfc73293613a6aedbb6a87c06788d5849608da1eac45e992ff0a6fee
|
|
| MD5 |
a0efa383c97124c0c828124978038a51
|
|
| BLAKE2b-256 |
6f28572cc33557d81cf43f608fa417d573679a3b76acaed492166602d06da3cb
|
File details
Details for the file sandbox0-0.4.4-py3-none-any.whl.
File metadata
- Download URL: sandbox0-0.4.4-py3-none-any.whl
- Upload date:
- Size: 486.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
745afa5b02ed09a46d9e9d38c23055351a8e1d6fd3b0b49018575b7082f455c1
|
|
| MD5 |
ca03e9a3bba1c23ef3be5fc7bab92fa1
|
|
| BLAKE2b-256 |
ce5b95b789c73703a47146222c1a55234b88f353b479a32924b4817fbfd634ef
|