Skip to main content

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.

Cua lets you create isolated, agent-ready computers from Python with a single async with block. This quickstart walks you through installing the SDK, creating an ephemeral Linux desktop container, running a shell command inside it, and saving a screenshot — then watching the sandbox clean itself up automatically.
Prerequisites: Python 3.12 or 3.13 and Docker Desktop or Docker Engine running on your machine.

Steps

1

Install the Cua SDK

Open a terminal and install the cua meta-package from PyPI:
pip install cua
This installs cua-sandbox, cua-agent, and cua-cli together. The sandbox SDK alone (cua-sandbox) supports Python 3.11–3.13 if you need an earlier version.
2

Create the script

Create a file named quickstart.py with the following content:
quickstart.py
import asyncio
from cua import Sandbox, Image

async def main():
    # Starts an ephemeral Linux desktop container via Docker.
    # The sandbox is destroyed automatically when the block exits.
    async with Sandbox.ephemeral(
        Image.linux(kind="container"),
        local=True,
    ) as sb:
        # Run a shell command inside the sandbox
        result = await sb.shell.run("uname -a")
        print("Shell output:", result.stdout)

        # Read and write the sandbox clipboard
        await sb.clipboard.set("Hello from Cua!")
        value = await sb.clipboard.get()
        print("Clipboard:", value)

        # Take a screenshot of the sandbox desktop
        screenshot = await sb.screenshot()
        with open("screenshot.png", "wb") as f:
            f.write(screenshot)
        print("Screenshot saved to screenshot.png")

asyncio.run(main())
The Image.linux(kind="container") argument selects a lightweight Linux desktop container. The same API accepts .macos(), .windows(), or .android() when you need a different OS.
3

Run it

Execute the script from the same directory:
python quickstart.py
You should see output similar to:
Shell output: Linux sandbox-abc123 6.6.0 #1 SMP ... x86_64 GNU/Linux
Clipboard: Hello from Cua!
Screenshot saved to screenshot.png
A new file called screenshot.png will appear in your current directory showing the sandbox desktop.
4

Understand what happened

Sandbox.ephemeral(..., local=True) created a Linux desktop container through Docker. The script ran uname -a inside that container, set and read the clipboard, and captured a screenshot of the desktop. When the async with block exited, the sandbox destroyed itself — no cleanup needed.

Supported OS targets

The same Sandbox API works across operating systems, both locally and in the cloud:
TargetImage callLocal backend
Linux containerImage.linux(kind="container")Docker
Linux VMImage.linux(kind="vm")QEMU
macOS VMImage.macos()Lume (Apple Silicon)
Windows VMImage.windows()QEMU / Hyper-V
Android VMImage.android()QEMU

More sandbox operations

Once you have a sandbox, you can interact with it through mouse, keyboard, and more:
quickstart_full.py
async with Sandbox.ephemeral(Image.linux(kind="container"), local=True) as sb:
    # Shell commands
    result = await sb.shell.run("echo hello")

    # Mouse control
    await sb.mouse.click(100, 200)
    await sb.mouse.double_click(100, 200)

    # Keyboard input
    await sb.keyboard.type("Hello from Cua!")
    await sb.keyboard.press("Return")

    # Screenshots
    screenshot = await sb.screenshot()

    # Mobile gestures (Android)
    # await sb.mobile.gesture((100, 500), (100, 200))

Next steps

Drive a real app

Use Cua Driver to give an agent access to your existing desktop apps via MCP.

First Sandbox tutorial

A deeper walkthrough of the Sandbox API, including clipboard, screenshots, and lifecycle management.

How sandboxes work

Understand the isolation model, runtime backends, ephemeral vs. persistent, and image composition.

Create a macOS VM

Set up a full macOS VM on Apple Silicon using the Lume CLI.

Build docs developers (and LLMs) love