# How do I let an agent use a desktop?

A sandbox from the `desktop` template has a Linux desktop that an agent can see and control like a person: screenshots, mouse and keyboard. Useful for apps and web pages without an API. You can watch it live in the portal.

> **Paid plans.** Desktop & Computer Use is available on paid plans and to accounts that have topped up at least US$15 in total (or the same in EUR or CZK). Until then the API answers `403 feature_disabled`.

## Steps

1. **Create a sandbox from the `desktop` template.**
2. **Take a screenshot** to see what is on the screen.
3. **Act** – click, type, press keys.
4. **Take another screenshot** to check what happened, and repeat.

**Ask your assistant**

No code: copy this into Claude or ChatGPT with [WBX Sandbox connected](https://sandbox.wbx.cz/docs/connect.md) and change it to fit.

```
Start a WBX sandbox with the desktop template and show me a screenshot. Open a terminal with Ctrl+Alt+T, type "echo hello from the desktop" and press Enter. Then show me another screenshot.
```

Watch along: in the portal, under *Sandboxes*, click *Desktop* next to the sandbox.

**Python**

`pip install wbxsandbox`, your key in `WBXSANDBOX_API_KEY`.

```
from wbxsandbox import Sandbox

with Sandbox.create(template="desktop", timeout=900) as sb:
    sb.computer.screenshot().save("before.png")     # look first
    sb.computer.key("ctrl+alt+t")                    # open a terminal
    sb.computer.type("echo hello from the desktop\n")
    sb.computer.screenshot().save("after.png")      # check what happened
```

**TypeScript**

`npm install wbxsandbox` (Node.js 20+); save as `.mts` for top-level `await`.

```
import { writeFile } from "node:fs/promises";
import { WBX } from "wbxsandbox";

const wbx = new WBX();
const sandbox = await wbx.sandboxes.create({ template: "desktop", timeoutSeconds: 900 });
try {
  await writeFile("before.png", (await sandbox.computer.screenshot()).data);   // look first
  await sandbox.computer.key("ctrl+alt+t");                                    // open a terminal
  await sandbox.computer.type("echo hello from the desktop\n");
  await writeFile("after.png", (await sandbox.computer.screenshot()).data);    // check the result
} finally {
  await sandbox.kill();
}
```

**curl**

Just `curl` and `jq`; your key in `WBXSANDBOX_API_KEY`.

```
H="Authorization: Bearer $WBXSANDBOX_API_KEY"
SB=$(curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes -H "$H" -d '{"template": "desktop", "timeout_s": 900}' | jq -r .id)
curl -s "https://sandbox.wbx.cz/v1/sandboxes/$SB/computer/screenshot" -H "$H" -o before.png
curl -s -X POST https://sandbox.wbx.cz/v1/sandboxes/$SB/computer/actions -H "$H" -d '{"actions": [{"type": "key", "keys": "ctrl+alt+t"},
  {"type": "type", "text": "echo hello\n"}], "screenshot": false}'
curl -s "https://sandbox.wbx.cz/v1/sandboxes/$SB/computer/screenshot" -H "$H" -o after.png
curl -s -X DELETE https://sandbox.wbx.cz/v1/sandboxes/$SB -H "$H"
```

## How to tell it worked

- The second screenshot shows a terminal window with *hello from the desktop*.
- The live view in the portal shows the same screen, and you can take over.

## If it doesn't work

| What you see | What to do |
| --- | --- |
| `403 feature_disabled` | Desktop is not enabled for your account yet – see the box at the top. |
| The first screenshot is empty or black | The desktop is still starting. Wait a few seconds and take it again. |
| A click lands in the wrong place | Coordinates are in pixels of the 1280×800 screen. Take a fresh screenshot before each click. |

## What it costs

Billed like any sandbox. The recommended size, 2 vCPU and 2 GB, costs about US$0.09 (€0.08, 2 Kč) an hour while it runs. [Pricing](https://sandbox.wbx.cz/pricing).

## Next steps

- [Desktop & Computer Use](https://sandbox.wbx.cz/docs/sandboxes/desktop.md): All actions, the screen and the API.
- [An agent on a desktop](https://sandbox.wbx.cz/docs/guides/computer-use.md): A complete agent loop with a language model.
- [Live console](https://sandbox.wbx.cz/docs/sandboxes/console.md): Watch and take over in the portal.

Source: https://sandbox.wbx.cz/docs/howto/desktop
