# Errors and limits

> Decision API status codes, error types and bodies, request limits, rate limits and when to retry.

Section: API reference. Web page: https://www.launchables.ai/docs/api/errors

Every error comes back as JSON with a message and, for most errors, a type:

```json
{ "error": "what went wrong", "type": "out_of_credit" }
```

A `422` also carries `detail`, a list naming the field at fault as a path from the body, so a program can point at it:

```json
{
  "error": "question 'eligible': noul criteria need both sides: the no (false) side is missing",
  "type": "invalid_question",
  "detail": [{ "loc": ["body", "questions", "eligible", "criteria"], "msg": "...", "type": "invalid_question" }]
}
```

## Status codes

| Status | Meaning |
|---|---|
| `400` | The body is not JSON (type `invalid_json`), a compressed body does not decompress (`bad_encoding`), or a multipart body is malformed (`bad_multipart`). |
| `400` | An image in `assets` cannot be used. Types `invalid_assets`, `unsupported_image_format`, `invalid_image`, `image_too_large`, `image_dimensions`, `too_many_images`, `unreferenced_asset` and `image_reference_truncated`; the message names the asset. |
| `401` | Missing, wrong, expired or revoked API token. |
| `402` | Type `out_of_credit`: the account has no prepaid credit left. Top up in the [console](https://console.launchables.ai/billing). Do not retry until you have. |
| `402` | Type `budget_exceeded`: the key's workspace has reached its monthly budget. Raise the budget in the console under Workspaces, or wait for the next month. Budgets reset on the 1st, UK time. |
| `403` | Type `model_not_allowed`: the key's workspace is not allowed to use that model. Change the workspace's models in the console. |
| `404` | Unknown path. |
| `411` | No `Content-Length` header. |
| `413` | Type `body_too_large`: the body is over 32 MiB, as sent or once decompressed. |
| `415` | Type `unsupported_encoding`: a `Content-Encoding` other than `gzip` or `zstd`, or more than one. The `Accept-Encoding` header lists what is accepted. |
| `422` | A question cannot be answered: no state or no questions, an unknown type, missing criteria for a choice or score, `noul` criteria that do not name both sides (or use keys other than `true`/`yes` and `false`/`no`), a label listed twice, more than 26 options, more than 16 questions in one request, or a state and question longer than the model's context window. `detail` names the field. |
| `422` | Type `invalid_image_budget`: `image_budget` is not 70, 140 or 280. |
| `422` | Type `images_not_supported`: the model asked for does not read images (only Myles-G 12B and Myles-G 31B do). Send the request without `assets`. |
| `429` | Type `rate_limited`: over your key's per-minute limit, of requests or of request bytes. Type `daily_limit_reached`: over a daily cap. The `Retry-After` header (and `retry_after` in the body) gives the seconds to wait. |
| `502` | The model behind the endpoint did not respond. Retry with backoff. |
| `503` | The model is not available right now: the endpoint is switched off for maintenance, or no healthy server for that model is answering (type `model_unavailable`), or the server is busy with other large requests (type `busy`). The `Retry-After` header says when to try again. |

## Limits

| Limit | Value |
|---|---|
| Request body | 32 MiB as sent, and 32 MiB once decompressed |
| Request bytes per key | 256 MiB a minute |
| Questions per request | 16 |
| Options or levels per question | 26 |
| Images | 8 per request and 8 shown in one question; PNG or JPEG, up to 16 MiB, 280 to 1568 pixels a side ([details](https://www.launchables.ai/docs/api/images#formats-and-limits)) |
| State read by the model | The first 20,000 characters (longer states are cut, not refused) |
| Context window | 32,768 tokens on the hosted Myles-G 12B; 16,384 on the hosted Myles-G 31B |
| Hosted key | 1,200 requests a minute by default, or the workspace's own per-key limit; no daily cap (more on request) |

## Retrying

Retry `429`, `502` and `503` with backoff (for example 1, 2, then 4 seconds), or after the `Retry-After` seconds when the answer carries them. Do not retry `400`, `401`, `411`, `413`, `415` or `422` without changing the request. Do not retry `402` or `403` at all: they persist until someone changes the account or workspace in the [console](https://www.launchables.ai/docs/console).

## Privacy

The endpoint does not store states, questions or answers. Its access log records only the method, the path, the status, the time taken and the request id.

## Request id

Every response carries an `X-Request-Id` header (`req_` and 32 hexadecimal digits). Quote it when you contact support about a call: it finds the call in our logs without anyone seeing what you sent.
