All method names below use the Python form. The TypeScript SDK mirrors them in camelCase (
start_process → startProcess, read_file → readFile, memory_mb → memoryMb, etc.). The same JavaScript runtime API is used from Node.js.This page focuses on the sandbox runtime SDK surface. Related interfaces documented elsewhere include the CLI and HTTP API, the image-building DSLs in Sandbox Images, and the browser/VNC integration details in Computer Use.
SandboxClient
SandboxClient is the top-level entry point for managing sandboxes in your namespace. Instantiate it once and reuse it — it handles auth, discovery, and the HTTP transport underneath.
- Python
- TypeScript
Create
Create a sandbox. Omitname for an ephemeral sandbox (cannot be suspended); pass name to create a named sandbox that supports suspend/resume. Returns a SandboxInfo describing the new sandbox.
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | None | None | Human-readable name. Required for suspend/resume. |
cpus | float | 1.0 | Number of CPUs to allocate. |
memory_mb | int | 1024 | Memory in megabytes. 1024–8192 MB per CPU core. |
timeout_secs | int | None | None | Auto-suspend (named) or auto-terminate (ephemeral) after this many seconds. |
image | str | None | platform default | Name or ID of a prebuilt Sandbox Image. |
snapshot_id | str | None | None | Restore from a snapshot instead of booting a fresh VM. |
secret_names | list[str] | None | None | Secrets to inject as environment variables. Must be pre-registered with tl secrets set. |
expose_ports | list[int] | None | None | User ports to route public traffic to (see Networking). |
allow_unauthenticated_access | bool | False | If true, exposed ports accept unauthenticated internet traffic. |
- Python
- TypeScript
Create and connect
create_and_connect creates a sandbox and returns a live Sandbox handle you can immediately run commands against — one call instead of two.
- Python
- TypeScript
Connect
Get aSandbox handle for an existing sandbox (by ID or name) without creating a new one. Use this to rejoin a named sandbox after resume, or to operate on a sandbox a different process created.
- Python
- TypeScript
List and get
Inspect sandboxes in your namespace.list() returns all sandboxes; get() returns one by ID or name.
- Python
- TypeScript
Rename
Assigning a name to an ephemeral sandbox converts it to a named sandbox that supports suspend/resume.- Python
- TypeScript
Suspend and resume
Pause a running named sandbox in place; resume it later under the same ID with its memory, filesystem, and running processes intact. Ephemeral sandboxes return an error onsuspend.
- Python
- TypeScript
Terminate
delete() ends the sandbox permanently. Terminated is a final state and cannot be reversed.
- Python
- TypeScript
Expose and unexpose ports
Route public internet traffic to services listening on user ports inside the sandbox. Requests arrive athttps://<port>-<sandbox-id-or-name>.sandbox.tensorlake.ai.
- Python
- TypeScript
Snapshot and restore
Capture a reusable artifact of the sandbox (filesystem + memory + running processes). Restore by passingsnapshot_id to create or create_and_connect.
- Python
- TypeScript
Sandbox handle
TheSandbox object returned by create_and_connect() or connect() is how you execute work inside a running sandbox. All methods below target a single live sandbox.
| Property (Python) | Property (TypeScript) | Type | Description |
|---|---|---|---|
sandbox_id | sandboxId | str | Server-assigned UUID. |
name | name | str | None | Human-readable name, or None for ephemeral. |
Run a command
run() is the short-lived foreground execution primitive: send a command, wait for it to exit, receive captured output. Use it for the common case of “do this one thing and give me the result.”
- Python
- TypeScript
env={"KEY": "value"} (Python) or env: { KEY: "value" } (TypeScript) for per-command environment variables. See Environment Variables.
See Execute Commands for streaming, multi-step shell pipelines, and error handling.
Background processes
For long-running or concurrent work, start a process and keep the handle so you can monitor, stream output, and signal it.- Python
- TypeScript
Writing to stdin
Drive a process interactively from code by writing bytes to its stdin, then closing the stream when you’re done.- Python
- TypeScript
PTY sessions
Open an interactive terminal inside the sandbox. The PTY is created over HTTPS; terminal I/O then moves over a WebSocket attached to the session.- Python
- TypeScript
File operations
Copy data in and out of the sandbox filesystem without spawning a shell.- Python
- TypeScript
Desktop sessions
Desktop sandboxes expose a higher-level remote-control handle on top of the normalSandbox APIs. Use this with tensorlake/ubuntu-vnc to capture screenshots and drive mouse and keyboard input through the authenticated sandbox proxy.
- Python
- TypeScript
| Python | TypeScript | Description |
|---|---|---|
screenshot() | screenshot() | Capture the current desktop as PNG bytes. |
move_mouse(x, y) | moveMouse(x, y) | Move the pointer to absolute screen coordinates. |
click() | click() | Click the current pointer location. |
double_click() | doubleClick() | Double-click the current pointer location. |
scroll_up() / scroll_down() | scrollUp() / scrollDown() | Scroll vertically. |
press(keys) | press(keys) | Send a key or key chord. |
type_text(text) | typeText(text) | Type text into the active window. |
width, height | width, height | Desktop resolution. |
Terminate
Shortcut forclient.delete(sandbox.sandbox_id) that uses the handle you already have.
- Python
- TypeScript
Data models
The SDK returns typed objects for every API call. The fields below are the ones you’ll read most often. Field names shown in Pythonsnake_case; TypeScript uses the camelCase equivalent.
SandboxInfo
Returned byclient.create(), client.get(), client.list(), and the suspend/resume/expose calls.
| Field | Type | Description |
|---|---|---|
sandbox_id | str | Server UUID. |
name | str | None | Name, or None for ephemeral. |
namespace | str | Namespace owning the sandbox. |
status | str | Pending, Running, Suspending, Suspended, Snapshotting, Terminated. |
image | str | Sandbox image in use. |
resources | ContainerResourcesInfo | .cpus: float, .memory_mb: int. |
secret_names | list[str] | Injected secrets. |
timeout_secs | int | Auto-suspend/terminate timeout. |
exposed_ports | list[int] | Public-routed user ports. |
allow_unauthenticated_access | bool | Whether exposed ports accept unauthenticated traffic. |
entrypoint | list[str] | Custom entrypoint command. |
created_at | datetime | None | Creation timestamp. |
terminated_at | datetime | None | Termination timestamp (if terminated). |
Sandbox
Returned byclient.create_and_connect() and client.connect(). Exposes the runtime methods documented above plus:
| Property | Type | Description |
|---|---|---|
sandbox_id / sandboxId | str | UUID, even if connected by name. |
name | str | None | Human-readable name. |
ProcessInfo
Returned bystart_process() and list_processes().
| Field | Type | Description |
|---|---|---|
pid | int | Process ID inside the sandbox. |
command | str | The executed command. |
args | list[str] | Command arguments. |
status | str | Running, Exited, etc. |
exit_code | int | None | Exit code once the process has exited. |
CommandResult
Returned byrun().
| Field | Type | Description |
|---|---|---|
stdout | str | Captured standard output. |
stderr | str | Captured standard error. |
exit_code | int | Process exit code. |
SnapshotInfo
Returned by the snapshot APIs.| Field | Type | Description |
|---|---|---|
snapshot_id | str | Server-assigned ID, use to restore. |
sandbox_id | str | Source sandbox this snapshot was captured from. |
status | str | Pending, Ready, Failed. |
size_bytes | int | None | Size of the snapshot artifact. |
created_at | datetime | None | Capture timestamp. |
Learn more
Lifecycle
State machine, suspend/resume, timeouts.
Execute Commands
Run commands, capture output, stream.
Process Management
Background processes, stdin, signals.
PTY Sessions
Interactive shells over WebSocket.
File Operations
Read, write, list, delete.
Snapshots
Capture and restore full VM state.
Sandbox Images
Prebuild dependencies into reusable images.
Computer Use
Desktop sessions, screenshots, mouse, keyboard.
Networking
Expose user ports to the internet.
Environment Variables
Per-command and per-PTY environment.