Errors
Handle request failures, interrupted streams, and access decisions.
Draft guidance. Koah's final status codes, error schemas, retry headers, and access reasons are not published. The categories below explain how to handle common HTTP failures; they do not define a live Koah error contract.
Before a response starts
Check the HTTP status before reading the success response. When a compatible gateway reports these statuses, handle them at the application's request boundary:
| Status or failure | Meaning to check | Application behavior |
|---|---|---|
400 or 422 | Invalid request or unsupported parameters. | Check the body and model capabilities before retrying. |
401 | Missing or invalid credentials. | Correct the provider key and authentication configuration. |
403 | The requested operation is not permitted. | Use the service's accurate access reason; do not infer abuse from the status alone. |
404 | The requested route or model was not found. | Check the protocol base URL, final path, and approved model ID. |
429 | A rate limit was reached. | Use confirmed retry guidance and a bounded retry policy. |
5xx | A gateway or provider failure. | Show a temporary service failure and use the agreed recovery policy. |
| Timeout or connection failure | The client did not receive a usable response. | Handle the SDK exception and preserve the user's work. |
A response body can be absent or non-JSON during infrastructure failures. Do not assume that every failed request has a parseable error object. Keep keys and private prompts out of diagnostic messages.
SDK exceptions
The Python clients expose connection errors and HTTP status errors through their own SDK classes. Their error envelopes can differ by protocol. Handle errors at your server boundary; see the complete server route.
An SDK exception describes a request failure. It does not establish an ad view, an earnings event, or an accurate policy-suspension reason.
After streaming starts
A stream can start with 200 and then fail. Detect transport exceptions, stream
error events, and missing completion markers. Keep partial output marked as
incomplete instead of presenting it as a completed answer.
See Streaming for protocol-specific completion markers. The client may need to handle failures inside its stream loop as well as when it opens the request.
Retries and limits
Choose a bounded retry policy for your application. Follow any retry guidance
returned by the service, and account for retries already handled by your SDK.
See Rate Limits for handling 429 responses.
Do not retry validation or authentication failures unchanged. For transient failures, confirm the retry budget and any server guidance first. Retrying a generation can create additional inference work or different output; do not assume an inference request is idempotent.
Access and no-fill
Keep admission, policy decisions, and operational failures distinct. Show the accurate reason supplied by the service. A rate limit, accounting shortfall, or network error must not become an invented abuse reason.
No-fill must not turn inference into a paid request or an out-of-credits message. The planned experience has no automatic paid fallback. Read Rate Limits for request limits and Ads and Validation for ad failures.