Skip to content
Documentation · Errors & retries
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

statuscodemeaning
400invalid_requestthe body is wrong; param names the field
400unsupported_parameterthis model doesn't take that parameter; the model's page lists the ones it does
401missing_api_keyno key sent; send it as Authorization: Bearer <key>
401invalid_api_keywrong or revoked key
401key_expiredthe key is past its expiry; ask its owner for a new key, or extend it under API keys
402insufficient_balanceadd funds
402key_limit_reachedthis 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)
402sponsor_credits_exhaustedthe 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)
402spending_cap_reacheda signed-in app hit its monthly cap; raise it under Connected apps
402monthly_limit_reachedthis request would pass your account's monthly usage limit; raise it in Billing or wait for the next UTC calendar month
403insufficient_scopea signed-in app's connection was not granted this permission (for example inference); connect the app again and allow it
403oauth_policy_changedthe app connection changed or was disconnected; connect the app again
403account_frozenthe account is banned; contact support to unban it
404model_not_foundunknown or unlisted model id
410media_expired / upload_expiredthe file was deleted after 24 hours; generate or upload it again
413payload_too_largethe request body is too large
429rate_limit_exceededover the rate limit of 600 requests per minute per key; wait for Retry-After
429too_many_concurrent_requeststoo many requests are in flight on this account; retry when some finish (Retry-After)
500internal_errorour error; retry, and quote the x-request-id if it repeats
502generation_failedthe model failed to make the file; try again
503no_capacityno capacity for this model right now; wait for Retry-After
504timeoutthe 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.