# Errors

Every error the consumer API returns, with its status, type and code.

Source: https://docs.noduma.dev/api/errors/

An error is JSON in OpenAI's shape, with its HTTP status:

```json
{ "error": { "message": "not enough credits for this request. ...", "type": "insufficient_quota", "code": "insufficient_credits" } }
```

Read `code`; `message` is for people and may change. In a stream that already started, the same object arrives as an event; see [Streaming](/api/streaming/).

| Status | `type` | `code` | When | What to do |
|---|---|---|---|---|
| 400 | `invalid_request_error` | `invalid_request` | A field breaks its rule (the message names it), the body is not JSON or is over 1 MiB, or `Noduma-Routing` is not a mode | Fix the request; see [Chat completions](/api/chat-completions/) |
| 401 | `invalid_request_error` | `invalid_api_key` | No key, a wrong key or a revoked key | Check `Authorization: Bearer ndm_k_...` |
| 402 | `insufficient_quota` | `insufficient_credits` | The balance does not cover even a 16-token answer | Earn credits or ask the maintainers; see [Credits](/concepts/credits/) |
| 403 | `invalid_request_error` | `routing_not_in_plan` | The routing mode is not in your plan | Use `any` or `own`; see [Routing](/concepts/routing/) |
| 403 | `invalid_request_error` | `not_a_network_member` | `network:<id>` names a network your account is not a member of, or none | Ask the maintainers who run it |
| 404 | `invalid_request_error` | `model_not_found` | The model is not on Noduma's list | Copy a name from `GET /v1/models` |
| 404 | `invalid_request_error` | `unknown_url` | The address is not part of the API | See [API overview](/api/) |
| 405 | `invalid_request_error` | `method_not_allowed` | A served address with another method | Use the method in `Allow` |
| 429 | `rate_limit_error` | `rate_limit_exceeded` | Over 60 requests a minute, over 4 at once, or over the day's answer tokens | Wait and retry; see [Limits](/api/limits/) |
| 502 | `server_error` | `node_failed` | The PC failed and no other PC could continue, or a PC sent an oversized answer (not charged) | Retry |
| 503 | `server_error` | `model_not_available` | The model is on the list but no PC serves it now (`Retry-After: 60`) | Another model, or later |
| 503 | `server_error` | `no_capacity` | No PC that may answer is free; for `own`, "None of your PCs serving this model is sharing now" | Retry; for `own`, start sharing on one of your PCs |
| 503 | `server_error` | `shutting_down` | The coordinator is restarting (`Retry-After: 10`) | Retry after the delay |
| 503 | `server_error` | `store_unavailable` | The coordinator cannot reach its database | Retry shortly |
| 504 | `server_error` | `timeout` | The request's deadline expired | A shorter answer, or retry |
| 500 | `server_error` | `internal` | Something failed inside the coordinator | Retry; if it persists, write to contact@noduma.dev |

## Retrying

Retry a `429`, `502`, `503` or `504` with a growing delay. A request refused before it reached a PC costs nothing.
