Docs / API & features
Errors & retries
Use the HTTP status and error code to decide what to fix or retry. Keep the x-request-id when investigating an API failure.
On this page
HTTP status reference
| status | code | meaning |
|---|---|---|
| 400 | invalid_request | the body is wrong; param names the field |
| 400 | unsupported_parameter | this model doesn't take that parameter; the model's page lists the ones it does |
| 401 | missing_api_key | no key sent; send it as Authorization: Bearer <key> |
| 401 | invalid_api_key | wrong or revoked key |
| 401 | key_expired | the key is past its expiry; ask its owner for a new key, or extend it under API keys |
| 402 | insufficient_balance | add funds |
| 402 | key_limit_reached | this request would take the key past its own monthly spend limit; nothing ran. The limit resets at the start of the next UTC month, or raise it under API keys (limits) |
| 402 | sponsor_credits_exhausted | the key is a sponsored key and its sponsor's balance has run out; nothing ran and you were not charged. Contact the event organiser (sponsored keys) |
| 402 | spending_cap_reached | a signed-in app hit its monthly cap; raise it under Connected apps |
| 402 | monthly_limit_reached | this request would pass your account's monthly usage limit; raise it in Billing or wait for the next UTC calendar month |
| 403 | insufficient_scope | a signed-in app's connection was not granted this permission (for example inference); connect the app again and allow it |
| 403 | oauth_policy_changed | the app connection changed or was disconnected; connect the app again |
| 403 | account_frozen | the account is banned; contact support to unban it |
| 404 | model_not_found | unknown or unlisted model id |
| 410 | media_expired / upload_expired | the file was deleted after 24 hours; generate or upload it again |
| 413 | payload_too_large | the request body is too large |
| 429 | rate_limit_exceeded | over the rate limit of 600 requests per minute per key; wait for Retry-After |
| 429 | too_many_concurrent_requests | too many requests are in flight on this account; retry when some finish (Retry-After) |
| 500 | internal_error | our error; retry, and quote the x-request-id if it repeats |
| 502 | generation_failed | the model failed to make the file; try again |
| 503 | no_capacity | no capacity for this model right now; wait for Retry-After |
| 504 | timeout | the model took too long; try again |
Error response
error body
{
"error": {
"message": "Your balance is too low for this request. Add funds to continue.",
"type": "insufficient_quota",
"code": "insufficient_balance",
"param": null
},
"request_id": "7f3c..."
}When to retry
Fix authentication, balance, model and input errors before retrying a 4xx response. For 429, wait for Retry-After. For temporary server failures, use a small retry limit and exponential backoff with jitter.
The API retries a failed text attempt once before streaming starts. After the first response byte, a stream is never switched to another attempt. Media generation is not retried automatically; a client retry is a new request and may produce a second charge.
Keep the x-request-id when contacting support. Native Messages and Gemini endpoints use their own error shapes; inspect the HTTP status as well as the body.