Gemini 429 RESOURCE_EXHAUSTED
What you see when this happens
- HTTP 429 with `status: 'RESOURCE_EXHAUSTED'`
- Error message specifies which quota was hit (RPM, TPM, RPD)
- Retry-After header may or may not be present
- Different limits between AI Studio and Vertex AI
Common causes
Free tier: 15 RPM. Paid tier: 1,000+ RPM. Easy to exceed on free tier.
1M TPM on free tier, 4M+ on paid. Large-context requests burn TPM fast.
Free tier has strict RPD (1,500 requests/day). Paid is higher but finite.
Vertex quota is per-project per-model — one model can be exhausted while others still serve.
How to fix it
Retry with exponential backoff
Standard retry pattern with full jitter.
from google.genai import errors
import random, time
def call_with_backoff(fn, max_attempts=5):
for attempt in range(max_attempts):
try:
return fn()
except errors.APIError as e:
if e.code != 429 or attempt == max_attempts - 1:
raise
wait = random.uniform(0, min(60, 2 ** attempt))
time.sleep(wait)
Upgrade from free to paid tier
Enable billing in Google AI Studio or GCP to unlock significantly higher quotas (1,000+ RPM vs. 15 RPM).
Request quota increase on Vertex AI
In GCP Console, navigate to IAM & Admin > Quotas, filter for 'Vertex AI', find the specific model quota, and request an increase. Usually approved within 24-48 hours.
Fail over to a cheaper model
Gemini Flash has separate quotas from Pro — failover routing distributes load.
MODELS = ["gemini-3.5-pro", "gemini-3.5-flash"]
def call_with_model_fallback(prompt):
for model in MODELS:
try:
return client.models.generate_content(
model=model, contents=prompt,
)
except errors.APIError as e:
if e.code == 429:
continue
raise
How to prevent it
- Enable billing early — free tier limits are prototyping-only
- Monitor per-model quotas separately
- Use Vertex AI for production (better quota controls than AI Studio)
- Cache responses where semantics allow
Related errors
Frequently asked questions
What's the difference between AI Studio and Vertex AI rate limits?
AI Studio has account-wide limits scaled by billing status (free vs. paid). Vertex AI has per-project per-model quotas managed through GCP quota system, with higher default limits and adjustable via quota requests.
How do I know which specific limit I hit?
The error message specifies the quota name. Common ones: 'GenerateContentRequestsPerMinutePerProjectPerModel', 'GenerateContentInputTokensPerMinutePerProjectPerModel', 'GenerateContentRequestsPerDayPerProjectPerModel'.