Error Handling
Errors are returned as JSON with an error object containing message, type, and code.
Error response
{
"error": {
"message": "Rate limit exceeded. Please retry after a brief wait.",
"type": "rate_limit_error",
"code": 429
}
}HTTP Status Codes
| Status | Type | Description |
|---|---|---|
| 200 | Success | Request succeeded. |
| 400 | invalid_request_error | Invalid request body, missing messages, or content filtered by safety system. |
| 401 | authentication_error | Invalid or missing API key. |
| 429 | rate_limit_error | Too many requests or concurrent connections. Check the Retry-After header. |
| 502 | upstream_error | Failed to connect to upstream model provider. |
| 503 | service_unavailable | Service temporarily unavailable. Daily quota or plan limit reached. |
Retry Strategy
For 429 errors, respect the Retry-After header value (in seconds). For 503 errors, use exponential backoff starting from 5 seconds with a maximum of 60 seconds.