Skip to main content
Every error Kyma returns has a stable error.code, a category in error.type, error.retryable, and a request_id. The full list, with what each code means and what to do, is on Errors. This page shows how to act on them.

Branch on error.code

error.code is always a string, on every status. Read it, not error.message: the message is written for people and can change. On /v1/messages the same object sits in Anthropic’s envelope ("type": "error" on top), so Anthropic SDKs work unchanged. A 200 with an empty billed body is a bug, not a valid “no result”. Out of credits is 402, never 200.

Retry only what can succeed

error.retryable, and the x-should-retry header, say whether the same request can succeed if sent again. The official OpenAI and Anthropic SDKs read x-should-retry and retry twice by default, so they already skip a 402 or a 400. If you retry yourself: honor Retry-After, back off exponentially with jitter, and never retry a non-retryable error unchanged.

The two 402 codes

A 402 is always about money or free-tier access, never about your payload. error.type is billing_error and error.code names the rule: On the OpenAI-compatible endpoints the body is:
On /v1/messages the same fields arrive in Anthropic’s envelope: "type": "error" and request_id at the top level, and error.type is billing_error, Anthropic’s own type for a 402:
On an image or audio model, model_requires_paid names the free-tier alternatives by id:
topup_url is the billing page a person opens. topup is the endpoint an agent with a wallet can pay on its own; it is a hint in the body, never a payment challenge. required is 0 on model_requires_paid on purpose. The $0.50 signup credit spends on the free tier and nothing else, so no top-up amount makes a paid model callable on it; quoting a figure there would send you to buy exactly enough credit to be refused again.

Rate limits

Rate limits are tier-based and counted per minute: RPM and TPM on text endpoints, concurrent jobs on media. Your tier’s numbers are live at GET /v1/limits/tiers, and Rate Limits explains each one. To see your tier and this minute’s usage:
The response includes tier, rpm_limit, tpm_limit, this minute’s rpm_used / rpm_remaining and tpm_used / tpm_remaining, and the full tier table. Checking it does not use up a request.

Python error handling

Retry with a fallback model

When a model is unavailable (provider_unavailable, model_unavailable) or refuses the content (route_refused), another model may answer: