# Errors

> Error types, status codes and the error body.

Source: https://docs.strokes.ink/api/errors

## The error body

```json
{
  "type": "error",
  "error": {
    "type": "not_found_error",
    "message": "model: strokes-large"
  },
  "request_id": "req_7Hq2LmN9xP4sTv1KcW8bYd3R"
}
```

| Field | |
| --- | --- |
| `type` | Always `error` |
| `error.type` | One of the types below |
| `error.message` | What went wrong, for people |
| `request_id` | The request's ID, the same as the `request-id` header |

## Error types

| Status | `error.type` | When |
| --- | --- | --- |
| `400` | `invalid_request_error` | The body isn't valid JSON, a field is missing, invalid or not supported, or the model couldn't process the request |
| `401` | `authentication_error` | The API key is missing, wrong, disabled or deleted |
| `402` | `billing_error` | The organization is out of credits, or the key reached its monthly spend limit |
| `404` | `not_found_error` | The model, stroke or endpoint doesn't exist |
| `410` | `invalid_request_error` | A one-time setup token sent to `/v1/agent-key` was already used |
| `529` | `overloaded_error` | The model is busy. Retry with backoff |
| `500` | `api_error` | Something went wrong on our side. Retry the request |
| `503` | `api_error` | The API is temporarily unavailable. Retry later |

These apply to every endpoint: [`/v1/messages`](/api/messages), [`/v1/chat/completions`](/api/chat-completions), [`/v1/models`](/api/models) and [`/v1/strokes`](/api/strokes). A streamed reply that fails after it started ends with an [`error` event](/api/streaming-events#error) instead.

There is no `429`: the API has no requests-per-minute limit. See [Limits and spend](/guides/rate-limits).

## Messages you may see

| `error.message` | Fix |
| --- | --- |
| `Missing API key. Send it in the x-api-key header.` | Add the `x-api-key` header |
| `Invalid API key.` | Check the key, or create a new one |
| `This API key is disabled. Enable it on the API keys page.` | Enable the key on the console's [API keys](/console/api-keys#disable-or-delete-a-key) page, or use another |
| `Your credit balance is too low. Buy credits or turn on auto-reload on the Billing page.` | Add credits on the console's [Billing](/console/billing) page |
| `This key reached its monthly spend limit of $50.00. An owner or admin can raise it on the API keys page.` | Raise the key's [limit](/console/api-keys#spend-limits), or wait for next month |
| `The request body is not valid JSON.` | Send a JSON body with `content-type: application/json` |
| `model: Field required` | Add `model` |
| `max_tokens: Must be a positive integer` | Send a whole number of 1 or more, or leave `max_tokens` out |
| `max_tokens: 40000 > 32000, which is the maximum allowed for swim-1.0` | Lower `max_tokens` to the model's maximum |
| `messages: At least one message is required` | Send at least one message |
| `messages.0: Each message needs a role of "user" or "assistant" and content` | Give every message a `role` and `content` |
| `stream: Must be a boolean` | Send `true` or `false` |
| `thinking.type: Must be "adaptive", "enabled" or "disabled"` | Use one of those |
| `top_k: Not supported` | Leave `top_k` out (also `container`, `mcp_servers`) |
| `messages.0.content.1: Content blocks of type "document" are not supported in user messages` | Send the document's text as a `text` block |
| `tools.0.input_schema: Field required` | Give every tool an `input_schema` — see [Tools](/api/messages#tools) |
| `web_search: Must be a boolean` | Send `true` or `false` |
| `mode: Must be "business", "academic", "creative" or left out` | Send one of those modes, or omit `mode` |
| `stroke_id: Must be 1 to 200 letters, digits or . _ : -` | Use a valid `stroke_id` (same rule for the `stroke-id` header) |
| `analyze: Requires at least one sample in voice.samples` | Add at least one sample to `voice.samples`, or omit `analyze: true` |
| `output_config.effort: Must be one of low, medium, high, max` | Use one of those |
| `The model could not process this request. Check the messages, images, tools and max_tokens.` | Check the request: an image that can't be read, a malformed tool schema |
| `model: strokes-large` | Use a model from [GET /v1/models](/api/models) |
| `stroke: user-42` | No stroke with that ID exists in your organization |
| `The model is overloaded right now. Retry the request in a moment.` | Retry with backoff |

How to handle and retry errors: [Errors guide](/guides/errors).
