Get 6% back at Conifer with an ernd card
SectionsErrors

Gateway

Errors and retries

Every refusal says what went wrong, in its format’s own error shape, and most cost nothing.

Conifer Gateway answers an error in the shape the SDK you use expects, with a code that says what happened. This page shows the two shapes, lists every status and code, says which errors to send again, and what to do about each.

The two shapes

The OpenAI routes answer in OpenAI’s shape:

401 on /v1/chat/completions
{
  "error": {
    "type": "authentication_error",
    "code": "invalid_api_key",
    "message": "The API key is missing or isn't valid.",
    "request_id": "req_01M8QKG70MK3272G0TP16BF898"
  }
}

/v1/messages and /v1/messages/count_tokens answer in Anthropic’s shape, and so do the routes that read, such as GET /v1/models, when the request sends anthropic-version. There the request’s id sits outside error, and an error may carry details:

401 on /v1/messages
{
  "type": "error",
  "error": {
    "type": "authentication_error",
    "code": "invalid_api_key",
    "message": "The API key is missing or isn't valid."
  },
  "request_id": "req_01M8QKG70MK3272G0TP16BF898"
}

Every error also carries the request’s id in x-conifer-request-id, and in x-request-id or request-id. Quote it when you write to support.

Every status and code

The status follows the code, and the code is the same in both shapes.

StatusCodeWhat it says
400invalid_requestWhat the request got wrong, or the provider’s own words where it refused what the request asked for.
400context_length_exceededThe provider’s words, or the gateway’s where the request is longer than any model it may go to can hold; on Messages, “prompt is too long: ” comes first.
401invalid_api_key“The API key is missing or isn’t valid.”
402insufficient_balanceWhat the request costs and what the balance holds.
403forbiddenWhy the key may not, such as “This key only reads: it can’t send requests to models.”
404model_not_found“No model is called …”, with the name sent.
404router_not_foundNo deployed router has this name, or a router on the automatic pool has fewer than two scored models to rank.
404route_not_found“No route for POST /v1/audio/speech.”
404request_not_foundNo such request in the log.
405method_not_allowed“/v1/chat/completions doesn’t take GET.”
409idempotency_conflictThe Idempotency-Key’s first request is running, or ran.
413request_too_large“The body is larger than 32 MiB.”
422idempotency_key_reusedThe Idempotency-Key was sent before with another request.
422no_eligible_modelNo model or host the request’s settings allow, naming each and why.
429rate_limitedWhich limit was met, or that what it needs is set aside for requests already running.
429spend_limit_reachedWhat the request usually costs, and what the month has left of the key’s spend limit, or of the workspace’s where one is set.
500model_failed“The model’s answer failed: ”, then the provider’s words.
500internal_errorThe gateway failed.
503no_providerEvery provider and fallback failed before the first token, or none had room.
503router_pausedThe saved router is paused.
503maintenanceThe API is paused for maintenance.
503unavailableThe server can’t take the request now; nothing was sent or charged. Send it again.

The type differs between the two shapes, by status. The gateway never answers Anthropic’s overloaded_error.

StatusOpenAI typeAnthropic type
400, 405, 409, 422invalid_request_errorinvalid_request_error
401authentication_errorauthentication_error
402invalid_request_errorbilling_error
403permission_errorpermission_error
404invalid_request_errornot_found_error
413invalid_request_errorrequest_too_large
429rate_limit_errorrate_limit_error
500, 503server_errorapi_error

Retries

The gateway retries providers by itself, as Models explains, so an error that reaches you has been tried already. Two headers say what to do next:

  • retry-after, on a 409, 429 or 503 where waiting helps: the seconds to wait before sending again.
  • x-should-retry: false, where sending again can’t help: a month’s spend limit reached (429 spend_limit_reached), an Idempotency-Key whose request ran and was not kept (409), and a model that failed twice (500 model_failed).

OpenAI’s and Anthropic’s SDKs send a 409, a 429 or a 5xx again by themselves, and they obey x-should-retry: false.

What an error costs

A refused request costs nothing, whether the gateway refused it before calling a provider or the provider refused it. A request that fails costs nothing either, except an empty answer a router moved past to another model, as Billing lists.

What to do

400

Read the message: it names the field or feature at fault, such as a tool or option the gateway doesn’t serve, and says what to send instead. A file or an image named by its id at a provider is served only on the workspace’s own key for that provider: on Conifer’s keys, send its contents (Models). On context_length_exceeded, shorten the conversation: Claude Code compacts it by itself on the Messages wire.

401

The key is missing, mistyped, expired or revoked. Check that the variable reached the process, and that the client sends it in a header the gateway reads (API keys).

402

The balance doesn’t cover the request. Add funds in the console, or lower the request’s output cap so its worst case is smaller (Billing).

403

The key may not do this: the request came from outside the key’s allowed addresses, or a saved router’s; the key only reads; or a restricted key doesn’t list the router or model. Use another key, or change this one’s access. A 403 that names a provider is about the workspace’s own key for it: the provider refused the key, or doesn’t serve the model to its account. Change the key on the Provider keys tab of API keys.

404

For model_not_found, check the id against GET /v1/models, the catalog or the console’s Models section. For router_not_found, check the router’s name, and that it is deployed. A router on the automatic pool also answers it where fewer than two of that pool’s models have a Conifer Intelligence score for the reasoning effort asked (Routing). For route_not_found, the route isn’t served.

409

The request with this Idempotency-Key is still running: wait the retry-after and send it again. With x-should-retry: false it already ran and its answer wasn’t kept; send a new request with a new key if you need one.

413

The body is over 32 MiB. Send less in one request.

422

For no_eligible_model, the message names each model and why it can’t serve: a cost cap below the worst case, a data policy no host meets, or no host at the model’s price. Loosen what it names. For idempotency_key_reused, give the new request a new key.

429

A rate_limited answer always carries retry-after: wait that long and send the request again. It has these causes:

  • The key, or the saved router, has sent as many requests as its rate limit lets in for now. retry-after says when the next one fits.
  • The key has as many requests in flight as its limit allows. retry-after is 1.
  • The workspace’s balance covers the request, but all of it is set aside for requests in flight. retry-after is 1.
  • The workspace’s requests hold as much request-body memory on the server as one workspace may. retry-after is 1.
  • The workspace has as many requests waiting for their hold on the balance as may wait. retry-after is 1.
  • The key has read as often as it may for now, on a route that reads. retry-after says when.
  • The provider rate-limited the workspace’s own key for it. retry-after is the provider’s, or 30.

A spend_limit_reached answer with x-should-retry: false means the month can’t take the request: raise the key’s spend limit, or wait for the month to end in UTC. Where the workspace has a monthly limit of its own, the message says so. One with retry-after instead means the month’s room is set aside for requests in flight: send it again when one has ended.

5xx

A 503 with retry-after passes: send the request again after it. unavailable means the server couldn’t take the request, so nothing was sent to a provider and nothing was charged. A 500 model_failed with x-should-retry: false would fail again; change the request or the model. For anything else, send the request again, and write to support with its id if it keeps failing.