Google Gemini API Error RESOURCE_EXHAUSTED: Quota exceeded (429)
You hit a Gemini API limit: requests per minute, tokens per minute or requests per day for this model and tier. Back off and retry for per-minute limits; per-day limits need billing or a higher tier.
Identify: does your log match?
{
"error": {
"code": 429,
"message": "You exceeded your current quota, please check your plan and billing details.",
"status": "RESOURCE_EXHAUSTED"
}
}- High
Free-tier limits
Free tier limits per model are low and include a daily request cap that resets at midnight Pacific time.
- Medium
Bursts above requests per minute
Parallel calls from a batch job exceed the per-minute limit even when the daily total is small.
- Low
Shared project quota
Several apps use keys from the same Google Cloud project and share its quota.
Fix
Back off on 429
const res = await ai.models.generateContent({ model: "gemini-2.5-flash", contents });
import { GoogleGenAI } from "@google/genai"; const ai = new GoogleGenAI({}); async function generate(contents, tries = 5) { for (let i = 0; ; i++) { try { return await ai.models.generateContent({ model: "gemini-2.5-flash", contents }); } catch (e) { if (e.status !== 429 || i === tries - 1) throw e; await new Promise(r => setTimeout(r, Math.random() * 1000 * 2 ** i)); } } }
Per-minute limits clear within a minute; jittered backoff spreads retries so they don’t collide again.
Verify: reproduce it on purpose
$ for i in $(seq 1 40); do curl -s -o /dev/null -w "%{http_code}\n" \
"https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "x-goog-api-key: $GEMINI_API_KEY" -H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"hi"}]}]}' & done | sort | uniq -cRun it against a dev environment to trigger RESOURCE_EXHAUSTED on purpose and test your error handler.
Prevent
- Check your tier’s limits per model in Google AI Studio.
- Enable billing on the project for production traffic.
- Use the Batch API for large offline jobs.
FAQ
Is RESOURCE_EXHAUSTED always my quota?
Usually. Occasionally it reflects shared capacity on a model; in both cases backoff is the right first response.
When does the daily limit reset?
Requests-per-day quotas reset at midnight Pacific time.
Related errors
Last verified 2026-10-22 · Source: Gemini API troubleshooting guide + google.rpc status codes · Official docs ↗ · ~18,100 searches/mo