Skip to main content

cua (Python)

The cua SDK for Python: a thin, generated binding over the Rust cua-sdk crate (libs/cua/crates/cua-sdk). The same API runs embedded in your process or against a cua daemon that shares sandboxes, spacesd connections and credentials across processes.

import asyncio, cua

async def main():
    c = cua.embedded()
    sb = await c.sandboxes().connect_url("http://127.0.0.1:3211", "token", "dev")
    env = await sb.spacesd(None)
    print((await env.run(cua.SpacesdCommand(program="uname", args=["-a"]))).stdout.decode())
    png = await env.screenshot(None)

asyncio.run(main())

Sandboxes: any image, local or cloud

c = cua.embedded()
sb = await c.sandboxes().create(cua.SandboxCreateOptions(
    on="local",                                   # or "aws": same options
    image="python:3.12-slim",
    command=["python", "-m", "my_mcp", "--port", "8765"],
    env={"FOO": "bar"},
    services={"mcp": 8765},
    wait_for=[cua.ReadinessProbe(port=0, service="mcp", http_path="/health")],
    cloud=cua.CloudOptions(warm=True),            # optional, ignored locally
))
svc = sb.service("mcp")
r = await svc.request("POST", "/mcp", body, None, [cua.HttpHeader(name="accept", value="application/json, text/event-stream")])
url = await svc.url()                             # usable from this machine
share = await sb.public_url("mcp", 3600, None)    # shareable, expires
fwd = await sb.forward(8765)                      # loopback URL: fwd.url()
info = sb.info()  # id, phase, location, services, expires_at_unix, provider_details

public_url is a signed URL in the cloud and a loopback URL with its own token locally, served by the cua daemon (started on demand with the cua CLI, which pip install cua installs through its cua-cli dependency). await sb.mcp("mcp", None) is an MCP client for a server the sandbox serves and await sb.mcp_config("mcp", None) its URL and headers for any MCP client; neither needs cua-spacesd. cua.canonical_image("linux", None) returns ghcr.io/trycua/linux:24.04. Cloud env, sidecars (addressed by name, on gVisor and KubeVirt) and registry secrets work like local ones; cloud image layers (a remote build) are not available yet and fail with a clear error.

High-level API (optional extras)

cua replaces the former cua meta-package (0.1.x). Its convenience imports resolve lazily from optional extras:

pip install "cua[sandbox]"   # cua-sandbox: Sandbox, Image, QEMURuntime, ...
pip install "cua[agent]"     # cua-agent: ComputerAgent, cua.callbacks, cua.tools
pip install "cua[all]"       # both (the `cua` command is the Rust CLI in libs/cua)
pip install --no-deps cua    # the SDK alone, without the `cua` command (`cua-cli`)
from cua import Sandbox, Image            # cua_sandbox.Sandbox / Image
async with Sandbox.ephemeral(Image.linux(), local=True) as sb:
    print((await sb.shell.run("uname -a")).stdout)

With cua-sandbox installed, cua.Sandbox is the high-level cua_sandbox.Sandbox; the SDK's own handle type (what sandboxes().create() returns) is always cua.SandboxHandle.

  • cua._native is generated by libs/cua/scripts/generate-uniffi-bindings.mjs and must not be edited; --check fails CI when it drifts.
  • Wheels are platform wheels (build_wheel.py), one per OS/arch, each with the libcua_sdk library next to _native.py (and the static Linux cua-spacesd in cua/bin/). The cua CLI is a second platform wheel, cua-cli (cli/), a dependency of cua that installs cua_cli/bin/cua[.exe]; the cua command runs it with CUA_SPACESD_STATIC set to that cua-spacesd. PyPI caps each file at 100 MB and the two together are over it.

Development

cd libs/cua
cargo build --release -p cua-sdk
scripts/build-test-fixtures.sh
node scripts/stage-uniffi-library.mjs          # copies the library here
cd python && uv run --with pytest pytest -q    # smoke tests against fixtures

Metadata

Release files for cua 0.20.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for cua 0.20.0
File Actions
cua-0.20.0-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details for cua-0.20.0-py3-none-win_arm64.whl
cua-0.20.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for cua-0.20.0-py3-none-win_amd64.whl
cua-0.20.0-py3-none-manylinux_2_31_x86_64.whl Python 3 none Linux glibc 2.31+ x86-64 Details for cua-0.20.0-py3-none-manylinux_2_31_x86_64.whl
cua-0.20.0-py3-none-manylinux_2_31_aarch64.whl Python 3 none Linux glibc 2.31+ ARM64 Details for cua-0.20.0-py3-none-manylinux_2_31_aarch64.whl
cua-0.20.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for cua-0.20.0-py3-none-macosx_11_0_arm64.whl
cua-0.20.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for cua-0.20.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 330.4 MB

Release files / cua-0.20.0-py3-none-win_arm64.whl

Download URL cua-0.20.0-py3-none-win_arm64.whl
Size 53.7 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
c29d44d9a8a7f6680adc0b32af5d579aaf0c017c8c4d8d5b3f6c4d53ebee1a3f
BLAKE2b-256 checksum
How to use checksums
bde8348a4187d7b38f8fa26f90cf2ea0915bc64d474946547ee170353d4df770
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / cua-0.20.0-py3-none-win_amd64.whl

Download URL cua-0.20.0-py3-none-win_amd64.whl
Size 58.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
cea82327107bb6c14a37bf67785c6958d2e291c904dd77e78eaef683bc410f2a
BLAKE2b-256 checksum
How to use checksums
49eb409058dd49be401aca5c71333937dcc34435f3a35d0527d69c4973e77e50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / cua-0.20.0-py3-none-manylinux_2_31_x86_64.whl

Download URL cua-0.20.0-py3-none-manylinux_2_31_x86_64.whl
Size 58.6 MB
Tags Linux glibc 2.31+ x86-64 Python 3
SHA-256 checksum
How to use checksums
18c75bdac547f4fbd73c85167af25b4b3d5f65adabbe5665a90bf7d156fa6167
BLAKE2b-256 checksum
How to use checksums
acae2d9f63c4376a19f34f1c7bacf18cb502d8f1e996cdaec3a36a8bbbd3d571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / cua-0.20.0-py3-none-manylinux_2_31_aarch64.whl

Download URL cua-0.20.0-py3-none-manylinux_2_31_aarch64.whl
Size 53.3 MB
Tags Linux glibc 2.31+ ARM64 Python 3
SHA-256 checksum
How to use checksums
f589e62f99337aa2c89fb9badfa5171ac2cfdf5b991a679b18b36e251a28f415
BLAKE2b-256 checksum
How to use checksums
739c53312a874b0bbca407a4149a90910d370a1257ceff552a75d1b74252850b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / cua-0.20.0-py3-none-macosx_11_0_arm64.whl

Download URL cua-0.20.0-py3-none-macosx_11_0_arm64.whl
Size 51.0 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1e3477b9a99645f0329a48b8d41bbf74fdc2ed54b4ad41c9084297c7f48eabe2
BLAKE2b-256 checksum
How to use checksums
f688b9ffefeb611b91eb201e5bdfaba56af09c20b0a0250951ec724a82f6713f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / cua-0.20.0-py3-none-macosx_10_12_x86_64.whl

Download URL cua-0.20.0-py3-none-macosx_10_12_x86_64.whl
Size 55.8 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
ed95caaebc3169690b6d820bcafa70855ee1400b685ecf765528df6161dc2874
BLAKE2b-256 checksum
How to use checksums
56ac76a5317a74e20c2db179001d45cb4a52a45d9b3f9348fd1c19806bde4669
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for cua 0.20.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page