TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/trycua/cua/llms.txt
Use this file to discover all available pages before exploring further.
cua-sandbox package gives you programmatic control over ephemeral and persistent sandboxed computer environments — virtual machines and containers running Linux, macOS, Windows, and Android — from Python. The same API works against the Cua cloud and against a local runtime (Docker, Lume, or QEMU), controlled by a single local=True flag.
Installation
- Full SDK
- Sandbox only
| Field | Value |
|---|---|
| Package | cua-sandbox |
| Import name | cua |
| Python versions | 3.11, 3.12, 3.13 |
Top-level exports
| Export | Description |
|---|---|
Sandbox | VM or container control class |
Image | Image builder class (see Image reference) |
Localhost | Direct host control — no sandbox required |
SandboxInfo | Sandbox metadata dataclass |
configure() | Global SDK configuration helper |
login() | Browser-based Cua authentication |
whoami() | Fetch authenticated user info |
Environment variables
| Variable | Description |
|---|---|
CUA_API_KEY | Cua cloud API key. Passed directly or read automatically by all methods. |
Sandbox class
Sandbox is the main entry point. It exposes interfaces (shell, mouse, keyboard, screen, clipboard, tunnel, terminal, window, mobile) for controlling a running VM or container.
When
local=False (the default), sandboxes are created in the Cua cloud using the CUA_API_KEY. Pass local=True to use a local Docker, Lume (macOS), or QEMU runtime — no API key required.Sandbox.ephemeral
Async context manager. Provisions a sandbox, yields it, then destroys it automatically on exit — ideal for one-shot tasks.
The image to run. Build one with
Image.linux(), Image.macos(), etc.Optional human-readable name for the sandbox.
Cua API key. Reads
CUA_API_KEY from the environment if None.Use a local runtime (Docker, Lume, QEMU) instead of the Cua cloud.
Explicit runtime backend. Usually inferred from
image.kind and local.CPU core count override (cloud only).
Memory in megabytes override (cloud only).
Disk size in gigabytes override (cloud only).
Cloud region to provision in.
Sandbox.create
Provisions a persistent sandbox. It keeps running after your script exits. Use Sandbox.connect() to reconnect to it later.
Sandbox.ephemeral.
Sandbox.connect
Connects to an existing sandbox by name. Supports both await (plain connection) and async with (auto-disconnects on exit, sandbox keeps running).
Name of the sandbox to connect to.
Cua API key. Reads
CUA_API_KEY if None.Connect to a locally running sandbox.
Override the WebSocket URL for the transport connection.
Override the HTTP URL for the transport connection.
Override the container name (local Docker runtimes).
Cloud region.
Instance methods
Lifecycle
Drop the transport connection. The sandbox keeps running. Use this when you want to release resources without destroying the sandbox.
Disconnect and permanently delete the sandbox. All state is lost.
Screenshots
Capture the sandbox display.
format is 'png' or 'jpeg'. quality (1–95) applies only to JPEG. text is an optional annotation overlaid on the image.Same as
screenshot() but returns a base64-encoded string — suitable for embedding in JSON or passing to LLM vision APIs.Display and environment
Returns the OS type:
'linux', 'mac', 'windows', or 'browser'.URL to view the sandbox display in a browser. Pass
share=True for a public shareable link (cloud only).Screen width and height in pixels as
(width, height).Class methods (sandbox management)
These methods do not require an active sandbox connection.| Method | Signature | Description |
|---|---|---|
list | async list(local=False, api_key=None) → list[SandboxInfo] | List all running and suspended sandboxes. |
get_info | async get_info(name, local=False, api_key=None) → SandboxInfo | Fetch metadata for a specific sandbox. |
suspend | async suspend(name, local=False, api_key=None) → None | Suspend a sandbox (save state). |
resume | async resume(name, local=False, api_key=None) → Sandbox | Resume a suspended sandbox. Returns a connected Sandbox. |
restart | async restart(name, local=False, api_key=None) → Sandbox | Suspend then resume. Returns a connected Sandbox. |
delete | async delete(name, local=False, api_key=None) → None | Permanently delete a sandbox. |
Cloud vs local
suspend: On cloud, suspend calls POST /v1/vms/{name}/stop. On local QEMU, it takes a QMP snapshot. On local Docker, it pauses the container. On local Lume (macOS), it stops the VM.Sandbox attributes
| Attribute | Type | Description |
|---|---|---|
name | str | None | Sandbox name. |
shell | Shell | Run shell commands — see Interfaces. |
mouse | Mouse | Mouse control — see Interfaces. |
keyboard | Keyboard | Keyboard input — see Interfaces. |
screen | Screen | Screenshots and dimensions — see Interfaces. |
clipboard | Clipboard | Clipboard read/write — see Interfaces. |
tunnel | Tunnel | Port forwarding — see Interfaces. |
terminal | Terminal | PTY sessions — see Interfaces. |
window | Window | Window management — see Interfaces. |
mobile | Mobile | Android touch and hardware keys — see Interfaces. |
SandboxInfo
Returned bySandbox.list() and Sandbox.get_info().
Sandbox name.
Current status:
'running', 'stopped', 'provisioning', etc.Runtime source identifier.
OS type:
'linux', 'macos', 'windows', 'android', or None.Host address for the sandbox.
VNC URL if available.
API URL for direct communication.
ISO 8601 creation timestamp.
SDK configuration
configure
CUA_API_KEY in the environment.
Cua API key.
Override the Cua API base URL.
login
~/.cua/credentials (Clerk auth flow).
whoami
id, email, etc.) from the Cua API.
Localhost
Localhost provides the same interface as Sandbox but controls the host machine directly via cua_auto — no sandbox is created. Useful for local automation without spinning up a VM.
Localhost exposes: screen, mouse, keyboard, clipboard, shell, window, terminal. It does not expose tunnel or mobile.
Methods screenshot, screenshot_base64, get_environment, get_dimensions, and disconnect have the same signatures as on Sandbox.