Fix Gemini API 503 "The model is overloaded"
When the Gemini API returns 503 "The model is overloaded", tell it from a 429 quota error, then retry with backoff and move non-realtime jobs to the Batch API.
The model is overloaded. Please try again later.The response body carries code 503 and status UNAVAILABLE. In the official error table, service_unavailable (503) means the service is overloaded or down, and the suggested action is "Wait and retry with exponential backoff".
The usual mistake is to read this as a quota problem. Before raising limits or swapping keys, sort it with this table.
503 UNAVAILABLE | 429 RESOURCE_EXHAUSTED | |
|---|---|---|
| Docs meaning | Service overloaded or down | Per-minute or per-second limit hit (rate_limit_exceeded), daily quota hit (quota_exceeded) |
| Cause lives on | The server side | Your project's usage |
| Docs action | Wait, then retry with exponential backoff | Backoff for rate limits; for the daily quota, wait for the reset or request an increase |
Code that handles 429, including the daily-quota branch, is in Retry Gemini API 429 and 503 Errors with Backoff. This article stays on 503.
[1] Confirm it is not a quota problem. An official forum post says "503 errors are unrelated to your quota and indicate our services are temporarily overloaded". Checking the usage dashboard or requesting an increase will not reduce this error.
[2] Add retries. The retry guidance on the troubleshooting page:
- Use exponential backoff and add jitter.
- Retry only on transient errors such as 429, 408, or 5xx.
- Set a maximum number of retries.
- The Python SDK retries up to four times by default.
The same forum post says the SDKs support retries through a retry config, and suggests starting with a low number of retries and a short timeout. If you already use an SDK, look at that setting before writing your own loop.
[3] Do not mix 503 with errors that must not be retried. The same page says not to retry client errors such as 400, 402, or 403. Filter on the status code; wrapping every exception in a retry loop repeats a request with a bad key over and over.
[4] Move jobs that do not need a live answer to the Batch API. The forum post recommends it: "consider moving non-realtime jobs to our Batch API". Large overnight jobs then avoid colliding with busy periods. How the Batch API works and its latency are not covered here and were not confirmed.
[5] Check whether you are on the free or the paid tier. In one forum thread, a reply from an author marked as staff first asked which tier the user was on and said "requests from paid tiers are prioritized, especially during periods of high traffic". That is an explanation, not a fix; the thread offered nothing else.
[6] If it keeps happening, waiting may be the only option. Several forum threads have users saying repeated retries did not help, and others say a different model still answered (one post says 3.1 pro gave no response while 3.0 pro worked; another says switching models removed the errors). Whether switching helps differs by post and is not confirmed officially. If one model keeps failing you can try another, but the official docs have no sentence recommending a fallback model, and nothing on how long an overload lasts. Check recent threads for the same error; staff sometimes post progress there.
Check it with the HTTP status codes tool ↗ — calculated in your browser.