# Errors

One shape for every error, and what to do about each.

Every error has the same shape. The message is written to be shown to a person.

402:

```json
{
  "error": {
    "code": "insufficient_credits",
    "message": "Not enough credits for this request. Add credits and try again."
  }
}
```

| Status | Codes | What to do |
|---|---|---|
| 400 | `invalid_request` | The body is malformed or the model does not accept an input. The message says what to change. |
| 401 | `unauthorized` | The API key is missing, wrong or revoked. |
| 402 | `insufficient_credits`, `key_spend_limit` | The balance, or this key's spend limit, does not cover the request. |
| 403 | `account_frozen`, `forbidden` | The account is on hold, or the endpoint is dashboard-only. |
| 404 | `unknown_model`, `not_found` | No such model, generation or route. |
| 409 | `unavailable`, `price_above_max`, `idempotency_conflict` | No provider can run the request (or none under your price cap), or the Idempotency-Key was used for a different request. |
| 413 / 415 | `too_large`, `unsupported_media_type` | The body is over 64 KB or is not JSON. |
| 429 | `rate_limited`, `too_many_in_progress`, `too_many_per_minute` | Slow down, or wait for a running job to finish. |
| 500 / 503 | `internal_error`, `generation_disabled` | Our side. Retry with the same Idempotency-Key. |

A generation that was accepted and then failed is not an HTTP error: it is a job with `status: "failed"`. See [Why a generation failed](https://opengrid.one/docs/results#failed).

Source: https://opengrid.one/docs/errors
