# Sandbox

> The whole API, for free, with sample results.

Source: https://docs.nocamclub.com/sandbox

A key starting with `nc_test_` runs on sample results. Nothing goes to a model and no credits move, so an agent or your tests can run as often as they like.

## What's real and what's sample

| Works exactly as in live | Sample |
|---|---|
| Keys, permissions and rate limits | The result: one fixed photo (430×662), clip (672×1344, 10 s, with sound) or sentence, with the same fields a real one has |
| Every check on a request, and every refusal | The price is shown, but `charged` is `false` |
| Queue, statuses, `Prefer: wait`, polling, cancel, delete, list | A generation takes about 3 seconds |
| Idempotency | |
| Uploads: files really go to storage and are really checked | |

The sample doesn't follow your prompt or settings: the same photo comes back for a poster and for a 1:1 request. To see what a prompt really does, use a live key.

## Testing failure

Put the word `fail` in the prompt, and the generation fails with [`sandbox_failure`](https://docs.nocamclub.com/errors/sandbox_failure.md). Use it to test your error handling.

```bash
curl https://api.nocamclub.com/v1/generations \
  -H "Authorization: Bearer $NOCAM_TEST_KEY" \
  -H "Content-Type: application/json" \
  -H "Prefer: wait=20" \
  -d '{ "model": "gpt-image-2", "input": { "prompt": "please fail" } }'
```

```json
{
  "status": "failed",
  "mode": "test",
  "error": {
    "code": "sandbox_failure",
    "message": "The sandbox failed this generation because the prompt has the word fail in it. Take the word out to get a sample result.",
    "hint": "Take the word fail out of the prompt to get a sample result.",
    "retryable": false,
    "docs_url": "https://docs.nocamclub.com/errors/sandbox_failure"
  }
}
```

## Limits

30 generations a minute, 5 in progress at once. Live and test don't see each other: a test key gets [`not_found`](https://docs.nocamclub.com/errors/not_found.md) for a live generation, and the other way around.

The sandbox only sells what live does: a model that's not on sale is refused in both.
