# Gemini 503 "model is overloaded": retry or fail over?

URL: https://infro.io/blog/gemini-503-model-is-overloaded-retry-or-fail-over
Author: INFRO Editorial (https://infro.io/blog/editorial)
Publisher: INFRO
Published: 2026-11-26
Last modified: 2026-11-26
Last reviewed: 2026-11-26 (next review due 2027-05-25)
Topic: Routing and reliability
Format: Guide

> A Gemini 503 UNAVAILABLE ("the model is overloaded") is the provider's capacity, not your quota, so retry briefly (one or two jittered attempts inside your user's deadline) and then move to a second connection or model. [^infro-blog-routing-rules] A gateway route can do the moving before the response starts, but it does not prevent the overload. [^infro-fallbacks]

Key takeaways:
- A 503 UNAVAILABLE says the model is short of capacity right now; a 429 RESOURCE_EXHAUSTED says your own limit was reached, and they need different responses.
- Retry a 503 at most once or twice, with full jitter, and cap the total by your user's deadline rather than by a retry count alone.
- Retrying the same host during a capacity event mostly adds latency, because every client is retrying into the same shortage.
- Write the 503 response as a failure rule: a short retry, then the next connection, then an alternate model, then a clear error.
- Read the request trace afterwards: the attempts and the connection that served the request tell you whether failover worked, and what the fallback cost in latency.

## Read the status before you read the message

The error you are searching for looks like this: an HTTP 503, status `UNAVAILABLE`, and a message along the lines of "The model is overloaded. Please try again later." People also meet it phrased as a high-demand error. Whatever the wording, the useful part is the status code, because it tells you whose limit was hit.

A 503 is the server saying it cannot take the request right now. Nothing in your request was wrong, and nothing in your account is exhausted. That is the angle of this guide: the 503 is Google's capacity, not your quota, so the fixes you reach for with a 429 (a higher tier, more keys, slower clients) do not apply.

> **Note: Source caveat**
> Google's own Gemini troubleshooting page returned no readable text when this guide was prepared, so this guide does not quote Google's wording or any Google-published timings. Check that page for the exact messages and any recommended actions on the day you read this. The reasoning below is general engineering practice, tied to INFRO's documented behaviour where it describes INFRO.

Two questions decide everything that follows. Will waiting help, and will a different destination help? For a 503 the honest answers are "a little, briefly" and "usually yes". For a 429 they are different, which is the next section.

## 503 UNAVAILABLE vs 429 RESOURCE_EXHAUSTED

Both are retryable in the HTTP sense, and both can show up in the same dashboard on the same afternoon. They are not the same failure, and treating them the same is the most common mistake in client code.

|  | 503 UNAVAILABLE | 429 RESOURCE_EXHAUSTED |
| --- | --- | --- |
| What it says | The model cannot take the request right now | A limit on your project or key was reached |
| Whose limit | The provider's capacity | Yours (rate or quota) |
| Does your traffic cause it? | No | Often yes |
| Same destination again | Once or twice, briefly; may fail again | Not before the window resets |
| Another key, same provider | Usually the same shortage | Can help: separate windows |
| Another connection or model | Yes, this is the main fix | Yes, if the other account has headroom |
| Counts against connection health | Yes: the host is genuinely unwell | No: a busy account is not a sick one |

Table: Two Gemini errors, two different responses

INFRO's routing-rules article makes the same split for providers in general: a 429 is about one key or account, and another key or account has its own window, while a 5xx or overloaded response means the provider is unwell, so retrying the same target is worth it "once, if the incident looks brief" and another target is the real answer. [1] INFRO's failover documentation adds that a provider 429 does not count against a connection's health, which is the right treatment for a busy-but-healthy account. [2]

If you are seeing 429s rather than 503s on Google's platform, the causes and fixes differ again; see [Vertex AI 429 resource exhausted: two causes, two fixes](https://infro.io/blog/vertex-ai-429-resource-exhausted-two-causes-two-fixes). The rest of this guide is about the 503.

## Why retrying the same host mostly adds latency

When a model is short of capacity, the shortage is shared. Every client that received a 503 is about to retry, and most of them use the same SDK defaults. The result is a crowd arriving at the same endpoint, in waves, asking for the thing that is scarce.

For your request, that has three consequences:

- **The odds of a quick recovery are unknown to you.** An overload can clear in a second or last a long time. Your client sees one rejected request and has no view of the provider's queue.
- **Each retry costs your user the full round trip.** A rejected request still takes time to come back, plus your backoff delay. Three sequential retries on one host can spend the whole patience budget of an interactive screen and still end in an error.
- **Retries add load to the thing that is overloaded.** This is why retry budgets exist: layered retries multiply traffic exactly when the target is weakest. INFRO's routing-rules article warns about this amplification for retries across layers. [1]

None of this means "never retry". A single quick retry is cheap and often succeeds, because overload is frequently bursty. The point is that retries on the same host have a low ceiling: they can only help if the shortage ends inside your deadline. A different destination does not depend on that.

An additional key on the same host rarely changes the picture. Keys give you separate rate-limit windows, which matters for a 429. They do not give you separate model capacity. INFRO's alternate-hosts capability, which lets one connection list more API hosts for the same key, is for the case where the first host cannot be reached at all. A 503 comes from a host that is reachable and answering, so the hosts-list is not the lever here; a second connection or a different model is.

## Bounded retries with jitter

A bounded retry has three limits: a number of attempts, a delay between them, and a deadline for the whole thing. The deadline matters most, because the user's patience is the real budget.

Use full jitter: pick each delay at random between zero and an exponentially growing cap. This spreads your clients out instead of having them retry in lockstep.

```python
import random
import time

RETRYABLE = {503}          # capacity: short, bounded retry
NEVER_RETRY = {400, 401, 403, 404}

def call_with_budget(send, deadline_s=8.0, max_attempts=3,
                     base_s=0.4, cap_s=2.0):
    """send() returns (status, body). Retries 503 only, within a deadline."""
    start = time.monotonic()
    for attempt in range(1, max_attempts + 1):
        status, body = send()
        if status < 400:
            return body
        if status not in RETRYABLE or attempt == max_attempts:
            raise RuntimeError(f"gemini error {status}")
        delay = random.uniform(0, min(cap_s, base_s * 2 ** (attempt - 1)))
        if time.monotonic() - start + delay >= deadline_s:
            raise RuntimeError("deadline reached while retrying 503")
        time.sleep(delay)
```

Two details are easy to miss. First, a 429 is deliberately not in the retry set: it needs to wait for its window, honour any `Retry-After` header if the response carries one, or go to another account. Second, the deadline check happens before sleeping, so a retry that cannot finish in time is never started.

> **Example: Illustrative retry budget**
> These numbers are illustrative, not measured or recommended by any provider. A chat screen gives up on a reply after about 8 seconds. Allow one attempt plus at most two retries, with jittered delays capped at 2 seconds. If the second retry also returns 503, you have used a few seconds on a host that is still short of capacity. That is the moment to hand the request to something else, not to try a fourth time.

If your calls already pass through a gateway that fails over, do not stack a client retry loop on top of it. Retries at two layers multiply. Let the gateway own the move to another destination and keep the client's own retry to the single case where there is nothing else to move to.

## Failure rules on a route

Writing this down as configuration rather than a loop in application code means it can be reviewed and changed during an incident without a deploy. INFRO's routes are a stable model name your application calls, backed by your own provider connections with ordered or weighted targets, if-rules and failure rules. [3] Failure rules decide, per failure kind, whether to retry, move on or stop.

A sensible rule set for a user-facing Gemini route reads like this:

| Failure | Rule |
| --- | --- |
| 503 UNAVAILABLE | Retry the same target once after a short jittered delay, then move to the next target |
| 429 RESOURCE_EXHAUSTED | Do not retry the same target; move to the next target or another key |
| Connection failure | Try the next host for the same connection, then the next target |
| 401 / 403 | Stop on that credential, move to another, and alert a person |
| 400 / 422 | Stop; the request itself is the problem |

This is a policy table to design against, not INFRO's configuration syntax; the schema is in the [routes documentation](https://infro.io/docs/routes). The shape follows INFRO's own guidance: classify every failure before acting, treat a rate limit as separate from ill health, and stop on a rejected request because the next target will usually reject it too. [1]

Two refinements pay off for Gemini traffic. An if-rule can send latency-sensitive requests to a route with a short per-attempt budget, and send batch work to one with a generous one, because rules can match on metadata, feature, streaming, prompt size and time of day. [3] And a weighted route can keep a small share of traffic on a second connection continuously, so that connection is already warm, tested and known to work on the day you need it.

## A second connection: Vertex AI, or another model

There are two kinds of second destination, and they fail differently.

**Same model, another connection.** If you hold a second connection that serves the same Gemini model, for example a Google Cloud account alongside your Gemini API key, INFRO's connection failover tries it when the first fails before the first token. The documentation says this is same-model, happens whenever more than one eligible connection exists, and that your client sees only a slightly higher time to first token. [2] Whether a Vertex AI path is available to you depends on the connection kinds you have set up; the [Connect a provider](https://infro.io/docs/providers) page lists what each serves. A separate endpoint is a separate failure domain, but it is not a guarantee. A shortage of a given model may or may not reach the other path, so test it before you rely on it.

**Another model.** If every connection serving the model is erroring, model fallbacks apply: an ordered list of up to five catalog model IDs, each tried over your own connections for that model's vendor, again before the first token. Fallbacks apply when the request names a model; when it names a route, the route's own targets are used instead. [2] The alternate model need not be Gemini. It must be good enough for the task, which is a test you run in advance; see [Is your fallback model good enough?](https://infro.io/blog/is-your-fallback-model-good-enough-test-fallback-equivalence).

Both are bounded by the commit point. Failover works strictly before the first token. [2] If a stream has started and then breaks, that is a different problem with different options, covered in [Streaming LLM failures](https://infro.io/blog/streaming-llm-failure-modes).

The failover rules INFRO documents are broad: a provider 5xx, timeout, 429, rejected credential, 404 or even a 400 or 422 moves the request to the next connection, while INFRO's own refusals (invalid body, budget, allowlist, unknown model) return immediately. [2] If you want the stricter "stop on 400" behaviour from the table above, that is what failure rules on a route are for; check the routes documentation for what each rule can express before you assume it.

With a single connection there is nothing to fail over to. [2] A route over one Gemini key can retry, but it cannot route around the shortage.

## What the request trace shows

Failover that you cannot inspect is failover you cannot tune. Each request that goes through INFRO is recorded with the model, the selected provider connection, the outcome, timings, usage and estimated provider cost; the trace documentation also covers fallback attempts and latency. [4] The response itself names the model, provider and connection that served the request. [2] For a route, the trace additionally names the route and the connection that served it. [3]

During or after an overload, use the trace to answer four questions:

1. **How many attempts did the request take?** A request that needed a second target is a failover that worked. A request with several attempts and an error is a rule that ran out of options.
2. **Which connection served it?** If it was your second connection, check that its latency and estimated cost are what you expected.
3. **How much time did the extra attempts add?** Your client sees a higher time to first token; the trace is where you see how much. If the retry on the first target costs more than it recovers, shorten it.
4. **Did the model change?** If a fallback model answered, the served model in the record differs from the one you asked for. Track that share, because it is a quality and cost change that no user reported.

You can list failing requests with the request API, for example `GET /v1/requests?status=error`, sorted by slowest to find the ones where retries cost the most. [4] Estimated provider cost is an estimate for operational use, not an invoice; the trace documentation says it is not one. [4]

## What failover does not do

A route does not prevent an overload. The shortage is at the provider, and nothing you put in front of it changes that. What a route changes is where your request goes once the first destination says no, and how quickly. If both of your destinations are short of capacity, or only one connection exists, the request still fails and your application still needs an error path that tells the user something useful.

Plan for that case explicitly:

- Decide what the screen shows when every target has failed, and whether the request is worth queuing for later.
- Keep the total time bounded; a long chain of targets is a long wait.
- Know what failover changes about cost. A fallback model may be priced differently from the primary, and a cold prompt cache on the second destination can change the estimate; see [What does failover do to your bill?](https://infro.io/blog/what-does-failover-do-to-your-bill-price-gaps-and-cold-caches).
- Run a drill. A second connection that has never carried traffic is an assumption; [failover drills](https://infro.io/blog/llm-failover-drills) describe how to test it.

## Checklist before the next overload

- [ ] Client code distinguishes 503 from 429 and never treats them as the same retry.
- [ ] 503 retries are jittered, capped at one or two, and bounded by the user's deadline.
- [ ] No retry loop stacked on top of a gateway that already fails over.
- [ ] A second connection or an alternate model exists, and has served real traffic recently.
- [ ] The route says, per failure kind, whether to retry, move on or stop.
- [ ] The trace shows attempts and the serving connection, and someone looks at it after incidents.
- [ ] The all-targets-failed path shows the user a clear message.

## Questions

### What does "The model is overloaded" mean in the Gemini API?

It arrives as an HTTP 503 with status UNAVAILABLE. Read it as the model being short of capacity at that moment. Your own request rate and quota are not the cause, so raising a limit does not fix it.

### Is the Gemini "high demand" error the same as a 429?

No. A 429 RESOURCE_EXHAUSTED points at a limit on your project or key. A high-demand 503 points at the provider's capacity. Treat them as separate failure kinds with separate rules.

### Should I add more API keys when Gemini returns 503?

Usually not. Keys spread rate-limit windows, which helps a 429. During a capacity event the shortage is behind all of them, so a second key on the same host tends to meet the same 503.

### Does a gateway stop Gemini 503 errors?

No. The overload is on Google's side and a gateway cannot prevent it. A route can move the request to another connection or model before the response starts, so your user may never see the error.

## Sources

1. LLM routing rules: if-rules, failure rules, key spreading — INFRO. https://infro.io/blog/llm-routing-rules-failure-rules (accessed 2026-11-26)
2. Failover & fallbacks — INFRO Docs. https://infro.io/docs/features/fallbacks (accessed 2026-11-26)
3. Routes — INFRO Docs. https://infro.io/docs/routes (accessed 2026-11-26)
4. Request traces — INFRO Docs. https://infro.io/docs/observability/traces (accessed 2026-11-26)
