Errors

Errors use the OpenAI shape. On a chat request, a provider that fails before the first byte is retried on the next one, so a 5xx is rare.

Codes

  • 400 invalid_request_errorThe body is not valid JSON, or a field is missing or has a value the API does not take. A decisions call needs state (the text) and at least one question.
  • 400 context_length_exceededThe prompt is too long for the model. Free chat models take prompts of up to 32k tokens: shorten it, or use a paid model. A decisions model takes text and questions up to its contextLength in the catalog.
  • 400 content_filterThe model's provider blocked the request or its answer under its content policy. Change the content, or use another model.
  • 400 invalid_imageThe model could not use an image or file in the request, for example a link it could not fetch. Send the image in the request itself, or check the link.
  • 400 invalid_valueA value is outside what the model takes, for example max_tokens above the most it can write. The message names it.
  • 400 unknown_providerThe request's provider.only or provider.order names a provider that does not serve this model. error.details.providers lists the names it takes. Nothing is held or billed. A name in provider.ignore that does not serve the model is skipped.
  • 400 chosen_provider_unavailableImages, video and voice: the providers the request chose (provider.only, or provider.order with allow_fallbacks false) do not make this model with these settings. error.details.providers names the ones that do. Nothing is held or billed. Choose one of them, or let any provider serve.
  • 401 invalid_api_keyThe key is missing or not one of yours. Decisions need a model key: x402 does not pay them.
  • 402 insufficient_balanceYour balance, or a spending limit on the key, the account or the customer, does not cover this request (the message names the limit and when it resets). The message says how much it may need, how much is available and the max_tokens that fits: lower max_tokens or top up in the console, then retry. A request that sets no max_tokens is not refused because its longest possible answer does not fit your balance: it is sent with the output your balance covers (a spending limit does not do this: set max_tokens), and the answer says so in the x-max-tokens-applied header. With room for fewer than 1,024 output tokens it is refused. A request reserves at most half of your free balance while it runs, so calls sent at once each find room. Free models answer with no balance.
  • 402 top_up_requiredImages, video and voice need a top-up first: add credits by card, crypto or an x402 wallet top-up, then retry. The free welcome credit and referral credit do not count. Nothing was charged.
  • 402 paid_balance_requiredUncensored models, prompts over 200,000 tokens, files sent by link or id, and requests over about 800 KB in all need a paid balance: an account that has never made a top-up cannot send them. The size limit follows the prompt limit, at about 4 bytes a token. The free welcome credit and referral credit do not count. The message says which it is. Images are not counted in a request's size; files, audio and video are. Top up in the console, then retry, or send a shorter prompt, a smaller request, or the text itself in place of a link. It is checked before the model runs: nothing is held or billed.
  • 400 gateway_not_foundThe x-klinn-gateway header names no gateway of this account. Check the name in the console under API keys › Guardrails, advanced gateway settings.
  • 403 gateway_lockedThe x-klinn-gateway header names another gateway than the one the key is locked to: its own gateway, or the account's default gateway when that has guardrails. Leave the header off, or name that gateway.
  • 403 model_not_allowedThe key, or the gateway the request runs through, is limited to other models. Use a model they allow.
  • 404 model_not_foundThat id is not listed, or the model is called at the wrong endpoint: a chat model answers /v1/chat/completions, a decisions model the endpoint in its catalog entry.
  • 413 invalid_request_errorA decisions request body is over 256 KB.
  • 422 no_offer_under_limitThe request's max_price (or the one on its gateway or key) is under the price of every route for at least one leg, or no provider is as far under the model's list price as its min_discount asks. The message gives the market price, or the best discount available right now. It is checked before the model runs: nothing is held or billed. Raise the limit, lower the discount, or retry later.
  • 422 no_provider_supports_parametersThe request sends provider.require_parameters true, and no provider it may use supports every parameter it sets (top_k, min_p, repetition_penalty and the like). error.details.parameters lists the parameters that count, and error.details.providers says, per provider, which ones it lacks. Nothing is held or billed, and the same request gets the same answer again. Remove those parameters, or send require_parameters false to be served by a provider that may ignore them.
  • 429 rate_limitedWait the Retry-After, then retry. Free chat models allow 10 requests a minute per key, and a gateway can set its own limit.
  • 429 balance_in_useRequests arrived at once on a small balance, and the ones still running reserve most of what is free. Retry after the Retry-After (one second): the reserve of a request is free again when it ends. Or send fewer at once, set max_tokens, or top up. Nothing is reserved or billed for this answer. A single request the balance does not cover gets 402 insufficient_balance instead.
  • 429 free_tier_exhaustedFree chat models: the key's 200 requests for the day are used, or free use is paused for the day. Retry after the Retry-After, or use a paid model.
  • 446 guardrail_blockedA guardrail of the gateway blocked the message; error.code names the check (prompt_injection, pii or topics). It was not sent to the model and not billed. Do not retry the same message.
  • 502 model_unavailableThe model did not answer, or every provider tried failed. Retry shortly, after the Retry-After when one is sent.
  • 503 no_capacity_under_limitThe request's max_price or min_discount (or the one on its gateway or key) admits a provider, but none within it can answer right now. The message and error.details give the next price (market_price), and for a min_discount how far under the list price that provider is (best_discount): send a max_price at or above that price, or a min_discount at or under that figure, to be served now, or retry after the Retry-After. Nothing is billed.
  • 503 chosen_provider_unavailableChat: none of the providers the request chose (provider.only, or provider.order with allow_fallbacks false) can answer right now. Nothing is billed. Retry after the Retry-After, or let other providers serve it.
  • 503 no_route_meets_speedThe request set provider.min_throughput or provider.max_latency with allow_fallbacks false, and no route is measured to meet it right now. Nothing is billed. Lower the bar, retry, or allow fallbacks to be served by the fastest route.
  • 503 no_offer_within_capNo longer sent: there is no fall-over cap. With no max_price, the cheapest working provider serves you at its price (shown in x-price-per-million and usage.cost). A request is refused for its price only when it sets a max_price or a min_discount and no provider can serve it within that: 422 no_offer_under_limit.
  • 503 model_unavailableThe model is temporarily unavailable. Retry shortly, after the Retry-After when one is sent.
  • 503 service_unavailableThe key or the price could not be checked just now. Retry shortly, after the Retry-After when one is sent.

On a chat request, a failed provider is retried on the next healthy one before the first byte. You see 502 or 503 model_unavailable only when none of them can take the request.

When the usual providers are down

When no provider can answer at the model's price, the cheapest one that can answer does, so the request is still served. There is no cap: without a max_price, it is served however far that provider's price is above the model's. It is billed at that provider's own price, with nothing added, at most the model's public list price (or the provider's own price where that is higher). x-price-per-million and usage.cost always say what it was billed. When that is above the model's listed price at that moment, the answer also carries x-price-basis: fallover and Logs marks it "Fall-over".

To refuse anything above a limit, send a max_price (or set one on the key or its gateway). The request then falls over only to providers within it; when none can serve it there, the answer is 422 no_offer_under_limit before the model runs, and nothing is held or billed.

A limit in dollars fits one model. To set one limit for every model, send a min_discount (or set minDiscount on the key): only providers at least that many percent under the model's list price serve the request, and the answer is the same 422 when none can. See Minimum discount.

To be served only at the model's price, send "provider": { "allow_price_fallover": false }: with no provider at that price, the answer is 503 model_unavailable with a Retry-After, and nothing is billed.

To turn it off for every request of a key, switch off "Fall back to a pricier provider" in the console (API keys, the key's Routing) or send PATCH /keys/{id} { "priceFallover": false } to the Management API (null returns it to the default, on). The router picks up the change within a minute. A request's own allow_price_fallover still comes first, and a price limit (the request's, its gateway's or the key's own default) still allows dearer providers up to that limit. Calls covered by an Instance never fall over.