---
title: "Quickstart: run an agent in three API calls"
description: "Start an episode, call tools, submit for verification: run any agent against Sandworld's app twins in three HTTP calls."
source: https://sandworld.dev/docs
---

# Quickstart

Sandworld environments are deterministic twins of real app categories. An agent acts only through typed tools; when it's done, the task's verifier checks the final state and tells you exactly which checks passed. Three calls cover the whole loop.

## Your API key

The public worlds need no key: anyone can run them, rate-limited per IP. A key gives you higher limits and keeps your episodes visible only to your organization. Create one in your workspace under [API keys](https://sandworld.dev/app/keys) and send it on every request as a bearer token:

```http
Authorization: Bearer sw_live_…
```

The samples below read it from `SANDWORLD_API_KEY`. Without the variable they still run, on the public limits. See [Authentication](https://sandworld.dev/docs/api#authentication) for scopes.

## 1. Start an episode

curl:

```bash
curl -s -X POST https://sandworld.dev/api/v1/environments/quickbasket/episodes \
  -H "authorization: Bearer $SANDWORLD_API_KEY" \
  -H "content-type: application/json" \
  -d '{"task_id": "qb-01", "seed": 7, "agent_name": "my-agent"}'
```

Python:

```python
import os
import requests

API = "https://sandworld.dev/api/v1"
KEY = os.environ.get("SANDWORLD_API_KEY")
HEADERS = {"authorization": f"Bearer {KEY}"} if KEY else {}

episode = requests.post(
    f"{API}/environments/quickbasket/episodes",
    headers=HEADERS,
    json={"task_id": "qb-01", "seed": 7, "agent_name": "my-agent"},
).json()
episode_id = episode["episode_id"]
```

TypeScript:

```ts
const API = "https://sandworld.dev/api/v1";
const key = process.env.SANDWORLD_API_KEY;
const headers = { "content-type": "application/json", ...(key ? { authorization: `Bearer ${key}` } : {}) };

const episode = await fetch(`${API}/environments/quickbasket/episodes`, {
  method: "POST",
  headers,
  body: JSON.stringify({ task_id: "qb-01", seed: 7, agent_name: "my-agent" }),
}).then((r) => r.json());
const { episode_id, instruction, policy, tools } = episode;
```

The response has the `episode_id`, the user's `instruction`, the app's `policy` and the `tools` with JSON schemas. Give all three to your agent.

## 2. Call tools

curl:

```bash
curl -s -X POST https://sandworld.dev/api/v1/episodes/$EPISODE_ID/step \
  -H "authorization: Bearer $SANDWORLD_API_KEY" \
  -H "content-type: application/json" \
  -d '{"tool": "list_delivery_slots", "arguments": {}}'
```

Python:

```python
step = requests.post(
    f"{API}/episodes/{episode_id}/step",
    headers=HEADERS,
    json={"tool": "list_delivery_slots", "arguments": {}},
).json()
print(step["result"] if step["ok"] else step["error"])
```

TypeScript:

```ts
const step = await fetch(`${API}/episodes/${episode_id}/step`, {
  method: "POST",
  headers,
  body: JSON.stringify({ tool: "list_delivery_slots", arguments: {} }),
}).then((r) => r.json());
console.log(step.ok ? step.result : step.error);
```

Each step returns the tool's observation — the same information a user of the app would see. Errors come back as data, the way a real API returns them.

## 3. Submit for verification

curl:

```bash
curl -s -X POST https://sandworld.dev/api/v1/episodes/$EPISODE_ID/submit \
  -H "authorization: Bearer $SANDWORLD_API_KEY"
```

Python:

```python
verdict = requests.post(f"{API}/episodes/{episode_id}/submit", headers=HEADERS).json()
print(verdict["pass"], verdict["score"])
for check in verdict["checks"]:
    print(check["pass"], check["label"])
```

TypeScript:

```ts
const verdict = await fetch(`${API}/episodes/${episode_id}/submit`, { method: "POST", headers }).then((r) => r.json());
console.log(verdict.pass, verdict.score);
for (const check of verdict.checks) console.log(check.pass, check.label);
```

You get `pass`, a `score` and every check with detail. Use the checks as a reward signal, or open the episode in the workspace to replay it step by step.

## With the Python client

The Python client (standard library only) wraps the same three calls and adds a Gymnasium-style wrapper. It reads the same `SANDWORLD_API_KEY`:

```bash
pip install https://sandworld.dev/files/sandworld-python.tar.gz
```

```python
from sandworld import SandworldEnv

env = SandworldEnv("quickbasket", task_id="qb-10")     # SANDWORLD_API_URL, SANDWORLD_API_KEY
obs, info = env.reset(seed=1)                          # info["tools"], info["policy"]
obs, reward, terminated, truncated, info = env.step(
    {"tool": "get_order", "arguments": {"order_id": "QB-10388"}}
)
obs, reward, terminated, truncated, info = env.step({"tool": "submit"})
print(reward, info["verification"].failed_checks)
```

It also picks tasks by how often the published models solve them ([tasks by difficulty](https://sandworld.dev/docs/api#tasks-by-difficulty)), and starts episodes with a [user style](https://sandworld.dev/docs/api#user-styles) for the simulated user:

```python
from sandworld import Sandworld

sw = Sandworld()
# tasks some published models solve and others don't
for t in sw.list_tasks(pass_min=0.01, pass_max=0.99):
    print(t["environment"], t["task_id"], t["difficulty"]["any_model"]["pass_rate"])
# Bench Hard tasks one model fails
hard = sw.list_tasks(suite="hard", model="gemini-3.5-flash-lite", pass_max=0)

# a user who answers vaguely at first (default, impatient, vague or skeptical)
ep = sw.start("quickbasket", task_id="qb-16", seed=1, user_style="vague")
print(ep.user_style, ep.step("ask_user", {"message": "Which address should I send it to?"}).result)
```

`SandworldEnv(..., user_style="skeptical")` takes the style too. To run Claude on any task end to end, see [Use Claude as the agent](https://sandworld.dev/docs/api#use-claude-as-the-agent).

## Next

- [API reference](https://sandworld.dev/docs/api) — authentication, every endpoint, training signals, fault injection, the local server.
- [Evaluate any model](https://sandworld.dev/docs/benchmarks) — Claude, OpenAI, Gemini, OpenRouter or your own endpoint (vLLM, SGLang…), with failure reasons.
- [Run from CI](https://sandworld.dev/docs/ci) — Bench Hard on every release, with JUnit results, a scorecard and a score badge.
- [Computer use](https://sandworld.dev/docs/computer-use) — operate the twins through their screens and measure the GUI tax.
- [MCP server](https://sandworld.dev/docs/mcp) — connect Claude.ai, ChatGPT, Cursor or any MCP client by URL, or run it locally.
- [Lab exports](https://sandworld.dev/docs/exports) — a Docker image per world, and OpenEnv, Verifiers, Inspect and Gymnasium packages.
- [Harbor packages](https://sandworld.dev/docs/harbor) — export tasks as Harbor task directories for your own harness.
- [Open datasets](https://sandworld.dev/docs/datasets) — verified trajectories and preference pairs for SFT and DPO.
- [Environment spec](https://sandworld.dev/docs/environment-spec) — how twins, tasks, verifiers and QA probes are defined.
