# Errors

OpenAI-style envelope, used by chat, responses, images, audio and video:

```json
{
  "error": {
    "message": "The requested model does not exist.",
    "type": "invalid_request_error",
    "code": "MODEL_NOT_FOUND"
  }
}
```

Anthropic-style envelope for `/v1/messages`:

```json
{"type": "error", "error": {"type": "invalid_request_error", "message": "..."}}
```

| Code | HTTP | Meaning |
|---|---|---|
| `INVALID_ACCESS_KEY` | 401 | missing or unknown key |
| `TOO_MANY_FAILED_ATTEMPTS` | 429 | too many bad keys from this IP |
| `MISSING_MODEL` | 400 | no `model` in the body |
| `MODEL_NOT_FOUND` | 404 | id or alias not in the catalog |
| `MODEL_NOT_ALLOWED` | 403 | model not allowed for this key |
| `CONTEXT_TOO_LARGE` | 400 | prompt longer than the model context |
| `MAX_TOKENS_EXCEEDED` | 400 | `max_tokens` over the key limit |
| `MEDIA_BYTES_EXCEEDED` | 400 | attachment over the byte limit |
| `MEDIA_UNITS_EXCEEDED` | 400 | too many media pieces in one request |
| `VIDEO_SECONDS_EXCEEDED` | 400 | requested video too long |
| `RATE_LIMIT_REACHED` | 429 | daily requests used up |
| `RATE_LIMIT_WOULD_EXCEED` | 429 | this request would pass the daily limit |
| `PROVIDER_NOT_CONFIGURED` | 500 | provider misconfigured |
| `PROVIDER_SATURATED` | 429 | concurrency cap reached |
| `PROVIDER_QUOTA_EXHAUSTED` | 429 | upstream quota exhausted |
| `PROVIDER_TEMPORARILY_UNAVAILABLE` | 429 / 503 | upstream rate limit or transient error |
| `PROVIDER_NOT_RESPONDING` | 503 | timeout |

Upstream messages are passed through after removing credentials and internal
names, so you see the real reason instead of a generic failure.
