Crescendo Lab Docs
English
Sign up

Gateway error codes

Every error code the Gateway's /v1 endpoints return, including inference_failed, provider_overloaded and gateway_rate_limited: status, retry or not, the fix.

Last updated

Where the code is#

Each endpoint answers in its own protocol's error shape, so the official SDKs read it:

  • /v1/chat/completions and /v1/responses: {"error": {"message", "type", "param", "code"}}. The code is in error.code.
  • /v1/messages and /v1/messages/count_tokens: {"type": "error", "error": {"type", "message"}}. The code is the message, except on a 429, which carries a readable message and the code in error.code.
  • /v1/models answers in the shape of the client that asked: the Anthropic shape when the request sends anthropic-version or x-api-key, otherwise the OpenAI shape.

Every error object also carries origin, whose failure it was — gateway, provider, model, guardrail or routing_rule — and every error answer whose headers were not yet sent carries the same value in X-Agentlab-Error-Origin, so you know whom to ask. The code and status do not change. An error inside a stream that already started carries origin in its error event.

A refusal the provider itself wrote (a 400, 413 or 422 about your request's content) is passed on in the provider's own words and has no Gateway code.

Retry headers: Retry-After says how many seconds to wait. X-Should-Retry: false tells the OpenAI and Anthropic SDKs not to retry at all.

Is it the Gateway?#

Getting 5xx errors, or no answer at all? The Gateway status page checks from your browser, with no sign-in, whether our hosted Gateway is ready, and says what to do for each answer.

Catalog#

CodeStatusOriginRetryWhat to do
application_key_required401gatewayNoSend the key as Authorization: Bearer <key> (or x-api-key, except on /v1/chat/completions).
application_key_not_accepted401gatewayNoThe key is revoked, expired, mistyped or used from an address outside its allowlist. Check it on the keys list, or create a new one.
gateway_key_attempts_exceeded429gatewayAfter Retry-AfterToo many keys that are not accepted came from your address. Fix the key your tool sends, then wait.
gateway_key_model_not_allowed403gatewayNoThe key's model allowlist does not include this model. Use a listed model or auto, or change the key's allowlist.
server_application_required403gatewayNoThe request came from a browser (Origin header) or had an unexpected query string. Call the Gateway from a server, CLI or script.
inference_not_admitted403gatewayNoThis workspace cannot use the Gateway right now, or the chosen model cannot be used. Request access on the AI Gateway page.
model_not_enabled403gatewayNoThe workspace's model settings exclude this model. Use another model or auto, or ask an owner or admin to allow it.
model_not_found404, 400gatewayNoThe model is unknown, or no allowed model can serve the request on this endpoint. Use a name from GET /v1/models or auto.
video_not_found404gatewayNoNo video with this id was created with this API key. A video is read only with the key that created it.
invalid_model400gatewayNoagentlab/… names are not models, and auto: only takes cost, balanced or quality. Use auto or a name from GET /v1/models.
invalid_provider400gatewayNoprovider.only names something that is not a provider, leaves out the model you named, or lists providers with no model that can serve the request (error.param is provider.only). Fix the list; the message names the valid providers.
unsupported_parameter400gatewayNoThe request names an OpenAI field the Gateway does not accept (error.param names it). Remove that field.
prompt_reference_invalid400gatewayNoName the prompt by its id or slug in /v1/prompts/{prompt}/completions, optionally followed by @<version>.
prompt_not_found404gatewayNoThe key's workspace has no prompt, or no such version, by that name. Check the Prompts tab of the workspace the key belongs to.
prompt_variables_mismatch400gatewayNovariables must name exactly the prompt's variables. The message lists the missing ones and the ones the prompt does not use.
prompt_variables_invalid400gatewayNovariables must be an object whose values are strings.
prompt_messages_not_accepted400gatewayNoA prompt call sends variables, not messages: the prompt holds the messages.
prompt_too_large400gatewayNoThe prompt filled with these variables is larger than a request may be. Send shorter values.
invalid_inference_request400gatewayNoThe Chat Completions body uses a field or value the Gateway does not accept. See the API reference.
invalid_request400gatewayNoThe Responses body asks for stored state (previous_response_id, conversation, prompt) or a refused tool. param names the field.
request_key_invalid400gatewayNoIdempotency-Key must be sent at most once and be 8 to 128 characters.
request_key_already_used409gatewayNoThis Idempotency-Key was already used. Send a new key with a new request.
routing_header_invalid400gatewayNoX-AgentLab-Routing must be auto, auto:cost, auto:balanced or auto:quality, sent once.
invalid_metadata400gatewayNoThe tags in X-AgentLab-Metadata or the body's metadata cannot be recorded; the message says which rule they broke. Send one JSON object of at most 16 string values, keys of 1 to 64 letters, digits, _, . or -, values of 1 to 512 characters. See tags.
outcome_subject_not_found404gatewayNoNo request with this id, or no run with this trace id, in this key's workspace. Send the X-Request-Id, chatcmpl_… id or trace id exactly as the Gateway returned it. See outcomes.
outcome_window_closed409gatewayNoThe request was sent more than 31 days ago; its outcome can no longer be reported.
invalid_outcome400gatewayNoSend outcome as success or failure, and exactly one of request_id or trace_id.
json_required415gatewayNoSend Content-Type: application/json.
request_too_large413gatewayNoThe body is larger than the endpoint accepts: 1 MiB for Chat Completions, speech and image generation, 32 MiB for Messages and Responses, 26 MiB for transcriptions (an audio file of at most 25 MiB), 64 MiB for image edits and videos.
request_body_unreadable400gatewayYesThe request body ended before the length it declared, or did not arrive in time. Send the request again.
gateway_guardrail_blocked400guardrailNoA workspace guardrail found something it blocks (a card number, an API key, a listed word, …); the message names the check. Remove that content, or ask a workspace admin to change the guardrail in AI Gateway › Get started.
gateway_routing_rule_rejected403routing_ruleNo; after Retry-After for a requests-per-minute ruleA workspace routing rule refuses this request (for example, an end user over a monthly amount, or a key sending too fast); the message is the workspace's own sentence and names the rule. Ask a workspace admin, or change the rule in AI Gateway › Gateway settings › Routing rules.
inference_allowance_exceeded429gatewayNoA monthly limit, department ceiling or rolling window has no room. The message names it. Raise it, or wait for the reset. On Free it can be the plan's included requests or model spend (gateway_plan_requests, gateway_plan_spend); on Pay as you go, the credit balance (gateway_balance). Add credits under AI Gateway › Plan; the same key works right after.
gateway_rate_limited429gatewayAfter Retry-AfterThis key or workspace sent more requests or tokens per minute than its rate limit, or has as many audio, image and video requests in progress as the Gateway serves at once. Wait, or raise the limit.
provider_rate_limited429providerAfter Retry-AfterThe model provider is busy. The SDKs wait and retry on their own.
count_tokens_concurrency_exceeded429gatewayAfter Retry-AfterToo many token-count requests at once. Retry after a second.
provider_overloaded529providerYesThe model provider is overloaded. Retry shortly, or use auto or another model.
inference_failed502gateway, provider, modelYes, onceThe provider failed to answer. If it keeps failing, open the request under AI Gateway › Usage.
settlement_pending503gatewayNoThe model answered but its usage could not be recorded yet, so the answer was withheld. Don't resend: it settles on its own.
inference_unavailable503gatewayYesThe Gateway could not reach what it needed to decide. Retry shortly.
gateway_unavailable503gatewayYesThe Gateway server is starting or reloading its configuration. Retry shortly.
gateway_not_configured503gatewayNoThis server has no Gateway configured. On a self-hosted Gateway, check its deployment configuration.
transport_deadline_unavailable503gatewayYesThe server could not set up the connection's time limits. Retry.

This table is checked against the Gateway's code on every build: a code the Gateway can send without a row here fails the build.