Error codes: 401, 402, 403, 429 and more
What each error from the API means, and what to do about it.
El centro de ayuda está escrito en inglés y neerlandés. Estás leyendo la versión en inglés.
Every error has a message and a code you can check in your code. Every response, error or not, has an x-request-id header: send it along when you contact support.
- 400 · Bad request
- The request isn’t valid. The body isn’t JSON (
invalid_json),modelis missing (missing_model), the model doesn’t support this endpoint (unsupported_endpoint; the message says which one to use), or the model rejected a parameter (invalid_request, sometimes with status422). Fix the request; retrying won’t help. - 401 · Unauthorized
- No key (
missing_api_key), a wrong or revoked key (invalid_api_key), or an expired key (api_key_expired). SendAuthorization: Bearer nr-v1-…and check the key on app.nexrouting.com/keys. - 402 · Payment required
- Your balance is empty or too low for the prompt you sent (
insufficient_credits), or the key reached its budget (key_budget_exceeded). Top up or raise the key’s budget. - 403 · Forbidden
- The key may not use this model (
model_not_allowed): check its allowed models. Or the account is paused (account_suspended): contact support. - 404 · Not found
- The model doesn’t exist or isn’t available right now (
model_not_found); the message often suggests another one. Or the endpoint doesn’t exist (not_found): the base URL must end in/v1. - 413 · Too large
- The request body is over 32 MB, or too large for the model (
request_too_large). - 429 · Too many requests
- Your key went over its requests per minute, or the model is busy right now (
rate_limit_exceeded). Wait the number of seconds in theRetry-Afterheader and try again. See Rate limits. - 500 · Internal error
- Something went wrong on our side (
internal_error). Try again. If it keeps happening, contact support with the request ID. - 503 · Unavailable
- The model is temporarily unavailable (
model_unavailable). Try again shortly, or use another model or lane.
Only in your usage log
Two status codes only appear in your usage log: 499 means your app closed the connection before the answer was complete, and 502 means a streamed answer broke off on the way.
Error format
Errors use the OpenAI format:
{"error": {"message": "Invalid API key.", "type": "authentication_error", "param": null, "code": "invalid_api_key"}}On /v1/messages, errors use the Anthropic format, with a type and a message but no code:
{"type": "error", "error": {"type": "authentication_error", "message": "Invalid API key."}}