---
title: Tutorial 8: Drive the Playground from code or an AI app · Agent Playground docs
description: Run a recipe, save a flow and check on a run over plain HTTP with curl. Then connect Claude, Cursor or another MCP app and let it build and run flows for you.
url: https://www.quietrobot.ai/docs/playground/tutorials/api-and-mcp
---

# Tutorial 8: Drive the Playground from code or an AI app

Run a recipe, save a flow and check on a run over plain HTTP with curl. Then connect Claude, Cursor or another MCP app and let it build and run flows for you.

Everything you've done in the builder, you can also do from code, or hand to an AI app. In this tutorial you'll run a recipe and one of your own flows with a few `curl` commands, then connect an AI app so you can ask it, in plain words, to build and run flows for you.

**Time:** about 15 minutes. **Plan:** Free. **You need:** a terminal with `curl` for part 1 (macOS and Linux have it, and so does Windows 10 and later). For part 2, an AI app that supports MCP, such as Claude, ChatGPT, Cursor or VS Code.

## Part 1: From code

### 1. Make an API key

In the dashboard, open **API keys** and make a new key. Copy it: it starts with `qr_live_` and is shown only once. Then, in your terminal:

```bash
export QR_API_KEY=qr_live_...
```

Treat the key like a password. Anyone with it can run flows in your organization, within your limits and rules.

### 2. Run a recipe

```bash
curl -s -X POST https://api.quietrobot.ai/api/v1/runs \
  -H "Authorization: Bearer $QR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"recipe":"fix-until-pass"}'
```

The answer is the new run, with its `id` (it starts with `run_`) and `status`. The run shows in the dashboard too, so you can watch it in the builder.

### 3. Check on it

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

Use your run's `id` in place of `run_123`. Run it every few seconds until `status` is `done`, `failed`, `stopped` (it reached a limit) or `cancelled`. The answer lists every step with its output, the loops it took and what it cost. To stop a run early, send `POST /runs/run_123/cancel`.

### 4. Run your own flow

Every flow you've saved has an id starting with `flw_`: it's in the builder's address bar. Run your `Check my website` flow from [Tutorial 1](https://www.quietrobot.ai/docs/playground/tutorials/first-flow), with tighter limits just for this run:

```bash
curl -s -X POST https://api.quietrobot.ai/api/v1/flows/flw_123/runs \
  -H "Authorization: Bearer $QR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"guards":{"maxLoops":1,"timeSec":60,"budgetUsd":0.02}}'
```

This is how you'd run a flow from another system, like the end of a deploy or a nightly job on your own server.

### 5. Save a flow from text

The flow document from [Tutorial 7](https://www.quietrobot.ai/docs/playground/tutorials/json-editor) works here too. Save your flow's JSON as `flow.json` (**Download .json** in the builder), then check it and save it as a new flow:

```bash
# Check it without saving or running it
curl -s -X POST https://api.quietrobot.ai/api/v1/flows/validate -H "Authorization: Bearer $QR_API_KEY" \
  -H "Content-Type: application/json" -d @flow.json

# Save it as a new flow
curl -s -X POST https://api.quietrobot.ai/api/v1/flows -H "Authorization: Bearer $QR_API_KEY" \
  -H "Content-Type: application/json" -d @flow.json
```

The check says what's wrong and where, whether your plan can run it, and which steps will wait for a person. The new flow opens in the builder like any other.

Every call, with every field, is on the [Flows API](https://www.quietrobot.ai/docs/playground/api) page.

## Part 2: From an AI app

The Playground works with apps that support MCP, an open standard for connecting AI apps to tools. Once connected, you can ask the app in plain words, and it builds, checks and runs flows for you.

### 1. Connect

In your AI app, add a connector (sometimes called a custom connector or MCP server) with this address, then sign in with your Quiet Robot account when it asks:

```text
https://api.quietrobot.ai/mcp
```

The [MCP server](https://www.quietrobot.ai/docs/sandboxes/mcp) page has steps for Claude, ChatGPT, Cursor, VS Code and others.

### 2. Ask

Try these, one at a time:

* "Show me the Agent Playground recipes."
* "Save **Fix until tests pass** as a flow, run it, and tell me what each step did."
* "Run my **Check my website** flow and tell me if the site is OK."
* "Build a flow that fetches https://example.com every morning, checks the page says 'Example Domain', and asks me before doing anything else. Check it, then save it."
* "Why won't my flow **Get three shipping quotes** run?"

The app uses the same flow document as the builder, so a flow it saves opens on the canvas, and you can keep editing it there.

### 3. What stays in your hands

An AI app gets no more power than you give it:

* **Limits** stop every run at its loops, time and spend, whatever the app asks for.
* **Approvals** still wait for a person in the dashboard. The app can see that a step is waiting, but it can't approve it.
* **Your plan** caps how many sandboxes run at once, and the app is told before a flow that needs more is started.
* **Your Claude key** stays in **Policies → Secrets**. The app never sees it, and neither does the sandbox.

If you only want the app to look, connect it with a [read-only key](https://www.quietrobot.ai/docs/sandboxes/authentication): it can list, read and check flows and runs, but not save or start them.

## What you learned

* A few `curl` calls run recipes and saved flows, check on runs, and save flows from JSON.
* An MCP app can build, check and run flows for you, inside your limits, rules and approvals.

## Where to go next

You've finished the tutorials. From here:

* Pick a [recipe](https://www.quietrobot.ai/docs/playground/recipes) close to your own work, and follow its guide to make it yours.
* Read [Limits and safety](https://www.quietrobot.ai/docs/playground/safety) before you point a flow at anything important.
* Keep the [Blocks](https://www.quietrobot.ai/docs/playground/blocks) page handy: it covers every block and setting.
