Each example starts with a concrete task against a live aiod daemon, exercises one sandbox capability, and checks the result. The code is runnable as written.
BASE_URL and the API key follow Quick Start. Every JSON response uses the envelope {"success": bool, "message": str, "data": ..., "hint": null|str}; validation failures answer 422 with a top-level errors list. See Error Handling.
Every example is written twice — a v2 form and a v1 form — and the API Preference switch in the sidebar picks which one you see. The v2 form calls the routes through the small Aio helper below; the v1 form uses the 1.x SDK (agent_sandbox.Sandbox in Python, SandboxClient from @agent-infra/sandbox in TypeScript), and falls back to the same helper on the /v1 route for the few calls the SDK has no method for. Wherever the helper is used, the example starts with sb = Aio(BASE_URL).
sb.post("/v2/commands", command="wc -l /tmp/x") posts a JSON body; sb.get/sb.delete take query params the same way — the first positional argument is route, so sb.post("/v2/fs/read", path="/tmp/x") works directly. Binary routes (download, screenshot) read sb.http.get(...) / fetch directly, bypassing the envelope check.
Confirm the daemon is up and read its capabilities:
A missing capability turns its own routes into 503; the daemon still starts.
| Example | Shows | Needs |
|---|---|---|
| Agent Calls the Sandbox | Write a file, run a command, execute Python, read the result | files, exec, code_interpreter |
| MCP | The same task through one JSON-RPC endpoint, and how tool errors look | exec, files, code_interpreter |
| Browser (CDP) | Playwright and Puppeteer against the sandbox's Chromium | browser |
| Browser Use | Build a page in the sandbox, then fill it, click it, and check the result | browser, files, exec |
| Interactive Terminal | A live PTY over WebSocket from a minimal client | exec with pty |
| Code Execution | A data-analysis session: CSV in, pandas, chart back as PNG | code_interpreter |
| File Operations | Scaffold a project, search and edit it, watch it, and the error contract | files |
| Computer Use | Navigate Chromium and follow a link through the accessibility tree | computer |
The four-step task on Agent Calls the Sandbox exists in three forms: the v2 routes, the 1.x SDK, and one JSON-RPC endpoint on MCP. The steps, the file names and the result 27 are the same in all three; only the transport changes, so an agent can use whichever protocol its framework already speaks.
Both SDKs target the v1 routes (Python agent-sandbox, TypeScript @agent-infra/sandbox):
Which calls work, which need a raw HTTP call, and which routes are gone: 1.x SDK compatibility. /v2 is called through the HTTP API; see the API Reference.