Python high-level API

cua_sandbox and the cua package helpers: packages, configuration, and the page for each class.

The high-level Python API: cua_sandbox (Sandbox, Image, the computer interfaces) and the helpers the cua package adds. It is a thin layer over the Cua SDK objects: the local runtimes and cua-spacesd all go through cua, whose generated binding (cua._native) those pages document.

PackageInstallImport
cua-sandbox (Python 3.11 to 3.13)pip install cua-sandboxfrom cua_sandbox import Sandbox, Image
cua with the extrapip install "cua[sandbox]"from cua import Sandbox, Image (the same classes)
MCP client supportpip install "cua-sandbox[mcp]"sb.mcp()
Typed Cua Driver accesspip install "cua-sandbox[driver]"sb.driver

configure() sets process-wide options; environment variables override it:

VariablePurposeDefault
CUA_CLIENT_ID, CUA_CLIENT_SECRETAPI key credentialsNone; then the cua auth login session
CUA_TOKEN_URLToken endpointThe cua.ai token endpoint
CUA_IMAGE_LINUX, CUA_IMAGE_WINDOWS, CUA_IMAGE_MACOSOverride Image.linux(), Image.windows(), Image.macos()The canonical images

Pages#

PageCovers
Sandbox, images and servicesSandbox, the sandbox() helper and its creation options, the Image builder, and the services, tunnels and MCP endpoints of a sandbox.
InterfacesShell, mouse, keyboard, screen, clipboard, window, terminal, files, apps, mobile and driver interfaces.
Runtimes and configurationLocal runtimes (Docker, QEMU, Lume, Hyper-V, Tart, Android emulator), support checks, configuration, sign-in and errors.

The cua package#

The hand-written layer of cua: two module-level constructors, a canonical-image helper and lazy re-exports of the extras.

embedded#

def embedded(
    *,
    state_dir: Optional[str] = None,
    account_from_session: bool = False,
    env_probe_timeout_ms: Optional[int] = None,
    spaces_home: Optional[str] = None,
    teleport_home: Optional[str] = None,
) -> Cua

An SDK runtime in this process (no I/O until the first call).

account_from_session=True uses the cua auth login session for the relay account the runtime lists "My machines" with. spaces_home is the Spaces registry directory (default ~/.cua); teleport_home makes teleport read app sessions under that directory with no host side effects (tests).

connect#

def connect(address: Optional[str] = None, token: Optional[str] = None) -> Cua

A client of a running cua daemon (socket path or loopback URL).

Image#

Without cua[sandbox], cua.Image is this helper. With it installed, cua.Image is the richer cua_sandbox Image.

class Image

Canonical image references (plain strings for sandboxes().create).

Example

from cua_sandbox import Image
 
img = Image.linux().apt_install("curl").pip_install("requests").env(DEBUG="1").expose(8080)
print(img.to_dict())
# {'os_type': 'linux', 'distro': 'ubuntu', 'version': '24.04', 'kind': None,
#  'layers': [{'type': 'apt_install', 'packages': ['curl']},
#             {'type': 'pip_install', 'packages': ['requests']}],
#  'env': {'DEBUG': '1'}, 'ports': [8080]}

Image.linux#

@staticmethod
def linux(version: Optional[str] = None, tier: Optional[str] = None) -> str

slim, full (the default) or docker (a VM with dockerd).

Image.windows#

@staticmethod
def windows(version: Optional[str] = None, tier: Optional[str] = None) -> str

Image.macos#

@staticmethod
def macos(version: Optional[str] = None, tier: Optional[str] = None) -> str

slim, full (the default), xcode or xcode-<X.Y>.

Image.omarchy#

@staticmethod
def omarchy(channel: Optional[str] = None) -> str

Omarchy (Arch Linux, Hyprland) with cua-spacesd: an amd64 VM (ghcr.io/trycua/omarchy:edge; emulated on arm64 hosts).

Image.from_registry#

@staticmethod
def from_registry(reference: str) -> str

Image.resolve#

@staticmethod
def resolve(
    reference: str,
    backend: str = 'local',
    arch: Optional[str] = None,
) -> ResolvedImage

Names from the extras#

cua resolves these names lazily from the optional extras. Install the extra to use them.

NameResolves toExtra
cua.AgentResponsecua_agent.AgentResponsecua[agent]
cua.AndroidEmulatorRuntimecua_sandbox.runtime.AndroidEmulatorRuntimecua[sandbox]
cua.check_local_supportcua_sandbox.check_local_supportcua[sandbox]
cua.Clipboardcua_sandbox.interfaces.clipboard.Clipboardcua[sandbox]
cua.CloudTransportcua_sandbox.CloudTransportcua[sandbox]
cua.CommandResultcua_sandbox.interfaces.shell.CommandResultcua[sandbox]
cua.ComputerAgentcua_agent.ComputerAgentcua[agent]
cua.configurecua_sandbox.configurecua[sandbox]
cua.DockerRuntimecua_sandbox.runtime.DockerRuntimecua[sandbox]
cua.EnvTransportcua_sandbox.EnvTransportcua[sandbox]
cua.HyperVRuntimecua_sandbox.runtime.HyperVRuntimecua[sandbox]
cua.Imagecua_sandbox.Imagecua[sandbox]
cua.Keyboardcua_sandbox.interfaces.keyboard.Keyboardcua[sandbox]
cua.logincua_sandbox.logincua[sandbox]
cua.LumeRuntimecua_sandbox.runtime.LumeRuntimecua[sandbox]
cua.Messagescua_agent.Messagescua[agent]
cua.Mobilecua_sandbox.interfaces.mobile.Mobilecua[sandbox]
cua.Mousecua_sandbox.interfaces.mouse.Mousecua[sandbox]
cua.QEMURuntimecua_sandbox.runtime.QEMURuntimecua[sandbox]
cua.register_agentcua_agent.register_agentcua[agent]
cua.RuntimeInfocua_sandbox.runtime.RuntimeInfocua[sandbox]
cua.RuntimeSupportcua_sandbox.RuntimeSupportcua[sandbox]
cua.sandboxcua_sandbox.sandboxcua[sandbox]
cua.Sandboxcua_sandbox.Sandboxcua[sandbox]
cua.SandboxInfocua_sandbox.SandboxInfocua[sandbox]
cua.Screencua_sandbox.interfaces.screen.Screencua[sandbox]
cua.Shellcua_sandbox.interfaces.shell.Shellcua[sandbox]
cua.skip_if_unsupportedcua_sandbox.skip_if_unsupportedcua[sandbox]
cua.SpacesdNotAvailablecua_sandbox.SpacesdNotAvailablecua[sandbox]
cua.TartRuntimecua_sandbox.runtime.TartRuntimecua[sandbox]
cua.Terminalcua_sandbox.interfaces.terminal.Terminalcua[sandbox]
cua.Tunnelcua_sandbox.interfaces.tunnel.Tunnelcua[sandbox]
cua.TunnelInfocua_sandbox.interfaces.tunnel.TunnelInfocua[sandbox]
cua.whoamicua_sandbox.whoamicua[sandbox]
cua.Windowcua_sandbox.interfaces.window.Windowcua[sandbox]

cua.runtime#

cua.runtime: sandbox runtime backends.

Exports: Runtime, RuntimeInfo, DockerRuntime, QEMURuntime, QEMUDockerRuntime, QEMUBaremetalRuntime, QEMUWSL2Runtime, LumeRuntime, HyperVRuntime, AndroidEmulatorRuntime, TartRuntime.

cua.tools#

cua.tools: agent tool classes and registry.

Exports: BaseTool, BaseComputerTool, register_tool, get_registered_tools, get_tool, TOOL_REGISTRY, BrowserTool, ToolError, IllegalArgumentError.

cua.callbacks#

cua.callbacks: agent lifecycle callback handlers.

Exports: AsyncCallbackHandler, ImageRetentionCallback, LoggingCallback, TrajectorySaverCallback, BudgetManagerCallback, TelemetryCallback, OtelCallback, OtelErrorCallback, OperatorNormalizerCallback, PromptInstructionsCallback.