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.401 invalid_api_keyThe key is missing or not one of yours. Decisions need a model key: x402 does not pay them.402 insufficient_balanceTop up in the console, then retry. Free models answer with no balance.400 gateway_not_foundThe x-klinn-gateway header names no gateway of this account. Check the name under Gateway in the console.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.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 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.502 model_unavailableThe model did not answer, or every provider tried failed. Retry shortly, after the Retry-After when one is sent.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.
