quiet robot
← All insights

Guide · · 14 min read

How to use Quiet Robot Sandboxes: the features, and seven recipes

Start Quiet Robot Sandboxes from Python, TypeScript, the CLI, HTTP or MCP: what every feature does, and seven recipes you can copy.

A sandbox is a private computer for an AI agent. The agent can install packages, run code, open a browser and start a web server in it, and none of that touches your laptop, your servers or anyone else's sandbox. Each Quiet Robot sandbox is its own Firecracker microVM with its own kernel, and it typically starts in 0.9 seconds.

This guide covers the whole product in one place: how to get started, the features every sandbox service needs, the controls that set ours apart, and seven recipes with code you can copy.

Get started in five minutes

Sign in at quietrobot.ai/app, open API keys, create a key and set it in your shell. The Free plan includes $5 of sandbox time every month, with no card.

export QR_API_KEY=qr_live_...

Everything below reads that variable. Pick the way in that suits you. They all talk to the same API, so the same rules and the same audit log apply whichever you use.

Python

pip install quietrobot-sandboxes
from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()  # reads QR_API_KEY

with qr.create() as sbx:  # destroyed when the block ends
    run = sbx.exec("python3 -c 'print(6 * 7)'")
    print(run["stdout"])  # 42

TypeScript

npm install @quietrobot/sandboxes
import { Sandboxes } from "@quietrobot/sandboxes";

const qr = new Sandboxes(); // reads QR_API_KEY
const sbx = await qr.create();
try {
  const run = await sbx.exec("python3 -c 'print(6 * 7)'");
  console.log(run.stdout); // 42
} finally {
  await sbx.destroy();
}

Both SDKs are version 0.2.0, on PyPI and npm, with no other dependencies.

The qr command line

The Python package also installs qr. qr run starts a sandbox, copies your folder in, runs one command, copies results back and cleans up:

pipx install quietrobot-sandboxes
qr run -- python3 -c "print(6 * 7)"
qr run --upload . -- python3 -m unittest

For longer work, keep a sandbox around: qr create prints its id, then qr exec, qr cp, qr shell (an interactive terminal), qr expose, qr pause, qr fork and qr rm work on it.

Plain HTTP

Every SDK call is one REST request, so any language works. This starts a sandbox and runs a first command in the same request:

curl -s https://api.quietrobot.ai/api/v1/sandboxes \
  -H "Authorization: Bearer $QR_API_KEY" -H "Content-Type: application/json" \
  -d '{"run": {"cmd": "python3 -c \"print(6 * 7)\""}}'

The full API is described at https://api.quietrobot.ai/api/v1/openapi.json, and in our API reference.

Claude, Claude Code and Cursor

The MCP server gives an AI assistant its own Linux computers to work in instead of yours. In Claude on the web, on Desktop or on your phone, add a custom connector with this address, then sign in to Quiet Robot:

https://api.quietrobot.ai/mcp

In Claude Code:

claude mcp add --transport http quietrobot https://api.quietrobot.ai/mcp

Cursor (~/.cursor/mcp.json) and other clients that run local servers can use the npm package instead:

{
  "mcpServers": {
    "quietrobot-sandboxes": {
      "command": "npx",
      "args": ["-y", "@quietrobot/sandboxes-mcp"],
      "env": { "QR_API_KEY": "qr_live_..." }
    }
  }
}

Then ask it to "start a sandbox, clone github.com/you/app and run the tests." Your rules, approvals and audit log apply to every command it runs. For setup in each Claude app, see Claude gets its own computers: connect Quiet Robot Sandboxes, then try the five-minute tutorial.

The everyday features

These are what any agent needs from a sandbox: run commands, move files, look at a web app, and keep a notebook going.

from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()
sbx = qr.create(timeout_sec=600)

# Files: paths are relative to /home/sandbox
sbx.files.write("site/index.html", "<h1>Hello from a sandbox</h1>")
print(sbx.files.read_text("site/index.html"))
print([f["name"] for f in sbx.files.list("site")["entries"]])

# Commands: wait for one, stream one, or leave one running
print(sbx.exec("uname -sm")["stdout"])
sbx.exec("for i in 1 2 3; do echo step $i; sleep 1; done", on_stdout=print)
server = sbx.spawn("python3 -m http.server 8000", cwd="site")  # keeps running

# A preview link for the web server
port = sbx.ports.expose(8000)  # private: only people with the link
print(port["shareUrl"])        # open it in a browser and you're in
print(sbx.ports.expose(8000, "public")["url"])  # or open to anyone

# Python that keeps its variables between calls, like a notebook
sbx.run_code("total = sum(range(101))")
print(sbx.run_code("total")["results"][0]["text"])  # 5050

sbx.destroy()
  • Commands run and wait (up to 5 minutes), stream their output as it arrives (up to an hour), or run in the background while you read their output later, write to their input or stop them.
  • Terminals: sbx.terminal() opens a real shell on a pseudo-terminal, and qr shell sbx_... drops you into one.
  • Files: read, write, list and remove, and qr cp copies whole folders both ways.
  • Preview links: every port gets an address like https://8000-sbx-....quietrobot.dev. Private links need a token or a share link; public ones are open to anyone.
  • Code: run_code keeps a Python kernel alive between calls, returns the value of the last line, and sends charts back as PNG images.
  • Root: the agent has sudo, so it can apt-get install what it needs.

Templates

A template is what a sandbox starts with. Name one in create and the sandbox starts warm, with its tools already installed. Eight official templates went live this week, alongside base (the default) and minimal:

Template What's in it
code-interpreter Python with pandas, NumPy, Matplotlib and seaborn, plus Jupyter
browser Playwright for Python and Node.js, with Chromium installed
desktop A Linux desktop with Chromium that an agent can see and click, and you can watch in your browser
coding-agent git, the GitHub CLI and build tools, with Claude Code, Codex, Gemini CLI or Aider one command away
fullstack-js Node.js, Bun and pnpm, with React, Next.js and Vite already downloaded
go and rust Current Go and stable Rust toolchains
postgres PostgreSQL 17 with pgvector, started with one command

You can also build your own template from a Dockerfile on top of any of these. The templates docs list every package.

What makes our sandboxes different

Most sandboxes stop an agent from breaking the computer it runs on. Ours also decide what the agent can reach, make it ask before risky actions, and keep a record you can hand to whoever asks what happened. These are on every plan, Free included.

Lock the internet down when you need to

A new sandbox can reach the internet, so installs and API calls just work. Lock it down to the sites you allow (the package sites a first pip install or npm install needs come ready), block domains, IP addresses or ranges, or shut the network off completely. You can change the rules while the sandbox runs, set your own default under Rules, and lock a sandbox so nothing inside it can widen them.

from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()
sbx = qr.create(egress={"mode": "allowlist", "allow": ["pypi.org", "files.pythonhosted.org"]})

print(sbx.exec("curl -sI https://example.com")["exitCode"])  # not 0: blocked, and logged
sbx.set_egress(allow=["pypi.org", "files.pythonhosted.org", "example.com"])
print(sbx.exec("curl -sI https://example.com")["exitCode"])  # 0: allowed, no restart

The rules are enforced by a firewall the sandbox's own code can't change, even with sudo, and a second one outside the VM. Start a sandbox with "lock": true and no later call can widen it.

Learn mode answers the question "what does this agent actually need to reach?" Turn it on, let the agent do its normal job, then allow exactly what it used:

learn = f"/sandboxes/{sbx.id}/egress/learn"
qr.request("POST", learn)                   # start recording
sbx.exec("pip install -q requests")         # let the agent do its normal job
seen = qr.request("GET", learn)             # every host it reached
print(seen)
qr.request("POST", learn + "/apply", {"allow": seen["allow"]})  # allow only those

The same button is on each sandbox's page in the dashboard.

Risky commands wait for a person

Commands that match your approval rules don't run until someone says yes. Every organization starts with rules for rm -rf, sudo, git push, uploads with curl or wget, and ssh or scp, and you can edit them or add your own. The person approving sees the exact command in the dashboard (a banner on every page, a live count and an optional desktop alert) or in an approval email. An API key can't approve, so an agent can't approve its own request.

from quietrobot_sandboxes import CommandDeniedError

try:
    sbx.exec(
        "rm -rf build",
        on_pending=lambda e: print("Waiting for a person:", e["approval"]["reason"]),
    )
except CommandDeniedError as e:
    print("Denied:", e)

If an approved command turns out to be a mistake, Undo on its row in the audit log puts the files back as they were just before it ran. We save a checkpoint of the home folder before every held or sudo command for exactly this.

Keys that never enter the sandbox

An agent can't leak a key it doesn't have. Save a key once with the hosts it may be sent to. The sandbox gets a stand-in, and the real key is added on the way out, only for those hosts:

qr.set_secret("DEMO_KEY", "real-value-123", hosts=["postman-echo.com"])  # once

sbx = qr.create(secrets=["DEMO_KEY"], egress={"mode": "allowlist", "allow": []})
print(sbx.exec("echo $DEMO_KEY")["stdout"])  # qrs.sbx_...: a stand-in, not the key
r = sbx.exec('curl -s $QR_GATEWAY_URL/postman-echo.com/headers -H "x-api-key: $DEMO_KEY"')
print(r["stdout"])  # the service received real-value-123

Most SDKs only need their base URL changed, for example OPENAI_BASE_URL=$QR_GATEWAY_URL/api.openai.com/v1. A prompt injection that asks the agent to print its environment gets a stand-in that's useless anywhere else.

Everything is on the record

Every command, file access, blocked connection, approval and use of a key goes into an audit log. Read it from the SDK, export it from the dashboard, or get a one-page report on what an agent did in a sandbox, as JSON or PDF. The report is written straight from the log, with no AI model in between.

Pause and resume, with memory

Pausing keeps a sandbox's files, its memory and its running programs. Paused time isn't billed, and our latest resume took 0.66 seconds.

sbx.run_code("notes = ['loaded a big dataset']")  # something only in memory
sbx.pause()                                        # paused time isn't billed
sbx.resume()
print(sbx.run_code("notes")["results"][0]["text"])  # ['loaded a big dataset']

You rarely need to resume by hand: a command or file call to a paused sandbox wakes it first.

Snapshots, fork, rewind and resize

  • Snapshot saves the home folder (code, packages, data) while the sandbox keeps running. Start new sandboxes from it with create(snapshot_id=...).
  • Fork starts up to 10 running copies of a sandbox in one call, with the same template, size and rules.
  • Rewind puts a sandbox's files back exactly as a snapshot had them.
  • Resize is a fork with a new size: sbx.fork(cpus=2, memory_mb=4096), then destroy the original.

Recipes 1 and 7 below put fork and rewind to work.

A forgotten agent won't run up a bill

sbx = qr.create(
    auto_pause_sec=300,          # pause itself after 5 quiet minutes
    timeout_sec=3600,            # and stop after an hour, whatever happens
)
qr.request("PUT", f"/sandboxes/{sbx.id}/spend-cap", {"capUsd": 2})  # never more than $2

sbx.exec("echo hello > hello.txt")
for event in sbx.audit()[:5]:
    print(event["action"], event.get("detail"))
report = qr.request("GET", f"/sandboxes/{sbx.id}/report")  # add ?format=pdf for a PDF

Every sandbox has a deadline (10 minutes unless you set one). Idle auto-pause stops paying for an agent that's waiting on a person or a model. Spend caps can be set per sandbox and per API key, with a warning at 80%. An API key may lower a cap but only a person can raise it, and a sandbox stopped by its cap keeps its files.

Two speeds today, a third coming

Pick a CPU per sandbox with cpu_class. Both are billed to the millisecond, only while the sandbox runs:

1 vCPU, 2 GB, per hour
Standard $0.045 Shared CPU. Right for most agent work.
Performance $0.070 A dedicated CPU, on Pay as you go.
Ultra Coming soon Powered by SapphireVM, our own microVM engine on bare metal, for the heaviest work.

Seven recipes

1. Try three fixes at once with fork

Set up a project once, fork it, and let several attempts run side by side. Keep the one that passes. This is the cheapest way to make an agent more reliable: instead of one try, take the best of three.

from concurrent.futures import ThreadPoolExecutor
from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()
base = qr.create(timeout_sec=900)
base.files.write("app/slug.py", "def slugify(s):\n    return s\n")
base.files.write("app/check.py", "from slug import slugify\nassert slugify('Hello  World!') == 'hello-world'\n")

# Three tries at the fix. In real use, each copy gets its own agent, prompt or model.
attempts = [
    "def slugify(s):\n    return s.lower().replace(' ', '-')\n",
    "def slugify(s):\n    return '-'.join(s.lower().split())\n",
    "import re\n\ndef slugify(s):\n    return re.sub(r'[^a-z0-9]+', '-', s.lower()).strip('-')\n",
]
copies = base.fork(count=len(attempts))["sandboxes"]
base.destroy()

def attempt(job):
    sbx, code = job
    sbx.files.write("app/slug.py", code)
    return sbx, sbx.exec("python3 check.py", cwd="app")["exitCode"] == 0

with ThreadPoolExecutor() as pool:
    results = list(pool.map(attempt, zip(copies, attempts)))

passed = [sbx for sbx, ok in results if ok]
print(f"{len(passed)} of {len(results)} passed; keeping {passed[0].id}")
for sbx, _ in results:
    if sbx is not passed[0]:
        sbx.destroy()

The fork happens after the slow part (cloning, installing), so each copy starts with everything in place. On the Free plan three sandboxes can run at once; Pay as you go allows 25.

2. A coding agent that asks before it pushes

Keep the model on your server and give it the sandbox as its hands. With our framework tools, every command the model runs is an API call, so your approval rules, network rules and audit log see each one. Here with the Vercel AI SDK (OpenAI Agents SDK, LangChain and Mastra work the same way):

npm install @quietrobot/sandboxes-ai ai @ai-sdk/anthropic zod
import { generateText, stepCountIs } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { sandboxTools } from "@quietrobot/sandboxes-ai/vercel-ai";

const { tools, session } = sandboxTools({
  create: {
    template: "coding-agent",
    egress: { mode: "allowlist", allow: ["github.com", "codeload.github.com", "registry.npmjs.org"] },
    timeoutSec: 3600,
  },
  noWaitForApproval: true, // a held command comes back as "waiting for a person"
});

try {
  const r = await generateText({
    model: anthropic("claude-sonnet-5-5"),
    tools,
    stopWhen: stepCountIs(30),
    prompt: "Clone https://github.com/you/app, run its tests, fix what fails and commit the fix.",
  });
  console.log(r.text);
} finally {
  await session.close();
}

When the model tries git push or rm -rf, the tool answers "Waiting for a person to approve this command. Don't run it again." and the agent carries on. You approve or deny from the dashboard or the email. Your model key stays on your server; the sandbox never sees it.

If you'd rather run Claude Code or Codex inside the sandbox (qr-agents install claude in the coding-agent template), the commands it runs there are its own, so approval rules don't see them. The network rules, key stand-ins, snapshots and audit log of connections still hold.

3. Computer use with the desktop template

The desktop template is a full Linux screen. Your agent looks with a screenshot and acts with the mouse and keyboard, and you can watch, or take over, in your own browser.

import shlex
from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()
desk = qr.create(template="desktop", run="qr-desktop start",
                 egress={"mode": "allowlist", "allow": ["example.com"]})
link = desk.ports.expose(6080)
print("Watch or take over:", link["shareUrl"])

def screenshot() -> bytes:
    desk.exec("qr-desktop screenshot")
    return desk.files.read("screenshot.png")

def click(x: int, y: int):
    desk.exec(f"xdotool mousemove {x} {y} click 1")

def type_text(text: str):
    desk.exec(f"xdotool type --delay 30 {shlex.quote(text)}")

def press(keys: str):
    desk.exec(f"xdotool key {keys}")

desk.exec("qr-desktop open https://example.com")
png = screenshot()  # send this to your computer-use model; run the action it picks

Those four functions are all a computer-use model needs: wire them to its tool calls and loop until it says it's done. The screen is 1280 by 800. Because each click and keystroke is a command, it's in the audit log, and the browser on the desktop can only reach the sites you allowed.

4. A code interpreter for data analysis

Give a model a spreadsheet and a notebook it can't break out of. The code-interpreter template has pandas and Matplotlib ready, and here the sandbox has no internet at all, so the data can't leave.

import base64
from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()
sbx = qr.create(template="code-interpreter", egress={"mode": "deny"})  # no internet at all

csv = "month,region,sales\nJan,East,120\nJan,West,90\nFeb,East,150\nFeb,West,110\nMar,East,170\nMar,West,95\n"
sbx.files.write("sales.csv", csv)

# Each call is one notebook cell. Your model writes these; the sandbox runs them.
sbx.run_code("import pandas as pd\ndf = pd.read_csv('sales.csv')")
cell = sbx.run_code("df.pivot_table(index='month', columns='region', values='sales', sort=False)")
print(cell["results"][0]["text"])

chart = sbx.run_code("df.groupby('month', sort=False).sales.sum().plot(kind='bar', title='Sales by month')")
png = next(r["png"] for r in chart["results"] if r.get("png"))
open("sales.png", "wb").write(base64.b64decode(png))

broken = sbx.run_code("df['profit'].sum()")  # errors come back, ready for the model to fix
print(broken["error"]["name"], broken["error"]["value"])  # KeyError 'profit'
sbx.destroy()

Variables stay alive between cells, so the model can build an analysis step by step, and a mistake comes back as an error it can read and fix rather than a crash.

5. A browser agent that stays on its sites

The browser template has Playwright and Chromium installed. Pair it with an allowlist and the agent can only browse where you said.

from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()
sbx = qr.create(template="browser", egress={"mode": "allowlist", "allow": ["example.com", "*.example.com"]})

script = """
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    page = p.chromium.launch().new_page()
    page.goto("https://example.com")
    print(page.title())
    print(page.inner_text("p"))
    page.screenshot(path="page.png")
"""
sbx.files.write("browse.py", script)
print(sbx.exec("python3 browse.py")["stdout"])
shot = sbx.files.read("page.png")

# The page links to iana.org, which isn't on the list, so the browser can't follow it.
blocked = sbx.exec("python3 -c \"import urllib.request; urllib.request.urlopen('https://www.iana.org')\"")
print(blocked["exitCode"])  # not 0, and the attempt is in the audit log
sbx.destroy()

This is the shape of a safe research or form-filling agent: a model decides what to click, the sandbox runs it, and a page that tries to send the agent somewhere else hits a wall. Want to watch it work? Use the desktop template from recipe 3 instead.

6. A preview environment for every pull request

Put each pull request online at its own address, so a reviewer can click through it before merging. This GitHub Actions job builds the app in a sandbox and comments the link on the pull request:

name: Preview
on: pull_request
jobs:
  preview:
    runs-on: ubuntu-latest
    permissions: { pull-requests: write }
    env:
      QR_API_KEY: ${{ secrets.QR_API_KEY }}
      PR: ${{ github.event.number }}
    steps:
      - uses: actions/checkout@v4
      - run: pipx install quietrobot-sandboxes
      - name: Start the preview
        run: |
          SBX=$(qr create --template fullstack-js --timeout 86400 --egress allowlist --allow registry.npmjs.org --meta pr=$PR)
          qr cp . $SBX:app
          qr exec $SBX --cwd app -- sh -c "npm ci && npm run build"
          qr exec $SBX --cwd app --background -- python3 -m http.server 3000 --directory dist
          echo "URL=$(qr expose $SBX 3000 --public)" >> $GITHUB_ENV
      - run: gh pr comment $PR --body "Preview: $URL"
        env: { GH_TOKEN: "${{ github.token }}" }

Swap the last two commands for your app's own start command if it has a server. Drop --public to keep the preview private, and share its shareUrl instead. The fullstack-js template already holds React, Next.js and Vite in its npm cache, so installs are quick. Sessions last up to 24 hours on Pay as you go (one hour on Free), and the pr tag lets a second job find and remove the sandbox when the pull request closes.

7. Rewind after a bad agent step

Agents make mistakes that tests catch only afterwards. Take a snapshot before each step, check the result, and rewind if it broke something:

from quietrobot_sandboxes import Sandboxes

qr = Sandboxes()
sbx = qr.create(timeout_sec=900)
sbx.files.write("app/config.json", '{"retries": 3}')

def checked_step(cmd: str, check: str):
    """Run one agent step. If the check fails afterwards, undo the step."""
    before = sbx.snapshot()
    sbx.exec(cmd)
    if sbx.exec(check)["exitCode"] != 0:
        sbx.rewind(snapshot_id=before["id"])
        return False
    return True

ok = checked_step(
    "echo 'retries = 3' > app/config.json",  # the agent writes the wrong format
    "python3 -c \"import json; json.load(open('app/config.json'))\"",
)
print(ok, sbx.files.read_text("app/config.json"))  # False {"retries": 3}

The agent gets a clean slate and a clear "that didn't work" to try again with, instead of building on a broken state. Pass save_current=True to rewind to keep a snapshot of the broken state too, for a person to look at later.

Start free

Sandboxes has a free tier that's live now: $5 of sandbox time every month, three sandboxes at once and no card. Pay as you go adds Performance CPUs, bigger sandboxes and 24-hour sessions, with no monthly fee. Start free, read the docs, or book a call if you want to talk through how your agents would use it.