---
title: "Gemini API 429 RESOURCE_EXHAUSTED: Quota, Capacity or Burst?"
description: "Gemini 429 RESOURCE_EXHAUSTED: tell quota, shared capacity and burst traffic apart from the body, with a minimal test, retryDelay retry code and 429 vs 503."
url: https://cdnping.org/en/blog/gemini-api-429-resource-exhausted-fix
language: en
published: 2026-10-28
category: "Troubleshooting"
tags: ["Gemini API","429","rate limiting","error troubleshooting","retry"]
source: cdnping.org
license: Free to quote and summarize with a link to the url above.
---
# Gemini API 429 RESOURCE_EXHAUSTED: Quota, Capacity or Burst?

When the Gemini API returns 429 with the status `RESOURCE_EXHAUSTED`, your request reached Google and was rejected because "resources ran out". It is not a network failure, and it is not a wrong API key. When you hit a Gemini 429, look at the response body first. If it carries `QuotaFailure` details, your project has used up a quota (RPM, TPM or RPD). If there are no quota details and the error clears on its own after a short while, it is most likely tight shared capacity or a momentary concurrency spike. The three cases need different handling.

## First, confirm it is really a 429 and not a network issue or a 503

Rule out two things that are easy to mix up.

The first is a network-layer problem. The request never reached Google, and what you see is a timeout, a connection reset or a failed TLS handshake, with no HTTP status code at all. In that case check the [Gemini API status page](/en/status/gemini): cdnping probes `generativelanguage.googleapis.com` from Cloudflare edge nodes every 5 minutes. For reference, in the window that had just started collecting, 08:40-10:05 UTC on October 17, 2026 (Cloudflare Denver node; see the [methodology](/en/methodology) for how this is measured), every probe to this endpoint succeeded, with connect time at p50 69ms and p95 89ms. The window is short. It only shows the endpoint was reachable during that period, not its long-term performance. If the status page looks healthy but you cannot connect locally, the problem is on your side, and you can work through it layer by layer with the [developer network self-check list](/en/blog/developer-network-self-check-2026).

The second is 503. Both 429 and 503 can be retried, but they mean different things:

| Status | `status` field | Typical meaning | Whose problem | What to do |
|---|---|---|---|---|
| 429 | `RESOURCE_EXHAUSTED` | Quota used up, or shared capacity temporarily short | Quota: yours. Capacity: the server's | Read retryDelay and retry with backoff; for quota, slow down or raise the limit |
| 503 | `UNAVAILABLE` | Service temporarily overloaded or unavailable | Server | Retry with backoff; switch model or fallback route if needed |
| 500 | `INTERNAL` | Internal server error, occasionally linked to overly long input | Mostly the server | Retry a few times; if it keeps happening, shorten the input and try again |
| 400 | `FAILED_PRECONDITION` | For example, the free tier is not available in your region | Account or region | Do not retry; check your account and region |

One more note on the last row: if the error says your region is not supported, that is a terms-of-service restriction. Retrying or changing code will not help, so choose a compliant way to access the service under Google's terms and local regulations. For the general meaning of each status code, see the [LLM API error code cheatsheet](/en/blog/ai-api-error-codes-400-to-529-cheatsheet).

## How do you tell the three kinds of RESOURCE_EXHAUSTED apart from the error message?

All of them are 429, but the response bodies differ. Below is a common shape when a quota is exceeded (an example; field names and values depend on what you actually receive):

```json
{
  "error": {
    "code": 429,
    "message": "You exceeded your current quota, please check your plan and billing details...",
    "status": "RESOURCE_EXHAUSTED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.QuotaFailure",
        "violations": [
          {
            "quotaMetric": "generativelanguage.googleapis.com/generate_content_free_tier_requests",
            "quotaId": "GenerateRequestsPerMinutePerProjectPerModel-FreeTier",
            "quotaDimensions": { "model": "<model name>", "location": "global" }
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.RetryInfo",
        "retryDelay": "37s"
      }
    ]
  }
}
```

Use this table to decide:

| What you see | Most likely cause | Next step |
|---|---|---|
| `details` has `QuotaFailure`, `quotaId` contains `PerMinute`, `quotaMetric` is a request count | RPM exceeded | Lower the request rate and wait for retryDelay |
| `quotaId` or `quotaMetric` is token-related (for example contains `input_token_count`) | TPM exceeded, common with long contexts or large document batches | Send less per request, split into batches, or space requests out |
| `quotaId` contains `PerDay` | RPD exceeded; today's allowance is gone | Wait for the daily reset, or adjust your usage tier |
| `quotaId` contains `FreeTier` | You are on the free tier, which has low limits | Check whether the project is linked to billing and whether you are using the key from the wrong project |
| Only a message like "Resource has been exhausted", no `QuotaFailure`, recovers on its own within seconds to minutes | Shared capacity shortage (resources tight on the server side at that time) | Retry with backoff; if it persists for a long time, switch model or use reserved capacity |
| Normal most of the time, appears only at the instant a batch starts or at peak concurrency, then disappears | A traffic burst hitting the per-minute window | Rate-limit on the client and smooth out sending, rather than adding more retries |

A few points:

- Limits are per project, not per API key. Google's [rate limits documentation](https://ai.google.dev/gemini-api/docs/rate-limits) states that limits apply to the project. Creating several keys under one project does not give you more quota, and it makes several services compete for the same allowance.
- Limits are separate per model. The `model` in `quotaDimensions` tells you which model's quota is full. The usage you are looking at in the console may be for a different model.
- RPD resets at midnight Pacific Time, which is 3 p.m. or 4 p.m. Beijing time (UTC+8), depending on whether the US is on daylight saving time. If 429s start every day after a fixed time, suspect RPD first.
- Gemini on Vertex AI uses a different quota system (dynamic shared quota and provisioned throughput). A 429 there more often means the shared pool is short at that moment, and handling should follow the official Vertex AI documentation. This article mainly covers the Gemini API (AI Studio keys).

## The console shows low usage. Why do I still get a 429?

There are many posts like this on Google's developer forum, and many have no resolution. You can check the following one by one:

1. You looked at the wrong model. The model shown by default in the usage chart is not necessarily the one you requested. Use `quotaDimensions.model` from the error to find the matching row.
2. You looked at the wrong project. Quota is counted against whichever project the key belongs to. If a colleague runs a test script under the same project, their requests are counted together with yours.
3. You were blocked by TPM rather than RPM. You may have sent only a few requests in a minute, but if each carries a very long context, the token count can still exceed the limit. Check whether `quotaId` is token-related.
4. The usage chart lags. Console statistics are not real time, and the peak from the last minute may not be shown yet.
5. It is not a quota problem at all. If the response has no `QuotaFailure`, it is a capacity-type 429, and naturally nothing looks abnormal in console usage.

Saving the full error response body and investigating from that is faster than staring at the console. Many SDKs and logging setups print only `message` by default and drop `details`, so turn on verbose logging, or just use the curl commands below.

## Hands-on: reproduce and pinpoint with a minimal request

### Step 1: confirm the key and the network are fine

Listing models does not call the generation endpoint, which makes it a good first check of the key and connectivity:

```bash
export GEMINI_API_KEY="your key"
curl -s -o /dev/null -w "HTTP %{http_code}  connect %{time_connect}s  total %{time_total}s\n" \
  "https://generativelanguage.googleapis.com/v1beta/models" \
  -H "x-goog-api-key: $GEMINI_API_KEY"
```

A 200 means the key is valid and the network works. If this already fails, the problem is not quota. Check your network and proxy settings first.

### Step 2: send the smallest possible generation request

```bash
MODEL="the model name you actually use"
curl -s "https://generativelanguage.googleapis.com/v1beta/models/${MODEL}:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"parts":[{"text":"ping"}]}]}' | tee /tmp/gemini-resp.json
```

- Small request succeeds, large request gets 429: almost certainly TPM.
- Small request also gets 429 and carries `QuotaFailure`: RPM or RPD is full; look at `quotaId`.
- Small request also gets 429 but with no quota details: a capacity-type problem. Try again at a different time or with a different model to compare.

### Step 3: pull out the key fields

```bash
jq '.error | {code, status, message,
  quota: [.details[]? | select(."@type"|endswith("QuotaFailure")) | .violations[]? | {quotaId, quotaMetric, quotaDimensions}],
  retryDelay: [.details[]? | select(."@type"|endswith("RetryInfo")) | .retryDelay][0]}' /tmp/gemini-resp.json
```

Paste this output into a support ticket and others can tell right away which kind it is.

## How should the retry code be written?

The principle: if the server gives a `retryDelay`, wait that long; if not, use exponential backoff with random jitter; cap the number of retries. A quota-type 429 (especially RPD) will not succeed no matter how many times you retry, so fail fast or degrade. The example below needs Python 3.10 or later.

```python
import os, random, time, requests

URL = "https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent"

def parse_retry_delay(err: dict) -> float | None:
    for d in err.get("details", []):
        if d.get("@type", "").endswith("RetryInfo"):
            v = d.get("retryDelay", "")          # looks like "37s" or "1.5s"
            if v.endswith("s"):
                return float(v[:-1])
    return None

def is_daily_quota(err: dict) -> bool:
    for d in err.get("details", []):
        for v in d.get("violations", []) or []:
            if "PerDay" in v.get("quotaId", ""):
                return True
    return False

def generate(model: str, body: dict, max_attempts: int = 5):
    key = os.environ["GEMINI_API_KEY"]
    base, cap = 1.0, 60.0
    for attempt in range(max_attempts):
        r = requests.post(URL.format(model=model), json=body,
                          headers={"x-goog-api-key": key}, timeout=120)
        if r.status_code == 200:
            return r.json()
        if r.status_code not in (429, 500, 503):
            r.raise_for_status()                 # 400/401/403 etc. are not retried
        try:
            err = r.json().get("error", {})
        except ValueError:
            err = {}
        if r.status_code == 429 and is_daily_quota(err):
            raise RuntimeError("Daily quota exhausted, stop retrying: " + err.get("message", ""))
        if attempt == max_attempts - 1:
            break
        delay = parse_retry_delay(err)
        if delay is None:
            delay = random.uniform(0, min(cap, base * 2 ** attempt))  # full jitter
        time.sleep(delay)
    raise RuntimeError(f"Still failing after {max_attempts} attempts, last status {r.status_code}")
```

A few easy places to go wrong:

- Multiple processes each retrying on their own amplify the burst. For example, a batch job opens 50 concurrent requests, all hit 429 together, wait the same number of seconds and send again together, and the next round gets 429 too. Jitter exists to spread them out.
- A retry is itself a request. The more you retry, the denser the requests in the same one-minute window, so set a retry limit and a global retry budget. For details, see [exponential backoff with jitter and retry budgets](/en/blog/llm-api-retry-exponential-backoff-jitter).
- Fix bursts on the sending side. A token bucket or a fixed-size concurrency pool that spreads each minute's requests evenly works better than retrying after the fact. For general practice, see [429 Too Many Requests and how to use Retry-After](/en/blog/llm-api-429-too-many-requests-fix).

## Long-term fixes for each of the three causes

| Cause | Short term | Long term |
|---|---|---|
| RPM/TPM exceeded | Wait for retryDelay, lower concurrency | Client-side rate limiting; compress prompts and cache repeated context; split different workloads across projects |
| RPD exceeded | Stop retrying, degrade to another model for the rest of the day | Request a higher usage tier based on actual daily usage, or move non-real-time jobs to after the reset |
| Shared capacity shortage | Retry with backoff | Prepare a fallback model or fallback route, with circuit-breaker conditions |
| Traffic burst | Stagger batch job start times | Queue plus fixed-rate consumption |

On fallback routes: the same model can behave differently across access routes. Take the OpenRouter public data that cdnping's [model monitor](/en/models) synced on October 17, 2026. For the same Google model, the 1-day uptime was 97.99% through the Google AI Studio standard route, 99.10% through the Vertex global route, and 100% on AI Studio's flex and priority routes. This is one day of data and should not be read as a stable gap between routes, but it does show the risk of configuring only one path. For why the same model can have different uptime across providers, see [this analysis](/en/blog/same-model-different-providers-uptime). For how to design fallback chains, circuit breakers and session consistency, see [multi-provider failover](/en/blog/llm-multi-provider-failover-circuit-breaker).

## Checklist for when something goes wrong

When you hit a Gemini 429, go through this in order:

- [ ] Open [/en/status/gemini](/en/status/gemini) and [/en/down/gemini](/en/down/gemini) to see whether the endpoint is healthy and whether other users are reporting rate limiting at the same time
- [ ] Save the full response body and confirm `status` is `RESOURCE_EXHAUSTED` and not `UNAVAILABLE`
- [ ] Is there a `QuotaFailure`? If so, note the `quotaId` and `quotaDimensions.model`
- [ ] Is `quotaId` PerMinute, PerDay or token-related? Does it include FreeTier?
- [ ] Which project does the key belong to? Who else is calling under the same project?
- [ ] Compare with the minimal "ping" request: does the small request fail too?
- [ ] Does the retry code read `retryDelay`, use jitter and a retry cap, and stop on RPD?
- [ ] Does concurrency spike at a particular moment (batch jobs, scheduled jobs, replay after a service restart)?

If you also use Claude, its overload error is 529 rather than 503. The logic for handling it is similar but not identical, so read it alongside [Claude 529 overloaded_error](/en/blog/claude-529-overloaded-error-explained). cdnping's [official site changes](/en/changes) tracks additions and removals in the Gemini changelog line by line; when a rate-limit-related announcement appears, you can compare it against your own rate-limit settings. For the exact limit values, rely on Google's official rate limits documentation.
