Skip to content

SDKs ​

OpenSandbox provides five sandbox SDKs for lifecycle management, command execution, file operations, and resource metrics. This site follows the repository's default branch; a feature merged here may require a newer package than the one you have installed. Check the release index when upgrading.

Installation ​

LanguagePackageInstall
Pythonopensandboxpip install opensandbox
JavaScript/TypeScript@alibaba-group/opensandboxnpm install @alibaba-group/opensandbox
Kotlin/Javacom.alibaba.opensandbox:sandboxGradle/Maven
Gogithub.com/alibaba/OpenSandbox/sdks/sandbox/gogo get github.com/alibaba/OpenSandbox/sdks/sandbox/go
C#/.NETAlibaba.OpenSandboxdotnet add package Alibaba.OpenSandbox

Capability coverage ​

“Yes” means a public SDK entry point exists. Availability also depends on the server runtime and the execd version installed in the sandbox.

CapabilityPython async/syncJavaScript/TypeScriptKotlin/JavaGoC#/.NET
Create, connect, renew, pause/resume, killYesYesYesYesYes
Snapshots and template managementYesYesYesYesYes
Resource requests, volumes, lifecycle hooksYesYesYesYesYes
Commands, files, resource metricsYesYesYesYesYes
Egress policy and Credential VaultYesYesYesYesYes
Isolated sessionsYesYesYesYesYes
Client Pool, including RedisYesYesYesYesNo
Pool warmup tracingYesYes, fewer attributesYesNoNo
Diagnostic context, logs/eventsYesYesYesYesYes
Create-latency telemetryYesYesYesYesYes

Differences that affect application code ​

  • Pools: Go exposes different warmup controls; the fields accepted by the default pool creator also differ across languages. See the pool configuration matrix.
  • Go command control: interrupt, command status, and accumulated command logs are exposed by ExecdClient, rather than the high-level Sandbox wrapper. Neither Sandbox.CreateSession nor ExecdClient.CreateSession accepts an initial working directory. Set Cwd when running a command in the session instead.
  • Go connect/resume readiness: pass ReadyOptions to request readiness checks. Without it, connecting resolves the endpoint without checking sandbox health.
  • Metrics streaming: Go exposes ExecdClient.WatchMetrics; the other SDKs' stable metrics services provide point-in-time reads. The CLI also has a metrics stream via osb sandbox metrics --watch.
  • Timeout units: use Python timedelta and JVM Duration; JavaScript and C# command timeouts use seconds. Go RunCommandRequest.Timeout uses milliseconds.

Template-backed sandboxes require an explicit TTL and inherit their workload configuration from the published template. Their egress policy is managed through the lifecycle API; they do not have a sandbox-side Credential Vault.

Feature guides ​

  • Client Pool: keep a ready buffer, select an acquire policy, share state through Redis, and retire a pool namespace.
  • Observability: configure pool warmup traces and creation metrics, understand the default settings, and locate slow startup phases.

Diagnostics ​

All sandbox SDKs expose diagnostic context, logs, and events on both Sandbox and SandboxManager. Use a manager when execd is not ready: these requests go to the lifecycle server without connecting to the sandbox.

LanguageContextLogs / events
Python async/syncget_diagnostic_contextget_diagnostic_logs / get_diagnostic_events
Kotlin/Java, JavaScriptgetDiagnosticContextgetDiagnosticLogs / getDiagnosticEvents
GoGetDiagnosticContextGetDiagnosticLogs / GetDiagnosticEvents
C#GetDiagnosticContextAsyncGetDiagnosticLogsAsync / GetDiagnosticEventsAsync

Manager methods take a sandbox ID; sandbox methods use the current instance. Context returns the backend type, backend-defined identifiers, and lifecycle state when available. Log/event methods also require a scope such as container or runtime. Availability depends on the server backend. URL-delivered content is not downloaded automatically; inspect truncated and warnings. C# SdkDiagnosticsOptions separately controls local SDK logging.

Lifecycle and cleanup ​

High-level image/snapshot creation defaults to a 10-minute TTL. Configure the TTL explicitly for your workload. To disable expiration, use Python timeout=None, JavaScript timeoutSeconds: null, Kotlin timeout(null), or the Go/C# ManualCleanup option. Template creation requires a TTL.

close(), DisposeAsync(), and context-manager exit release local client resources; they do not kill the remote sandbox. Kill it in a finally/defer block, or use Python's destroy() helper. Pool acquisitions are consumed once and are not returned to the idle buffer.

CLI ​

Use the CLI to manage sandboxes, run commands, and work with files from a terminal.

bash
uv tool install opensandbox-cli

MCP server ​

The MCP server exposes sandbox operations to MCP-capable clients:

bash
pip install opensandbox-mcp

Copyright © OpenSandbox a Series of LF Projects, LLC