Cua Sandbox gives you a full, isolated computer — not a container shell or a remote desktop session — through a single Python API. Each sandbox is a disposable machine that starts from a known state, runs whatever code or GUI automation your agent needs, and can be destroyed without touching the host. Because both the code half (Documentation 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.
sb.shell, sb.terminal) and the GUI half (sb.mouse, sb.keyboard, sb.screen) share one filesystem and one OS state, an agent can click through a UI workflow and then immediately inspect the files it produced using a shell command.
What is Cua Sandbox?
Thecua-sandbox package (imported as cua) is the core SDK. The cua meta-package bundles cua-sandbox together with the agent framework and CLI so you can pip install cua and have everything in one step. The cua meta-package requires Python 3.12+. The cua-sandbox package alone requires Python 3.11+.
- Meta-package (recommended)
- Sandbox only
cua-sandbox, cua-agent, and cua-cli together.OS matrix
Cua Sandbox supports five operating systems across two execution modes: cloud (managed by cua.ai) and local (runs on your own hardware using Docker, QEMU, Lume, or Hyper-V).| Image | Kind | Cloud | Local runtime |
|---|---|---|---|
Image.linux() | VM | ✅ | QEMU |
Image.linux(kind='container') | Container | ✅ | Docker Desktop |
Image.macos() | VM | ✅ | Lume (Apple Silicon) |
Image.windows() | VM | ✅ | QEMU / Hyper-V |
Image.android() | VM | ✅ | QEMU |
BYOI (.qcow2, .iso) | VM | 🔜 soon | ✅ QEMU |
Linux containers share the host kernel and start faster. Full VMs boot their own kernel for higher OS fidelity. Choose containers for fast Linux CI work and VMs when behavior must match a real machine.
Minimal working example
The snippet below creates an ephemeral Ubuntu 24.04 VM, runs a shell command, and takes a screenshot — all in under ten lines. The sandbox is automatically destroyed when theasync with block exits.
local=True to run on your own machine instead of the cloud:
Cloud vs local execution
- Cloud
- Local
Sandbox interfaces
EverySandbox instance exposes the same set of interfaces regardless of the OS or runtime:
| Attribute | Purpose |
|---|---|
sb.shell | Run shell commands, get stdout/stderr/returncode |
sb.mouse | Click, double-click, drag, scroll |
sb.keyboard | Type text, press key combinations |
sb.screen | Take screenshots, query screen size |
sb.clipboard | Read and write clipboard text |
sb.tunnel | Forward sandbox ports to localhost |
sb.terminal | Open interactive PTY sessions |
sb.window | Query the active window title |
sb.mobile | Android touch and hardware-key control |
What to read next
Images
Configure OS type, install packages, copy files, and chain builder calls into a reproducible image spec.
Lifecycle
Understand ephemeral vs persistent sandboxes, context managers, reconnect, list, and delete.
Scale Out
Run dozens of sandboxes in parallel with asyncio.gather, Semaphore, and Queue patterns.
Secrets
Inject API keys and credentials at runtime without baking them into the image.