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 "cloud": 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 bundled CLI). 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, Pool, 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)
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.

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
CUA_E2E_FLEET=1 uv run --with pytest pytest -q tests/test_live_fleet.py  # live Fleet

Metadata

Release files for cua 0.4.1

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.4.1
File
cua-0.4.1-py3-none-win_arm64.whl Python 3 none Windows ARM64 Details
cua-0.4.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
cua-0.4.1-py3-none-manylinux_2_31_x86_64.whl Python 3 none Linux glibc 2.31+ x86-64 Details
cua-0.4.1-py3-none-manylinux_2_31_aarch64.whl Python 3 none Linux glibc 2.31+ ARM64 Details
cua-0.4.1-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
cua-0.4.1-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 422.5 MB

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

Download URL cua-0.4.1-py3-none-win_arm64.whl
Size 61.4 MB
Tags Python 3 Windows ARM64
SHA-256 checksum
How to use checksums
b0f70f039a0e13d7fa804e33f9f79a1208aa1d8dd47e10028594b4bb40ab0ddd
BLAKE2b-256 checksum
How to use checksums
bd9eef96c2a17d74aadc898ddbce440eb87a856e4ef5106ec866971f9ec4f00e
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.4.1-py3-none-win_amd64.whl

Download URL cua-0.4.1-py3-none-win_amd64.whl
Size 66.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
5f5ba8f3f95eca5ae111d134293de3d11be1ff78f072bb0ab81dff5b98091d77
BLAKE2b-256 checksum
How to use checksums
766da9f1491ad9e12b5bc5ca1cb872bb91637ded88c045266d4b51eb3a7b810a
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.4.1-py3-none-manylinux_2_31_x86_64.whl

Download URL cua-0.4.1-py3-none-manylinux_2_31_x86_64.whl
Size 77.2 MB
Tags Linux glibc 2.31+ x86-64 Python 3
SHA-256 checksum
How to use checksums
e6b685a16dd2b0da899de7e9b011cdaf0f3b477046a9cfbe07933b757caa37d7
BLAKE2b-256 checksum
How to use checksums
2e76992ad4d169d27046afba6d1836a9dc24b21ae388364e5d3c8abe04cbe943
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.4.1-py3-none-manylinux_2_31_aarch64.whl

Download URL cua-0.4.1-py3-none-manylinux_2_31_aarch64.whl
Size 78.3 MB
Tags Linux glibc 2.31+ ARM64 Python 3
SHA-256 checksum
How to use checksums
a7748a69723867c7d5040ac3e3594d92c5327b39e072176752ec86b42f67f91b
BLAKE2b-256 checksum
How to use checksums
bcf46bb4644482255129c62961283ad8ba8efae40eb2566476bbb93b161b30c5
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.4.1-py3-none-macosx_11_0_arm64.whl

Download URL cua-0.4.1-py3-none-macosx_11_0_arm64.whl
Size 67.0 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1287228c6586af3cb62b6bdc7300c604638300852e2b789745bb12dd3b39e5ee
BLAKE2b-256 checksum
How to use checksums
095a5fce801e07ec01d632bbb3cc7ce7254112e18da44a0dae3881113bba7d00
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.4.1-py3-none-macosx_10_12_x86_64.whl

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

Release history Release notifications | RSS feed

0.4.4

6 release files

0.4.3

6 release files

0.4.2

6 release files

This release

0.4.1 This release

6 release files

0.4.0

6 release files

0.3.1

6 release files

0.3.0

6 release files

0.2.0

6 release files

0.1.6

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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