Gemini API Quota Exceeded: 429 RESOURCE_EXHAUSTED Error & Solutions
You hit a Gemini API rate limit. This guide covers what each limit means, how to check your current usage, implement exponential backoff, switch to a higher-quota model, and upgrade to paid tier.
Quick diagnosis
The error looks like this in the API response:
{
"error": {
"code": 429,
"message": "Resource has been exhausted (e.g. check quota).",
"status": "RESOURCE_EXHAUSTED"
}
} If Gemini is returning 429 for everyone right now, it may be a service incident — check the live status badge above before debugging your code.
Free tier rate limits by model
Every Gemini model on the free tier has three independent limits. Exceeding any one triggers a 429.
| Model | RPM | TPD (tokens/day) | RPD |
|---|---|---|---|
gemini-2.0-flash | 15 | 1,000,000 | 1,500 |
gemini-2.0-flash-lite | 30 | 1,000,000 | 1,500 |
gemini-1.5-flash | 15 | 1,000,000 | 1,500 |
gemini-1.5-pro | 2 | 32,000 | 50 |
gemini-1.5-pro has the most restrictive free tier at 2 RPM and 50 RPD. If you are using it, switching to gemini-2.0-flash gives 7.5x more RPM immediately.
Step 1 — Check your quota usage in Cloud Console
Before writing any code, confirm which limit you are hitting. Go to:
- console.cloud.google.com → APIs & Services → Generative Language API → Quotas & System Limits
- Filter by
GenerateContentto see per-minute request usage vs. your limit - Filter by
Tokento see daily token consumption
Alternatively, open aistudio.google.com → Usage tab for a per-model breakdown of RPM and token usage.
Step 2 — Implement exponential backoff
The most important fix for bursty workloads is retry with exponential backoff and random jitter. This handles transient RPM spikes without any quota increase.
Python
import time
import random
import google.generativeai as genai
import os
genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
model = genai.GenerativeModel("gemini-2.0-flash")
def call_with_backoff(prompt, max_retries=5):
for attempt in range(max_retries):
try:
return model.generate_content(prompt)
except Exception as e:
if "429" in str(e) or "RESOURCE_EXHAUSTED" in str(e):
if attempt == max_retries - 1:
raise
# Exponential backoff: 1s, 2s, 4s, 8s, 16s + jitter
wait = (2 ** attempt) + random.uniform(0, 1)
print(f"Rate limited. Waiting {wait:.1f}s before retry {attempt + 1}/{max_retries}")
time.sleep(wait)
else:
raise
response = call_with_backoff("Explain exponential backoff in one paragraph") JavaScript / Node.js
import { GoogleGenerativeAI } from "@google/generative-ai";
const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY);
const model = genAI.getGenerativeModel({ model: "gemini-2.0-flash" });
async function callWithBackoff(prompt, maxRetries = 5) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
const result = await model.generateContent(prompt);
return result.response.text();
} catch (error) {
const isQuota = error.message?.includes("429") ||
error.message?.includes("RESOURCE_EXHAUSTED");
if (isQuota && attempt < maxRetries - 1) {
const wait = (2 ** attempt + Math.random()) * 1000;
console.log(`Rate limited. Retrying in ${(wait / 1000).toFixed(1)}s...`);
await new Promise(resolve => setTimeout(resolve, wait));
} else {
throw error;
}
}
}
}
const text = await callWithBackoff("What is exponential backoff?");
console.log(text); cURL (check quota headers)
# Use -i to see response headers — Gemini returns Retry-After on 429
curl -i -X POST \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts": [{"text": "Hello"}]}]
}'
# Bash retry loop with backoff
MAX=5; WAIT=1
for i in $(seq 1 $MAX); do
STATUS=$(curl -s -o /tmp/gemini_resp.json -w "%{http_code}" \
-X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=$GOOGLE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"Hello"}]}]}')
[ "$STATUS" = "200" ] && break
echo "Attempt $i failed ($STATUS). Sleeping ${WAIT}s..."
sleep $WAIT; WAIT=$((WAIT * 2))
done
cat /tmp/gemini_resp.json Step 3 — Switch to a model with more free quota
If you are on gemini-1.5-pro (2 RPM free), switching to gemini-2.0-flash (15 RPM free) is a one-line change that gives you 7.5x more headroom:
# Before (2 RPM free tier)
model = genai.GenerativeModel("gemini-1.5-pro")
# After (15 RPM free tier, faster responses)
model = genai.GenerativeModel("gemini-2.0-flash")
# Or the ultra-fast lite variant (30 RPM free tier)
model = genai.GenerativeModel("gemini-2.0-flash-lite") gemini-2.0-flash-lite has the highest free RPM (30) and is best for high-volume tasks where response quality is secondary to throughput.
Step 4 — Enable billing or request a quota increase
Enable billing (removes most free tier limits)
- Open console.cloud.google.com → Billing
- Link a billing account to your project
- On paid tier,
gemini-2.0-flashautomatically goes from 15 RPM to 2,000 RPM - You are charged per token —
gemini-2.0-flashcosts $0.075 / 1M input tokens
Request a quota increase
- Go to console.cloud.google.com → APIs & Services → Generative Language API → Quotas & System Limits
- Find the specific metric you need more of (e.g.,
GenerateContent requests per minute per project) - Click the pencil icon → enter the new limit → Submit Request
- Quota increase requests require an active billing account and are typically approved within 2 business days
Get an email the next time Google Gemini API goes down
Outage alerts for Google Gemini API, straight to your inbox. No account needed, unsubscribe in every email.
Watching more than one service? A free account covers 5 services + a daily digest — and Pro is currently free.
Frequently asked questions
Why do I get 429 RESOURCE_EXHAUSTED when calling Gemini API?
This error fires when you exceed one of three independent limits: RPM (requests per minute), TPM (tokens per minute), or RPD (requests per day). On the free tier, gemini-2.0-flash allows 15 RPM — sending 16 requests in a single minute triggers a 429 on that 16th call. The API does not queue requests; it rejects them immediately when the limit is reached.
What are the free tier rate limits for each Gemini model?
gemini-2.0-flash: 15 RPM, 1M TPD, 1,500 RPD. gemini-2.0-flash-lite: 30 RPM, 1M TPD, 1,500 RPD. gemini-1.5-flash: 15 RPM, 1M TPD, 1,500 RPD. gemini-1.5-pro: 2 RPM, 32K TPD, 50 RPD. The Pro model has dramatically lower free limits — avoid it for high-volume use cases unless you have billing enabled.
How do I check my Gemini API quota usage in Cloud Console?
Navigate to console.cloud.google.com → APIs & Services → Generative Language API → Quotas & System Limits. Filter by metric name to see current usage vs. limit for RPM, TPM, and RPD. You can also use the Usage tab in aistudio.google.com for a per-model view of daily token consumption.
How do I request a quota increase or switch to a paid tier?
Enable billing in your Google Cloud project to automatically unlock higher paid tier limits (e.g., gemini-2.0-flash goes from 15 RPM to 2,000 RPM). For even higher limits beyond the paid tier defaults, go to Quotas & System Limits in the Cloud Console and click the pencil icon next to the specific metric to request an increase. Requests require an active billing account and are typically reviewed within 2 business days.