Errors
The complete code table, the `upstream_` convention, and which failures are worth retrying.
Every failure on the OpenAI-compatible routes comes back in OpenAI's error envelope, so an SDK's own error classification keeps working against konduit:
{
"error": {
"message": "the requested model is not served by konduit",
"type": "invalid_request_error",
"param": null,
"code": "model_not_found"
}
}Four fields, always all four:
message— either a fixed string konduit owns or the message the provider sent for this request. Written to you; never written to a log.type— the class of failure, in OpenAI's vocabulary.param— alwaysnull. konduit never blames a single field, because naming one would mean quoting it, and a field name plus its value is your request's content.code— which failure it was. This is the field to branch on.
On POST /v1/messages and POST /v1/messages/count_tokens errors use
Anthropic's envelope instead, {"type":"error","error":{"type":"…","message":"…"}},
with no code or param. Branch on error.type and the HTTP status; an
upstream error body is relayed as it arrived.
The upstream_ convention
Read this before the table; it is the reason the table has the shape it has.
Every code that describes something the provider did is prefixed
upstream_. A code without that prefix is konduit deciding — usually before any provider was asked at all.
The prefix is not decoration. A 429 from a provider and a 429 from konduit's
own rate limiter are the same status and the same type, and they ask for
opposite things: one says the provider is out of capacity and the fix is to wait,
the other says your own limit was reached and the fix is a larger limit. Getting
it wrong means backing off from a queue that will never drain — or hammering a
provider that asked to be left alone.
The same distinction runs through the rest of the list. upstream_unauthorized
is a provider rejecting konduit's credential, which is konduit's problem and
not yours; invalid_api_key is yours. upstream_invalid_request means a
provider read your body and rejected it; model_not_found means nothing was ever
sent anywhere.
konduit's own codes
Nothing was asked of any provider when you see one of these.
| Status | type | code | What it means |
|---|---|---|---|
| 400 | invalid_request_error | invalid_request | The body is not one JSON object, model is missing or empty, messages is empty on a chat completion, prompt is missing, null or not one string on a legacy or fill-in-the-middle completion, or an embeddings request has neither input nor messages. On a transcription: a form konduit cannot read in exactly one way, a response_format other than json or verbose_json, or a stream other than false; see Transcriptions. |
| 400 | invalid_request_error | invalid_policy | The provider object could not be read — wrong shape, or a field konduit does not recognise. See Routing. |
| 400 | invalid_request_error | model_does_not_support_images | A message carries an image part (image_url or input_image), and no deployment of the requested model accepts images. Pick a model whose capabilities.vision is true in GET /v1/models. |
| 400 | invalid_request_error | model_does_not_support_endpoint | No deployment of the model serves this endpoint: an embedding model was sent to a completions route, a chat model to POST /v1/embeddings, a chat model to POST /v1/completions or POST /v1/fim/completions that none of its deployments serves, or a transcription model to any route but POST /v1/audio/transcriptions and any other model to that one. deployment.endpoints in GET /v1/models lists the routes of each deployment. See Embeddings, Text and code completions and Transcriptions. |
| 401 | invalid_request_error | missing_api_key | No key was presented. See Authentication. |
| 401 | invalid_request_error | invalid_api_key | A key was presented and konduit will not accept it. |
| 402 | insufficient_balance | insufficient_balance | Your organisation's available credit does not cover the reservation this request needs — which is not the same as what it would cost. See below. |
| 403 | invalid_request_error | insufficient_scope | The key is valid but does not carry the scope required by this endpoint. |
| 403 | invalid_request_error | organisation_not_active | The key is valid and so is the credential — your organisation has not been activated by konduit yet, or has been suspended. Reissuing the key changes nothing; the console says which of the two it is. |
| 404 | invalid_request_error | model_not_found | konduit's catalog knows no deployment under that name, or your API key is restricted to models that do not include it. |
| 404 | invalid_request_error | no_deployment_matches_policy | The model exists; your provider policy excluded every deployment of it. |
| 413 | invalid_request_error | request_too_large | The request body exceeded 20 MiB. Base64 adds a third to an image, so downscale large photos before sending them. |
| 429 | rate_limit_exceeded | rate_limit_exceeded | Your own per-key or per-organisation limit. See Rate limits. |
| 503 | server_error | catalog_unavailable | This gateway has never managed to load its catalog and cannot say what it serves. |
| 503 | server_error | no_provider_configured | The catalog lists the model, but this gateway has no adapter for any operator serving it. |
| 503 | server_error | ledger_unavailable | Credit could not be checked. konduit fails closed on money rather than serving on unverifiable credit. |
| 503 | server_error | gateway_busy | The request bodies in flight already fill the memory konduit gives them, or your organisation's share of it, so yours was not read. Retry after the Retry-After delay. |
`insufficient_balance` is a 402, not a 429
A quota system would answer 429 here, and a client's back-off loop would then
wait patiently for a balance that only grows when somebody pays. konduit sells
prepaid credit rather than a quota, so the status says what is actually true:
retrying will not help, a top-up will.
The type is insufficient_balance too — the one value with no exact OpenAI
counterpart. OpenAI sends insufficient_quota; the word differs because the
thing differs, but the position in the envelope and the meaning for an SDK's
classification are the same: a billing problem, not a throttle and not a
malformed request.
What it measures is a reservation, opened before any provider is asked and
sized from what the request could cost at worst: the prompt, plus the completion
ceiling, against the most expensive deployment the request might fall back to. A
request that names no max_completion_tokens is reserved as though it might
generate the deployment's whole maximum output — its context window, where the
catalog publishes no tighter figure. So a 402 does not mean the completion
would have been unaffordable; it means the worst case was. Sending
max_completion_tokens is usually the whole fix —
Reservations
has the table. An embeddings request has no completion, so its reservation is
the estimated input alone, and a 402 there means the credit did not cover
even that; see Embeddings. A transcription's
reservation is the per-request ceiling, because an upload's size does not say
how long its audio runs; see Transcriptions.
Upstream codes
A provider was reached and something went wrong there. konduit does not simply pass the provider's status through — the two cases below are why.
| Status | type | code | What it means |
|---|---|---|---|
| 4xx (relayed) | invalid_request_error | upstream_invalid_request | The provider rejected your request: an unknown parameter, a malformed tool schema, a context that is too long. The provider's own status is kept — so this is the one code that can arrive with a status the table does not name, including a 409, a 422 or a 451. |
| 429 | rate_limit_exceeded | upstream_rate_limited | The provider is out of capacity. Retry-After is always present: the provider's own value when it sent one, and konduit's floor of 1 when it did not. |
| 502 | server_error | upstream_unauthorized | The provider rejected konduit's credential. Not your key — nothing you can do about it, and konduit will not tell you your key is bad when it is ours. |
| 502 | server_error | upstream_error | The provider answered something konduit could not use: a 5xx, an unparseable body, a status that is not an answer to a completion, a body that broke off, or a stream request answered with one JSON document. |
| 502 | server_error | upstream_response_too_large | The provider answered, and the answer ran past konduit's response bound (8 MiB) — several choices with n or best_of, echo, or logprobs can make one. The provider generated and bills it, so no other deployment is asked and the response carries x-should-retry: false: retrying would buy the same answer again. Ask for less. |
| 502 or 503 | server_error | upstream_unavailable | The provider could not be reached at all (502), or said it was overloaded (503, with Retry-After when it sent one). |
| 504 | server_error | upstream_timeout | The provider did not answer in time. |
Why 401 from a provider becomes 502 from konduit
Passing it through would tell you your key is bad when it is konduit's, and would
make an SDK re-prompt a human for a credential that was never the problem. A
502 says what is true: the hop after konduit did not answer the question.
Two different `402`s — branch on `code`, not on the status
A provider that answers 402 has its status relayed as
upstream_invalid_request, so a 402 from konduit means one of two unrelated
things: your konduit credit did not cover the reservation
(type: insufficient_balance, code: insufficient_balance), or the provider
refused on its own billing grounds (type: invalid_request_error, code: upstream_invalid_request). Only the first is fixed by topping up. This is the
sharpest case of the general rule at the top of this page: code is the field to
branch on, and a client that switches on the status alone will send somebody to a
payment page over a provider's quota.
An upstream's own error message is relayed to you when it arrived in a shape konduit recognises. When it did not — a load balancer's HTML error page is the common case — konduit substitutes a message of its own rather than forwarding something that would leak the provider's topology and tell you nothing.
Which of these should you retry
| Behaviour | Codes |
|---|---|
Retry with back-off. Honour Retry-After when present. | upstream_rate_limited, rate_limit_exceeded, gateway_busy, upstream_unavailable, upstream_timeout, upstream_error |
| Retry, but the fix may be operational. These are konduit's own dependencies; a retry is right, an alert is also right. | catalog_unavailable, ledger_unavailable, no_provider_configured |
| Do not retry — change the request. | invalid_request, invalid_policy, model_not_found, no_deployment_matches_policy, model_does_not_support_images, model_does_not_support_endpoint, request_too_large, upstream_invalid_request, upstream_response_too_large |
| Do not retry — change the credential. | missing_api_key, invalid_api_key, insufficient_scope |
| Do not retry — talk to konduit. Nothing about the request or the key is wrong; the organisation behind it is not active. | organisation_not_active |
| Do not retry — pay. | insufficient_balance |
| Do not retry — nothing you can change. The credential konduit presents to the provider was refused. A second attempt meets the same refusal; if this persists it is ours to fix, and worth telling us about. | upstream_unauthorized |
konduit already tries the next eligible deployment when one fails, so a 502 or
a 504 with a retryable code means every candidate it tried failed, not merely
the first. A client-side retry is still worth having — providers recover — but
retrying instantly will not find a healthy one that konduit missed a moment ago.
The exception is an answer a provider did give: an answer past the response
bound (upstream_response_too_large), or a stream request answered with one
JSON document (upstream_error), ends the request without asking another
deployment, because that provider generated and bills it.
Degraded modes
konduit has three dependencies of its own — the model catalog, the ledger that holds your credit, and the rate limiter's shared counters. Each fails in a way that was decided deliberately, and the decision is visible to you, so here it is in one place.
| What is degraded | What you see | Why |
|---|---|---|
| The catalog cannot be refreshed. | Nothing. Requests keep being served from the last snapshot that loaded, however old it is. | A model list that is minutes stale is a better answer than no inference at all. Only a gateway that has never loaded a catalog answers catalog_unavailable, and then it genuinely cannot say what it serves. |
| The ledger cannot be reached. | 503 ledger_unavailable on every request. | konduit fails closed on money. Serving on credit it cannot verify would be the one degraded mode a customer cannot audit afterwards. |
| The limiter's shared counters are unreachable. | Nothing, or a 429 slightly sooner than your plan implies. | Each gateway falls back to counting in its own process. Your limit is then enforced per replica rather than across them, which can only ever throttle earlier, never later — availability of inference is not traded away for accounting precision. |
An error with no envelope at all
Everything on this page describes a failure konduit was still running to
report. If the process itself dies mid-request there is no envelope and no
status: the connection closes, and whatever sits in front of konduit turns that
into a 502 or a 504 of its own. On a stream, the body simply stops — with no
error frame and no [DONE]. The other case is deliberate: an embeddings
response whose provider fails mid-body is cut off, as
below.
That is why an SDK-level transport error (APIConnectionError and its kin)
deserves different handling from an APIError: the second is konduit's answer,
the first means there was none to give. Retry it like a dropped connection.
Errors on a stream
Once the first frame has been flushed there is no status left to change. A
failure after that point arrives inside the stream instead, in the same envelope,
and data: [DONE] is not written after it. See
Streaming.
Errors on embeddings
An embeddings response is one JSON document, relayed as the provider sends it,
so it has no frame to carry an error in once its 200 is out. A provider that
fails after that, before the document is complete, has your connection cut off
rather than the response finished: your client sees a transport error, never a
200 carrying truncated JSON. Not every SDK retries a failure that arrives after
the status, so retry it yourself. See
Embeddings.
What konduit logs
None of your content, ever. konduit logs request metadata — model, provider,
deployment, token counts, latency, status and the code above — and nothing
else. That includes error messages: the message field is written to you and to
nobody else, precisely because a provider's 400 often echoes part of what you
sent.