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._nativeis generated bylibs/cua/scripts/generate-uniffi-bindings.mjsand must not be edited;--checkfails CI when it drifts.- Wheels are platform wheels (
build_wheel.py), one per OS/arch, each with thelibcua_sdklibrary 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.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| cua-0.3.1-py3-none-win_arm64.whl | Python 3 | none | Windows ARM64 | Details |
| cua-0.3.1-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| cua-0.3.1-py3-none-manylinux_2_31_x86_64.whl | Python 3 | none | Linux glibc 2.31+ x86-64 | Details |
| cua-0.3.1-py3-none-manylinux_2_31_aarch64.whl | Python 3 | none | Linux glibc 2.31+ ARM64 | Details |
| cua-0.3.1-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details |
| cua-0.3.1-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details |
Total release size: 420.0 MB
Release files / cua-0.3.1-py3-none-win_arm64.whl
| Download URL | cua-0.3.1-py3-none-win_arm64.whl |
|---|---|
| Size | 60.9 MB |
| Tags | Python 3 Windows ARM64 |
|
SHA-256 checksum How to use checksums |
1d9a2403f9701e9a0bb5e8a4148ad95f78f959b0b1f12ff20ac959a2a264fcdc
|
|
BLAKE2b-256 checksum How to use checksums |
53e642cdeea58c420764d819215c3bf8a4ed2c9d03dfba3ed3bd68cb007e8184
|
| 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.3.1-py3-none-win_amd64.whl
| Download URL | cua-0.3.1-py3-none-win_amd64.whl |
|---|---|
| Size | 65.9 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
9e816675b270c3be37686e51fca508ce6c96d8374339ecb760a525bb29382d40
|
|
BLAKE2b-256 checksum How to use checksums |
bdd46b1f7e74c53733093d53ba2d05284102791995243c41e5c132ee8749e106
|
| 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.3.1-py3-none-manylinux_2_31_x86_64.whl
| Download URL | cua-0.3.1-py3-none-manylinux_2_31_x86_64.whl |
|---|---|
| Size | 76.8 MB |
| Tags | Linux glibc 2.31+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
5254427de521bee523c3b744d742daeeef194306401c0c0eb5e1b3375c464c98
|
|
BLAKE2b-256 checksum How to use checksums |
7d12be4d2965503a21ddfab02a58148ad27814ae55320c71edb1e1bc5be2f034
|
| 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.3.1-py3-none-manylinux_2_31_aarch64.whl
| Download URL | cua-0.3.1-py3-none-manylinux_2_31_aarch64.whl |
|---|---|
| Size | 78.1 MB |
| Tags | Linux glibc 2.31+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
56e1274b934f1d708cb185a88682db15fab8bb62793dcea2b77b7a5f1ed6fffb
|
|
BLAKE2b-256 checksum How to use checksums |
8ee845880c8caaf7bab6250679fd7c785bc68dd05b6f365bd135690619c2f769
|
| 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.3.1-py3-none-macosx_11_0_arm64.whl
| Download URL | cua-0.3.1-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 66.6 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a5ec295548a589fa22a90a93022ebc03c8efb677b3efb72733a33e1c49f7fd89
|
|
BLAKE2b-256 checksum How to use checksums |
b4bb6dfc8c823b866a124360167335d866f0ae98f5c46601b659fa3af5111dc4
|
| 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.3.1-py3-none-macosx_10_12_x86_64.whl
| Download URL | cua-0.3.1-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 71.6 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
712bfa04b9e93fc3666e5477ceeaf688bd82316481a45e90ef32e8fedff2c42a
|
|
BLAKE2b-256 checksum How to use checksums |
2440880d5b07bc723dba375c2e1a1115a643ac52bca77a27623c17b9146fcf1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|