Usage
Errors and retries
Error format, common codes, and retry strategy.
Errors return a JSON body with a type, code, and human-readable message.
json
{
"error": {
"type": "rate_limit_exceeded",
"message": "Too many requests. Retry after the period in the Retry-After header.",
"request_id": "req_demo_02"
}
}Common status codes
| Status | Meaning | Retry? |
|---|---|---|
| 400 | Invalid request | No — fix the request |
| 401 | Missing or invalid key | No |
| 404 | Unknown model ID | No |
| 429 | Rate limited | Yes, with backoff |
| 5xx | Upstream or server error | Yes, with backoff |
Retry strategy
- Retry only on 429 and 5xx responses.
- Use exponential backoff with jitter.
- Cap total attempts.
- Log the request ID for support.