SeaCloudAI sandbox SDK for control-plane, build-plane, and runtime CMD APIs.
Project description
Sandbox Python SDK
Python SDK for Sandbox control-plane, build-plane, and nano-executor CMD APIs.
Install
pip install seacloud-sandbox
Client Initialization
- unified gateway client:
Client(base_url=..., api_key=...) - build plane via root client:
client.build - runtime helper:
sandbox.runtimeorclient.runtime_from_sandbox(sandbox)
control and build talk to the gateway. Runtime access is derived from sandbox create/detail/connect responses; callers should not hardcode runtime endpoints or tokens.
Recommended Workflow
Most applications only need the root client:
- Initialize
Client(base_url=..., api_key=...). - Create, list, get, or connect sandboxes from the root client.
- Keep working from the bound sandbox object:
reload(),logs(),pause(),refresh(),set_timeout(),connect(),delete(). - When the sandbox exposes
envdUrl, switch into runtime operations throughsandbox.runtime. - Use
client.buildonly for template/build workflows.
Quick Start
Control Plane
import os
from sandbox import Client
client = Client(
base_url="https://sandbox-gateway.cloud.seaart.ai",
api_key=os.environ["SEACLOUD_API_KEY"],
timeout=180,
)
sandbox = client.create_sandbox({
"templateID": "base",
"workspaceId": "python-sdk-demo",
"timeout": 1800,
"waitReady": True,
})
print(sandbox["sandboxID"], sandbox.get("envdUrl"))
if sandbox.get("envdUrl"):
print(sandbox.runtime.base_url)
Bound Sandbox Workflow
listed = client.list_sandboxes()
for sandbox in listed:
detail = sandbox.reload()
print(detail["sandboxID"], detail["status"])
Build Plane Through Root Client
import os
from sandbox import Client
client = Client(
base_url="https://sandbox-gateway.cloud.seaart.ai",
api_key=os.environ["SEACLOUD_API_KEY"],
)
template = client.build.create_template({
"name": "demo",
"visibility": "personal",
"image": "docker.io/library/alpine:3.20",
})
print(template["templateID"], template["buildID"])
Runtime Helper
import os
from sandbox import Client
from sandbox.cmd import FileRequest, UploadBytesRequest
client = Client(
base_url="https://sandbox-gateway.cloud.seaart.ai",
api_key=os.environ["SEACLOUD_API_KEY"],
)
created = client.create_sandbox({
"templateID": os.environ["SANDBOX_EXAMPLE_TEMPLATE_ID"],
"waitReady": True,
})
runtime = created.runtime
try:
runtime.write_file(UploadBytesRequest(
path="/root/workspace/hello.txt",
data=b"hello from python",
))
with runtime.read_file(FileRequest(path="/root/workspace/hello.txt")) as response:
print(response.read().decode("utf-8"))
finally:
created.delete()
Root Client First
For most integrations, stay on the root client as long as possible:
- initialize once with
Client(base_url=..., api_key=...) - use
create_sandbox,list_sandboxes,get_sandbox,connect_sandbox - continue from the returned sandbox object with
reload(),logs(),pause(),refresh(),set_timeout(),connect(),delete() - only switch to runtime with
runtimewhen you need file/process/stream operations - use
client.buildonly for template/build workflows
Low-level submodules remain available when you want direct stateless calls or need request/response models explicitly.
API Surface
Control Plane APIs
sandbox.Client exposes control-plane methods directly and build-plane methods under client.build:
- system:
metrics,shutdown - sandboxes:
create_sandbox,list_sandboxes,get_sandbox,delete_sandbox - sandbox operations:
get_sandbox_logs,pause_sandbox,connect_sandbox,set_sandbox_timeout,refresh_sandbox,send_heartbeat - admin:
get_pool_status,start_rolling_update,get_rolling_update_status,cancel_rolling_update
Recommended root-client path:
- sandbox lifecycle:
create_sandbox,list_sandboxes,get_sandbox,connect_sandbox - follow-up control actions from the returned object:
reload(),logs(),pause(),refresh(),set_timeout(),connect(),delete() - runtime actions from objects that include
envdUrl:runtime
Low-level direct methods like delete_sandbox and get_sandbox_logs remain available on the root client when you want stateless calls.
Build Plane Namespace
client.build exposes:
- system:
metrics - direct build:
direct_build - templates:
create_template,list_templates,get_template_by_alias,get_template,update_template,delete_template - builds:
create_build,get_build_file,rollback_template,list_builds,get_build,get_build_status,get_build_logs
Runtime Namespace
The object returned by sandbox.runtime or client.runtime_from_sandbox(...) exposes:
- system:
metrics,envs,configure,ports - proxy and file transfer:
proxy,download,files_content,upload_bytes,upload_json,upload_multipart,write_batch,compose_files,read_file,write_file - filesystem RPC:
list_dir,stat,make_dir,remove,move,edit - watchers:
watch_dir,create_watcher,get_watcher_events,remove_watcher - process RPC:
start,connect,list_processes,send_input,send_signal,close_stdin,update,stream_input,get_result,run
Useful CMD helpers:
sandbox.cmd.CmdRequestOptions: username, signature, signature expiration, range, timeout, extra headersProcessStreamandFilesystemWatchStream: Connect-RPC stream readersConnectFrame: low-level frame parser
Module Layout
sandbox: rootClientand recommended entrypointsandbox.control: control-plane models and low-level APIssandbox.build: build-plane models and low-level APIssandbox.cmd: runtime models and low-level APIssandbox.core: shared transport and error primitives
Notes
- The gateway entrypoint only needs
base_url + api_key. - Runtime access should be derived from sandbox response objects with
sandbox.runtimeorruntime_from_sandbox(...). create_sandboxandget_sandboxreturnenvdUrlandenvdAccessTokenwhen nano-executor access is enabled.- Runtime file/process APIs require a template image that starts nano-executor and returns runtime access fields; if runtime APIs return
404, verify the selected template supports CMD runtime routes. - Runtime requests can override timeout per call through
CmdRequestOptions(timeout=...). waitReady=Truecan take longer than the default timeout in production; passtimeout=...toClient(...)for long-wait workflows.- HTTP errors are classified into typed exceptions such as
NotFoundError,RateLimitError, andServerError. Transport timeouts raiseRequestTimeoutError. - Sandbox timeout is validated to
0..86400; refresh duration to0..3600. - Build validation currently rejects unsupported
fromImageRegistry,force, and per-stepargs/force. - Some gateways do not expose
/admin/*or/build; integration tests skip those cases on404.
Security
- Do not commit
SEACLOUD_API_KEY,envdAccessToken, or sandbox access tokens. - Treat runtime tokens as sandbox-scoped secrets. Prefer
sandbox.runtimeorclient.runtime_from_sandbox(...)so response-scoped runtime access is not copied into configuration. - Do not log raw API keys or runtime tokens. SDK exceptions may include response bodies, so avoid logging full error payloads in multi-tenant systems.
- The SDK does not construct tenant routing headers. Gateway routing context is derived from the API key.
Production Smoke
Use production smoke tests only with explicitly provided credentials and disposable sandboxes:
SANDBOX_RUN_INTEGRATION=1 \
SANDBOX_TEST_BASE_URL=https://sandbox-gateway.cloud.seaart.ai \
SANDBOX_TEST_API_KEY=... \
SANDBOX_TEST_TEMPLATE_ID=tpl-base-dc11799b9f9f4f9e \
PYTHONPATH=src python -m unittest discover -s tests -p 'test_*.py' -v
tpl-base-dc11799b9f9f4f9e is a known-good SeaCloudAI runtime template for validating CMD routes such as list_dir, read_file, write_file, and run.
Integration Tests
SANDBOX_RUN_INTEGRATION=1 \
SANDBOX_TEST_BASE_URL=https://sandbox-gateway.cloud.seaart.ai \
SANDBOX_TEST_API_KEY=... \
SANDBOX_TEST_TEMPLATE_ID=... \
PYTHONPATH=src python -m unittest discover -s tests -p 'test_*.py' -v
Use a runtime-enabled template for CMD integration coverage. For SeaCloudAI production smoke tests, tpl-base-dc11799b9f9f4f9e is a known-good runtime template.
Release
- See
CHANGELOG.mdfor release notes. - See
RELEASE_CHECKLIST.mdbefore tagging or publishing a new version. - GitHub Actions can publish to PyPI through Trusted Publishing with
.github/workflows/publish.yml.
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
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 seacloud_sandbox-0.1.1.tar.gz.
File metadata
- Download URL: seacloud_sandbox-0.1.1.tar.gz
- Upload date:
- Size: 25.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ba3b99e7dd724f63d5aac1606e12f340a2253282956f92e63c39affd48db3c7
|
|
| MD5 |
e08d9e0be1a3c833609d393e573b5dda
|
|
| BLAKE2b-256 |
81153981b17d7cc154ef2ad854377a53dd0c0e1d92ab97c542fdd5bf0172dda4
|
Provenance
The following attestation bundles were made for seacloud_sandbox-0.1.1.tar.gz:
Publisher:
publish.yml on SeaCloudAI/sandbox-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seacloud_sandbox-0.1.1.tar.gz -
Subject digest:
1ba3b99e7dd724f63d5aac1606e12f340a2253282956f92e63c39affd48db3c7 - Sigstore transparency entry: 1367343856
- Sigstore integration time:
-
Permalink:
SeaCloudAI/sandbox-python@5c35b1338f60b5efcba3e2db6f29ca4b0ed905b2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/SeaCloudAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5c35b1338f60b5efcba3e2db6f29ca4b0ed905b2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file seacloud_sandbox-0.1.1-py3-none-any.whl.
File metadata
- Download URL: seacloud_sandbox-0.1.1-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0415d98d407177bc1f7f2aaf668641ed4e68516120fa70f66e63c6a18d862a80
|
|
| MD5 |
f45c0abdae5b47e47271733c3ade437d
|
|
| BLAKE2b-256 |
b8e9e0df01d7a13a852d987facec5dfa50927be48aedd7c91f405ca545ad1eeb
|
Provenance
The following attestation bundles were made for seacloud_sandbox-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on SeaCloudAI/sandbox-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
seacloud_sandbox-0.1.1-py3-none-any.whl -
Subject digest:
0415d98d407177bc1f7f2aaf668641ed4e68516120fa70f66e63c6a18d862a80 - Sigstore transparency entry: 1367343876
- Sigstore integration time:
-
Permalink:
SeaCloudAI/sandbox-python@5c35b1338f60b5efcba3e2db6f29ca4b0ed905b2 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/SeaCloudAI
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5c35b1338f60b5efcba3e2db6f29ca4b0ed905b2 -
Trigger Event:
push
-
Statement type: