What a 429 RESOURCE_EXHAUSTED tells you
The Gemini API returns 429 RESOURCE_EXHAUSTED when your project has used up a limit. It is a statement about your quota, not about Google's capacity. Google's own retry guidance names 429 RESOURCE_EXHAUSTED and 503 UNAVAILABLE together as errors that call for exponential backoff,1 but the two have different causes and, as later sections show, different fixes.
Three facts decide almost everything that follows:
- Limits are measured per project, not per API key.2
- Limits differ per model, and per usage tier of the project.2
- Exceeding any single limit triggers the error, even if the others have room.2
So the first question is never "should I retry?". It is "which limit, on which model, in which project?" The rest of this guide answers that, then covers what to do, and only at the end how a gateway can carry the failover decision so that application code does not have to.
The three limits, and the ones around them
Google measures rate limits across three dimensions: requests per minute (RPM), input tokens per minute (TPM) and requests per day (RPD).2 The docs give the arithmetic plainly: with an RPM limit of 20, the 21st request inside a minute fails, even if your token and daily limits are untouched.2
| Limit | Window | What exhausts it | Resets |
|---|---|---|---|
| RPM | One minute | Many small requests, a retry storm, parallel workers | Rolling, within about a minute |
| TPM (input) | One minute | A few very large prompts, long context, big documents | Rolling, within about a minute |
| RPD | One day | Steady volume over the day, or a batch job that ran early | Midnight Pacific time2 |
| Spend limit | Rolling 10 minutes | Expensive requests in a burst | Rolling2 |
There are limits beyond the three. Image models have images per minute, some models have a tokens-per-day limit, and built-in tools carry their own: Grounding with Google Search on Gemini 3 and newer has a default of 1,500 requests per day per project on the Gemini Developer API.2 Preview and experimental models have more restricted limits,2 which is why a call that works on a stable model can 429 on a preview one at the same traffic. Priority inference holds its own limits, by default 0.3x the standard limit for each model and tier.2
The spend-based limit surprises people. On paid tiers it is evaluated over a rolling 10-minute window: $10 on Tier 1 and $200 on Tier 2 and Tier 3, with no such limit on the free tier. Whether it applies to a given account depends on billing history and standing.2 When you hit it, the API still returns 429 RESOURCE_EXHAUSTED. A burst of long-context requests can trip it while your RPM and TPM look fine.
Google also says the specified limits are not guaranteed and actual capacity may vary.2 Treat the numbers as a budget, not a promise.
How to tell which limit you hit
The error status alone does not say. The docs separate the cases in the Interactions API error reference: one 429 code for exceeding a per-minute or per-second request or token limit, one for exceeding the daily quota, and one for too many requests in a short period.3 If the API gives you that code or a quota name in the message, log it. Do not write logic that depends on message wording, though; it can change. Instead, diagnose from your own data.
- Open the AI Studio rate-limit page for the project. Google points to it for your active limits per model and tier, with usage over the last 28 days.2 Read the limit for the exact model in the failing call.
- Count requests in the last minute for that model and project. If the count is at or near the RPM limit, it is RPM. Include every service and developer laptop that shares the project.
- Sum input tokens for the same minute. If requests are well under RPM but a few carry large prompts, it is TPM.
- Check the day. If the 429s began at some point in the day and never cleared until after midnight Pacific, it is RPD.
- Check the 10-minute spend. If requests and tokens are in bounds but cost per request is high, compare against the spend limit for your tier.
The pattern over time is the fastest tell. Per-minute limits clear in under a minute. A daily limit stays until the reset. A spend limit clears as the 10-minute window rolls forward.
Usage tiers and how a project moves up
Rate limits are tied to the project's usage tier, and the project is upgraded automatically as usage and spend grow.2 The tiers and their qualifications, as the docs list them:
| Tier | Qualification | Billing tier cap |
|---|---|---|
| Free | An active project or free trial; some projects need verification | N/A |
| Tier 1 | Set up and link an active billing account | $250 |
| Tier 2 | Paid $100 plus 3 days from first successful payment | $2,000 |
| Tier 3 | Paid $1,000 plus 30 days from first successful payment | $20,000 to $100,000+ |
Tiers 2 and 3 are based on total cumulative spending on Google Cloud services, not just the Gemini API, for the billing account linked to the project.2 A move from Free to Tier 1 typically takes effect instantly; later upgrades take effect within 10 minutes.2 Meeting the criteria is generally sufficient, though Google notes an upgrade can in rare cases be denied after review.2
Two practical consequences. First, the quickest fix for a free-tier 429 is to link billing, which moves the project to Tier 1. Second, a project that hits its paid-tier limits can ask for more through Google's rate limit increase form, with no guarantee: Google says it will do its best to review the request.2 That is a slow path at best, so it is a capacity plan, not an incident response.
When backoff works, and when retrying is wasted
Backoff works for limits that clear on their own within seconds: RPM, TPM and the rolling spend window. Google recommends exponential backoff starting around 1 second (then 2, 4, 8), random jitter so clients do not retry in lockstep, a maximum number of attempts, and retrying only transient errors such as 429, 408 and 5xx.1 The official SDKs already do this: the Python SDK retries transient errors up to four times with an initial delay of about 1 second and a maximum of 60 seconds.1 If you use an SDK, check before adding your own loop on top, or you will multiply attempts and keep the project pinned at its limit.
Backoff does not work when the daily limit is spent. Google's error reference gives different actions for the two: wait and retry with exponential backoff for the per-minute code, but wait until the quota resets or request an increase for the daily one.3 RPD resets at midnight Pacific time.2 Retrying a spent daily limit only burns client time and keeps the failure visible to users for hours.
import random, time
class DailyQuotaSpent(Exception):
pass
def call_with_backoff(send, max_attempts=4, base=1.0, cap=60.0):
"""send() returns (status, body). Retry only what can clear soon."""
for attempt in range(max_attempts):
status, body = send()
if status < 400:
return body
if status == 429 and daily_quota_spent(body):
# Do not wait for midnight Pacific inside a request path.
raise DailyQuotaSpent(body)
if status not in (408, 429, 500, 502, 503, 504):
raise RuntimeError(f"not retryable: {status}")
delay = min(cap, base * 2 ** attempt)
time.sleep(random.uniform(0, delay)) # full jitter
raise RuntimeError("retries exhausted")daily_quota_spent is yours to write. The reliable version compares your own per-model, per-project request count for the current Pacific-time day against the limit shown in AI Studio, rather than parsing message text. Raise DailyQuotaSpent to a layer that can pick another target, or queue the work for after the reset.
Do not retry 400, 402 or 403: they point to bad syntax, a payment problem or a restricted project or key, and Google says not to retry them.1
Spreading across keys does not raise a project limit
The common first response to a 429 is to create more API keys and rotate through them. Inside one Google project it does nothing. Rate limits are applied per project, not per API key,2 so ten keys in one project share one RPM, one TPM and one RPD. The same logic applies to the free-tier eligibility check, which Google evaluates at the project level: a new key in the same project does not resolve a restriction.1
What does add headroom:
- A key in a different project that has its own tier and its own per-model limits. Each project needs billing linked to reach a paid tier.
- A higher tier for the project you already have.
- A different model whose limits have room, since limits are per model.2
- A different route to the same model family, such as Gemini on Vertex AI, which is a separate quota system. See Vertex AI 429 resource exhausted: two causes, two fixes for how those limits behave.
Whether more projects are acceptable is a policy and terms question for your organization, not just a technical one. Splitting traffic purely to dodge limits can also complicate attribution and billing. Check your agreement before building that. For the general version of this mistake across providers, see Load balancing LLM API keys: what adds capacity and what doesn't.
429 RESOURCE_EXHAUSTED vs 503 UNAVAILABLE
Both are on Google's backoff list,1 but they mean different things.
| Question | 429 RESOURCE_EXHAUSTED | 503 UNAVAILABLE |
|---|---|---|
| Whose limit | Your project's, for that model | The service is temporarily overloaded or down3 |
| Cause | Over RPM, TPM, RPD or spend | Capacity or an outage on Google's side |
| Another key, same project | Same result | May or may not recover |
| Another project | Often succeeds | Often the same failure |
| Another model | Often succeeds | Depends on whether the model is the affected one |
| Retry | Yes for per-minute; not for spent daily | Yes, with backoff |
The practical split: with a 429, the failing resource is your allocation, so capacity elsewhere in your accounts is useful. With a 503, the failing resource is Google's serving capacity for that model or region, so a second key or project on the same model often hits the same problem. A 503 is the case for a different model or a different serving path; a 429 is the case for more quota. Log both separately, and do not let a circuit breaker treat a 429 as an unhealthy provider. A rate limit on one model says nothing about whether your next request to another model will work. Circuit breakers for LLM providers: throttling is not failure covers that distinction.
When the answer is a second connection or another model
Sort the 429 by what clears it:
- Per-minute limits, short bursts. Backoff, plus smoothing on your side. Queue and pace requests to stay under RPM and TPM.
- Per-minute limits, sustained. Backoff will not close a structural gap. You need a higher tier, a second project, or a second path. Raise the tier first, because it needs no architecture work.
- Spent daily limit. Move the remaining traffic to a target that has room: a different project, Gemini on Vertex AI, or another model. Queue anything that can wait until the reset.
- Spend window. Reduce per-request cost (smaller context, shorter outputs), or move large requests to a target with a higher ceiling.
When you fail over to another model, the change is not neutral. Prices differ, caches are cold, and outputs differ. Is your fallback model good enough? Test fallback equivalence and What does failover do to your bill? cover what to check before the failover is needed. Decide which requests deserve a fallback and which should wait; Provider quota is short: which AI requests should survive? is the triage for that.
Doing the failover through one route
You can write all of this in application code, but then every service repeats the classification of 429s, the secondary targets and the daily-limit check. A gateway can hold it in configuration instead. With INFRO, which sits in front of provider accounts you already hold, the pieces map like this:
- Connection failover. With a model named directly, INFRO tries your enabled, healthy connections that serve that vendor. Keys that just answered 429 are tried last, and a provider 429 does not count against the connection's health. Every upstream failure before the first token, 429 included, moves to the next connection, and your client sees only a slightly higher time to first token.4 With one connection there is nothing to fail over to.4
- Model fallbacks. A
fallbacksarray of up to five catalog model IDs is tried in order once every connection for the primary model has failed before the first token.4 - Routes. A named route your application sends as
modelresolves to ordered or weighted targets over your own connections, and a priority route walks targets in order, using the first that answers.5 Routes can also carry if-rules and failure rules, which decide per failure kind whether to retry, move on or stop, so a spent daily limit can go straight to the next target instead of waiting. - Visibility. When your own provider returns the 429, INFRO's error uses the code
provider_rate_limited,6 so you can tell a provider limit from INFRO's own refusals in your logs.
Failover only helps if a second target exists with its own headroom. Two keys in the same Google project count as one for Gemini's limits, even though INFRO spreads requests across a provider's keys:4 give the route a second target that sits in a different project, a different serving path or a different model. INFRO's gateway keys also take limits you control: an hourly spending limit per key bounds a burst from one caller, and key limits restrict which providers a key may use. Those protect the shared Gemini project from one noisy service eating the whole RPM.
A checklist for the next 429
- Note the model, project and time of the failing call.
- Read the project's limits for that model in AI Studio.
- Classify: RPM, TPM, RPD or spend window.
- Per-minute: back off with jitter and a retry cap; confirm no second retry loop sits above the SDK's own.
- Daily: stop retrying, queue what can wait, move the rest to another target.
- Check whether billing is linked and the tier is what you expect.
- Confirm any "extra" keys are in different projects.
- Keep 429 and 503 in separate metrics, and do not trip a breaker on 429.
