Gemini API errors
What does Gemini's 429 RESOURCE_EXHAUSTED error mean?
429 RESOURCE_EXHAUSTED means your Google Cloud project went over one of the Gemini API's limits: requests per minute, input tokens per minute, requests per day, or the spend allowed in a rolling 10-minute window. The fastest fix is to retry with exponential backoff, then open the rate limit page in Google AI Studio to see your project's active limits.
Limits apply per project, not per API key, so a second key in the same project won't help. Daily request limits reset at midnight Pacific time, and where the spend-based limit applies, a Tier 1 project gets $10 per 10 minutes.
Which limit you hit
Google checks each limit on its own, and "exceeding any of them will trigger a rate limit error." Its own example: if your RPM limit is 20, the 21st request within a minute fails, even with tokens to spare.
| Limit | Window | Typical trigger | Fix |
|---|---|---|---|
| Requests per minute (RPM) | Per minute | Bursts of calls, or many workers sharing one project | Back off and retry, and spread requests out |
| Tokens per minute (TPM) | Per minute, input tokens | Long prompts or large files sent in a burst | Back off, and send fewer or shorter inputs at once |
| Requests per day (RPD) | Resets at midnight Pacific time | The day's request allowance is used up | Wait for the reset, or request a higher limit |
| Spend-based limit | Rolling 10 minutes | Spend over $10 on Tier 1, or over $200 on Tiers 2 and 3 | Wait, cut expensive requests, or request an increase |
On the Interactions API, the error's code field narrows it down: rate_limit_exceeded covers "the per-minute or per-second request or token limit", quota_exceeded means "You have exceeded your daily quota", and too_many_requests means too many requests in a short period. Google's fix for the spend-based limit is to wait, then "Reduce the rate of expensive requests, for example by using smaller context windows or shorter outputs."
How to tell which one you hit
- Open the rate limit page in AI Studio to see the active limits for your project and each model.
- Check your tier on the Projects page in AI Studio. Rate limits are tied to the project's usage tier, and later tier upgrades take effect within 10 minutes.
- Count the apps and keys on the project. They all draw from the same pool: "Rate limits are applied per project, not per API key."
- Match the errors to your traffic. 429s that line up with long contexts or long outputs point to the spend-based limit, 429s at a steady high request rate point to RPM, and 429s that last until midnight Pacific point to RPD.
- Check the model. Google notes that "Rate limits are more restricted for experimental and preview models."
Errors that look similar but won't clear with a retry
- 402 Payment Required (
payment_required): "Your Prepay credit balance is depleted." Add credits or turn on auto-reload. Google says not to retry 400, 402 or 403 errors. - 403 PERMISSION_DENIED: the key is blocked or reported as leaked, or the project is restricted. See what to do when a Gemini key is reported as leaked.
- Billing tier spend cap: each billing account has a monthly cap of $250 on Tier 1, $2,000 on Tier 2 and $20,000 to $100,000 on Tier 3. Once it's reached, service is paused for every linked project "until the start of the next billing cycle (the 1st of each month)." You can request an increase.
- Project spend cap you set yourself in AI Studio, under Spend, then Monthly spend cap. Google marks it experimental, and spend can run over for about 10 minutes before it stops anything.
If usage stopped while the rate limit page shows headroom, check the Spend page in AI Studio before you touch your retry logic. Caps and prepay are covered in how to limit Gemini API spend.
Where Costbrake fits
RESOURCE_EXHAUSTED is Google slowing a burst down. It doesn't tell you what the burst cost, and it won't stop the next one. Costbrake watches Gemini spend through a read-only Google Cloud connection: live estimates from Cloud Monitoring, about 5 minutes behind, checked every 5 minutes on Pro and Team and every 2 minutes during a spike, plus the Cloud Billing export to BigQuery, which is usually a few hours behind and final after about 3 days.
The live estimates count paid-tier input and output tokens per model. Cached input, long-context, grounding, and image or audio output only show up later, in the billing export.
If spend keeps climbing, a Costbrake admin can brake the Gemini API in one project: Costbrake sets a zero Google spend cap on that service, using a second service account key that can manage budgets. Google pauses new usage once its cost estimate passes the cap. That isn't instant, and usage until then is still billed. Undo lifts the cap, and Google can take up to an hour to let usage through again. Brakes need Pro or Team; see pricing and the Google Cloud integration. The rate limits themselves are Google's, and Costbrake can't change them.
Questions and answers
Does a new Gemini API key fix RESOURCE_EXHAUSTED?
No. Google applies rate limits per project, not per API key, so every key in the same project shares one set of limits. A key in another project has its own rate limits, but its usage tier and the monthly cap on your billing account still apply.
How long should I wait before retrying a Gemini 429?
Google recommends exponential backoff with jitter: wait about 1 second, then 2, 4 and 8 seconds, and cap the number of retries. The official SDKs already do this; the Python SDK retries up to four times with delays from about 1 second up to 60 seconds. A daily limit won't clear until midnight Pacific time.
Why do I get RESOURCE_EXHAUSTED on a paid tier?
Paid tiers have limits too. Each model has its own RPM, TPM and RPD limits for your tier, preview models get tighter ones, and paid projects can hit the spend-based limit: $10 per rolling 10 minutes on Tier 1 and $200 on Tiers 2 and 3, where Google applies it.
How do I raise my Gemini API rate limits?
Your tier goes up automatically as you spend: Tier 2 needs $100 paid plus 3 days since your first successful payment, and Tier 3 needs $1,000 paid plus 30 days. Google also has a form to request a paid tier rate limit increase, linked from its rate limits page.
Can Costbrake stop RESOURCE_EXHAUSTED errors?
No. Those are Google's limits and only Google can change them. Costbrake shows what the spend behind a burst is costing, alerts within minutes on Pro and Team, and lets an admin set a zero spend cap on the Gemini API in one project when the spend is unwanted.
Sources
Updated