quiet robot

Agent Playground

Flows API

Save, check, simulate and run Agent Playground flows over plain HTTP, and write flows as JSON. The same plan limits and Policies apply as in the builder.

View as Markdown

Everything the builder does, you can do from code. A flow you draw in the builder and a flow you send as JSON are the same thing: you can draw a flow and run it from your CI, or generate one in code and open it in the builder. For the same calls from TypeScript, Python or the qr command line, see SDK and CLI. To let an AI app build and run flows, see MCP tools.

All calls use an API key. A read-only key can list and read flows and runs, and simulate. Saving, starting and stopping runs need a full key.

Run a recipe or a saved flow

The quickest way to start: run a recipe by its id, or a flow you saved in the builder (its id starts with flw_ and is in the builder's address bar).

Terminal
export QR_API_KEY=qr_live_...

# Run a recipe
curl -s -X POST https://api.quietrobot.ai/api/v1/runs -H "Authorization: Bearer $QR_API_KEY" \
  -d '{"recipe":"fix-until-pass"}'

# Run your saved flow, with tighter limits for this run
curl -s -X POST https://api.quietrobot.ai/api/v1/flows/flw_123/runs -H "Authorization: Bearer $QR_API_KEY" \
  -d '{"guards":{"maxLoops":3,"timeSec":600,"budgetUsd":0.50}}'

Both answer 201 with the run. A run that needs more sandboxes at once than your plan allows is refused with 403 plan_limit, and every command it runs goes through your Policies, as in the builder. Then check on it:

Terminal
curl -s https://api.quietrobot.ai/api/v1/runs/run_123 -H "Authorization: Bearer $QR_API_KEY"

Poll every few seconds until status is done, failed, stopped (it reached a limit) or cancelled. Stop it early with POST /runs/run_123/cancel.

Simulate first

Get the same forecast the builder shows, before you spend anything:

Terminal
curl -s -X POST https://api.quietrobot.ai/api/v1/graphs/simulate -H "Authorization: Bearer $QR_API_KEY" \
  -d '{"flow":"flw_123","guards":{"maxLoops":5,"timeSec":300,"budgetUsd":0.25}}'
JSON
{
  "forecast": {
    "costUsd": { "p50": 0.0009, "p90": 0.0014 },
    "seconds": { "p50": 38, "p90": 55 },
    "loops": { "mean": 2.8, "p90": 4 },
    "outcomes": { "done": 1800, "failed": 0, "guard": 200 },
    "guardHits": { "loops": 0.1, "time": 0, "budget": 0 },
    "worstCaseUsd": 0.0031,
    "worstCaseWhy": "the time cap (180s) on up to 1 sandbox",
    "modelCostUsd": { "p50": 0, "p90": 0 },
    "notes": []
  }
}

p50 is the typical run and p90 one run in ten. A CI job can refuse to start a run whose worstCaseUsd is over budget.

Write a flow as JSON

A flow is a list of steps (nodes) and arrows (edges):

JSON
{
  "name": "Fix until tests pass",
  "template": "base",
  "start": "get",
  "secrets": ["ANTHROPIC_API_KEY"],
  "nodes": [
    { "id": "get", "kind": "run", "label": "Get the code", "cmd": "git clone https://github.com/you/app proj" },
    { "id": "test", "kind": "run", "label": "Run tests", "cwd": "proj", "cmd": "python3 -m pytest -q" },
    { "id": "fix", "kind": "agent", "label": "Fix it",
      "goal": "Make the tests in proj pass without changing them. They said:\n{{steps.test.output}}",
      "maxTurns": 12, "maxUsd": 0.5, "done": "cd proj && python3 -m pytest -q" },
    { "id": "done", "kind": "end", "label": "Fixed" }
  ],
  "edges": [
    { "from": "get", "to": "test" },
    { "from": "test", "to": "fix", "when": "fail" },
    { "from": "fix", "to": "test" },
    { "from": "test", "to": "done", "when": "pass" }
  ],
  "rewindTo": "get"
}
  • template is the sandbox template the run starts from.
  • start is the first step. It must run something in the main sandbox.
  • secrets lists the saved secrets the run may use. AI steps need ANTHROPIC_API_KEY here.
  • rewindTo is the step whose checkpoint the sandbox goes back to if a limit stops the run.
  • An edge's when is pass (the default), fail, always (either way), or choice:<label> after an AI choice.

Step kinds

kindBlockMain fields
runRun commandcmd, cwd, files (a map of path to text, written before it runs)
codeRun codecode, lang (python, node or bash)
modelAsk AIprompt, model, key, output (text, json or decision), choices, schema, expect, out
agentAgentgoal, model, key, tools (shell, files), maxTurns, maxUsd, done
teamAgents togethermembers (2 to 6 step ids), need (all or any)
branchDecidecmd: exit 0 follows pass, anything else fail
approvalApprovalask, the question for the person
waitWaitseconds, 1 to 600
forkTry in parallellanes, 2 to 10 names
judgeKeep the bestmetric, best (min or max)
endOutput

Every step has an id and a label. Steps that run something also take sandbox (a lane name, or the main sandbox when left out), timeoutMs, checkpoint, network: "none", approve: true (ask a person first), and the forecast hints estSec and passRate. Models are claude-sonnet-5-5 (the default), claude-opus-5-5 and claude-haiku-5-5.

A flow's own rules go in policy:

JSON
"policy": {
  "network": { "mode": "allowlist", "allow": ["pypi.org", "*.github.com"], "lock": true },
  "hold": [{ "pattern": "git push|npm publish", "description": "Publishing needs a person" }]
}

mode is deny, allowlist or open. A flow that breaks a rule (an unknown step in an edge, a reference to a later step, a lane no fork makes) is refused with a message that names the step. To find every place before you save, check it first.

Check a flow before you save or run it

Send flow JSON (or a saved flow's id, or a recipe's id) to /flows/validate. It runs the same checks as Run in the builder, without saving or starting anything:

  • the flow itself: every step, arrow and reference, and the limits
  • your plan: how many sandboxes the flow runs at once, against how many your plan allows (Free runs 3 at a time)
  • your keys: AI steps need their key saved under Policies, Secrets
  • your Policies: which steps will likely wait for a person, or have no network
Terminal
curl -s -X POST https://api.quietrobot.ai/api/v1/flows/validate -H "Authorization: Bearer $QR_API_KEY" \
  -d @flow.json
JSON
{
  "valid": false,
  "problems": [
    { "message": "step test: cmd is required", "code": "invalid_flow", "step": "test", "path": "/graph/nodes/1/cmd" },
    { "message": "Needs Pay as you go: runs 4 sandboxes at once, and Free runs 3", "code": "plan_limit" }
  ],
  "sandboxes": { "atOnce": 4, "limit": 3, "plan": "free" },
  "policy": { "ship": "Waits for a person (this step asks)" },
  "steps": 6,
  "guards": { "maxLoops": 5, "timeSec": 300, "budgetUsd": 0.25 }
}

A flow that wouldn't run still answers 200, with valid: false and the problems; nothing is refused. Each problem has a code and, when it points at one, the step and a path into your JSON, so an editor or a CI job can show exactly where it is.

codeWhat to do
invalid_flowFix the step or field the message names.
plan_limitUse fewer parallel lanes, or add a card on the Billing page to run more sandboxes at once.
missing_secret, secret_hostSave the key under Policies, Secrets, with the host the message names.
model_steps_off, agent_steps_offAI or agent steps are switched off for your organization right now.

/flows/validate also takes {"flow": "flw_123"} or {"recipe": "pr-reviewer"}, and size like a run.

Flow JSON: export, edit, import

The builder's JSON view, the API, the SDKs and the MCP tools all use one document:

JSON
{
  "$schema": "https://api.quietrobot.ai/api/v1/flows/schema",
  "name": "Fix until tests pass",
  "graph": { "start": "get", "nodes": [ ... ], "edges": [ ... ], "secrets": ["ANTHROPIC_API_KEY"] },
  "guards": { "maxLoops": 5, "timeSec": 300, "budgetUsd": 0.25 },
  "layout": { "get": { "x": 80, "y": 120 } }
}
  • graph is the flow, as in Write a flow as JSON.
  • guards are its limits.
  • layout is where each block sits on the canvas. Leave it out and the builder lays the flow out for you.
  • $schema points editors at the flow's JSON Schema, so they can complete field names and flag mistakes as you type. The API ignores it.
Terminal
# Export a flow (no ids or dates, ready to keep in your repository)
curl -s https://api.quietrobot.ai/api/v1/flows/flw_123/export -H "Authorization: Bearer $QR_API_KEY" > flow.json

# Check your edits, then save them back over the flow...
curl -s -X POST https://api.quietrobot.ai/api/v1/flows/validate -H "Authorization: Bearer $QR_API_KEY" -d @flow.json
curl -s -X PUT https://api.quietrobot.ai/api/v1/flows/flw_123 -H "Authorization: Bearer $QR_API_KEY" -d @flow.json

# ...or import it as a new flow, here or in another organization
curl -s -X POST https://api.quietrobot.ai/api/v1/flows -H "Authorization: Bearer $QR_API_KEY" -d @flow.json

# The JSON Schema, for your editor (no key needed)
curl -s https://api.quietrobot.ai/api/v1/flows/schema

In VS Code and other editors that read $schema, an exported flow gets hints straight away.

In the builder

You don't need the API to work on a flow as JSON. In the builder, press JSON in the toolbar (on a tablet or phone it's under More). The panel shows the flow you're editing as this same document.

  • Edit it in place. A change that's valid shows up on the canvas a moment after you stop typing, and saves like any other change.
  • Mistakes don't break your flow. If the JSON doesn't parse, or the flow it describes couldn't be saved, nothing changes on the canvas. A note tells you the line, or what's wrong with which step.
  • Copy JSON or Download .json to keep a flow in your repository or share it.
  • Import JSON replaces the flow with one you paste or pick from a file (up to 1 MB). It asks first, and you can undo it.

The JSON editor page covers the checks under the editor and the Fields list.

Save flows

Terminal
# Save a new flow from a recipe, or from your own JSON
curl -s -X POST https://api.quietrobot.ai/api/v1/flows -H "Authorization: Bearer $QR_API_KEY" -d '{"recipe":"pr-reviewer"}'
curl -s -X POST https://api.quietrobot.ai/api/v1/flows -H "Authorization: Bearer $QR_API_KEY" \
  -d @- <<'EOF'
{ "name": "Fix my tests", "graph": { ... }, "guards": { "maxLoops": 3, "timeSec": 600, "budgetUsd": 1 } }
EOF

The flow opens in the builder like any other. A saved flow can be a draft that can't run yet: runnable is false and problem says why.

CallWhat it does
GET /recipes, GET /recipes/{id}The recipes, with their category, default limits (guards), flow, and needsKey
GET /flows, POST /flowsList your flows, save a new one
POST /flows/validateCheck flow JSON, a saved flow or a recipe without running it: problems, sandboxes at once against your plan, steps your Policies will hold
GET /flows/{id}/exportThe flow JSON, without ids or dates
GET /flows/{id}/triggers, POST /flows/{id}/triggersList a flow's triggers, add one. See Triggers
PATCH, DELETE /flows/{id}/triggers/{triggerId}Turn a trigger on or off, change it, delete it
POST /hooks/flows/{triggerId}Start a flow from a webhook (its token in X-QR-Token) or GitHub. No API key
GET /flows/schemaThe flow JSON's JSON Schema, for editors. No key needed.
GET, PUT, DELETE /flows/{id}Read, change (fields you leave out keep their value) or delete a flow. Deleting keeps its runs.
GET /flows/{id}/versions, POST /flows/{id}/versionsList versions, newest first; save one with an optional note
GET /flows/{id}/versions/{n}One version, with its flow
POST /flows/{id}/restore{"version": n} restores a version
GET /flows/{id}/runs, POST /flows/{id}/runsList a flow's runs, start one
POST /graphs/simulateForecast a graph, recipe or flow
POST /runsStart a run of a graph, recipe or flow, with optional guards, size and metadata
GET /runs, GET /runs/{id}Recent runs; one run with its steps
POST /runs/{id}/cancelStop a run

size picks the sandbox size for the run, like {"cpuClass": "standard", "cpus": 2, "memoryMb": 4096}. The default is your plan's default size. metadata is up to 16 strings of your own, kept with the run.

The run object

JSON
{
  "id": "run_...", "name": "Fix until tests pass", "recipe": "fix-until-pass",
  "status": "done", "guards": { "maxLoops": 5, "timeSec": 180, "budgetUsd": 0.05 },
  "loops": 3, "costUsd": 0.0011, "modelCostUsd": 0, "elapsedSec": 41.2,
  "flowId": null, "flowVersion": null, "stopReason": null, "error": null,
  "steps": [
    { "seq": 1, "node": "setup", "label": "Set up project", "status": "ok",
      "message": "Project ready, 4 attempts prepared", "output": "...",
      "costUsd": 0.0001, "durationMs": 1830, "snapshotId": "snp_..." }
  ]
}

A step's status is running, waiting (for a person), ok, fail, stopped or skipped. An agent step also has agent, its turn-by-turn replay: each turn's text, tool calls with exit codes and output, tokens and cost, and the final check.

From code and the command line

The TypeScript and Python SDKs and the qr command line make these calls for you: see SDK and CLI.

Track your own loops

Already have an agent loop in your own code, or in LangGraph? You can still see it in the Playground's run view and use its limits. Start a run with "mode": "external" and a flow that only names the steps, then report each step as your code runs it:

Terminal
curl -s -X POST https://api.quietrobot.ai/api/v1/runs/run_123/steps -H "Authorization: Bearer $QR_API_KEY" \
  -d '{"node":"test","status":"fail","sandboxId":"sbx_...","message":"2 tests failed"}'

The answer says "stop": true once a limit is reached, and your code should stop there. Reported runs show in Recent runs marked "reported".

  • Agent PlaygroundQuickstart: build and run your first flow
  • Agent PlaygroundBlocks
  • Agent PlaygroundRecipes
  • SandboxesQuickstart: your first sandbox
  • SandboxesMCP server
  • SandboxesAPI reference