Tickd.ai
API errors

Gemini API 429 Resource Exhausted Error: How to Fix

Updated 11/1/2026

Understand the Gemini API 429 Error

The Gemini API returns an HTTP 429 Too Many Requests status code with the error message RESOURCE_EXHAUSTED when your application exceeds its allocated rate limits. This protection mechanism prevents system abuse and ensures service stability. Rate limits are tracked across three primary vectors:

  1. Requests Per Minute (RPM): The total count of API calls initiated within a sliding 60-second window.
  2. Tokens Per Minute (TPM): The combined quantity of input (prompt) and output (completion) tokens processed in a 60-second window.
  3. Requests Per Day (RPD): The absolute daily ceiling for API calls.

These limits differ drastically depending on whether you are running on the Free Tier or the Pay-As-You-Go Tier within Google AI Studio or Vertex AI. Follow these sequential steps to resolve the issue.

Agent Builder turns a task you repeat into a reusable assistant with setup text for each app.

Tickd is independent and not affiliated with any AI company.

Open Agent Builder

Step 1: Identify Your Current Rate Limits and Tier

Before refactoring code, determine which tier your API key is associated with:

  1. Log in to the [Google AI Studio](https://aistudio.google.com/) dashboard.
  2. Navigate to the Plan & Billing or Settings section.
  3. Verify whether your API key is linked to a Free plan or a Pay-as-you-go Google Cloud billing account.
  4. Free Tier (Gemini 1.5 Flash): Limits are constrained (typically 15 RPM, 1 million TPM, and 1,500 RPD).
  5. Pay-As-You-Go Tier: Limits scale significantly higher (e.g., up to 360 RPM and 4 million TPM for Gemini 1.5 Flash).

If your application's natural traffic requirements exceed these baselines, you will continue to trigger 429 errors until you implement code-level throttling or upgrade your tier.

Step 2: Implement Exponential Backoff with Jitter

If your code encounters a 429 error, do not retry the request immediately. Instant retries overwhelm the gateway and extend your rate limit lockout. Instead, implement exponential backoff with a randomized "jitter" factor. This ensures retries are spread out smoothly over time.

Below is a Python implementation utilizing standard SDK patterns to gracefully retry failed calls:

`python import time import random from google.api_core import exceptions from google import genai

client = genai.Client()

def generate_with_retry(prompt, retries=5, base_delay=2): for attempt in range(retries): try: response = client.models.generate_content( model='gemini-1.5-flash', contents=prompt, ) return response.text except exceptions.ResourceExhausted as e: if attempt == retries - 1: raise e # Calculate backoff: base_delay * 2^attempt + random jitter delay = (base_delay ** attempt) + random.uniform(0, 1) print(f"Rate limit hit. Retrying in {delay:.2f} seconds...") time.sleep(delay) `

Step 3: Set Up Client-Side Rate Throttling

Do not rely entirely on backoff error-catching. Proactively throttle your outbound API requests to stay safely below your quota thresholds.

If you are using Node.js, implement client-side queuing with a rate-limiting library like limiter:

`javascript import { RateLimiter } from "limiter"; import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI(); // Safe threshold: Limit requests to 12 per minute (1 request every 5 seconds) const limiter = new RateLimiter({ tokensPerInterval: 12, interval: "minute" });

async function safeGenerateContent(prompt) { await limiter.removeTokens(1); try { const response = await ai.models.generateContent({ model: "gemini-1.5-flash", contents: prompt, }); return response.text; } catch (error) { console.error("API Error:", error); } } `

Step 4: Optimize and Compress Token Payloads

Your code might trigger 429 errors because you are hitting your Tokens Per Minute (TPM) limit rather than your Requests Per Minute (RPM) limit. Large document uploads, heavy system instructions, and verbose outputs consume TPM rapidly.

  • Use Context Caching: If you are repeatedly sending the same large system instructions, reference materials, or PDF documents (greater than 32,000 tokens), implement Gemini's Context Caching API feature. This cuts both token overhead and costs.
  • Cap Output Generation: Set the max_output_tokens parameter in your generation configuration to a lower threshold. This prevents the model from returning unnecessarily long, token-draining text.
  • Sanitize Inputs: Strip out useless white spaces, HTML tags, duplicate datasets, and verbose headers from your inputs before pushing them to the Gemini model.

Step 5: Transition to Pay-As-You-Go Billing

If your production application has outgrown the free limitations, linking a payment card is the quickest fix.

  1. Go to the Google AI Studio console.
  2. Click on the Get API Key or Billing option.
  3. Select Set up billing and follow the prompts to link an active Google Cloud Billing account.
  4. Once billing is enabled, your API key transitions to the paid tier, and your rate limits automatically scale to production-ready ceilings.

When to Escalate

If you have already transitioned to a paid Google Cloud billing account and your high-scale application is still regularly exhausting its quota, you must request a custom quota limit increase. Go to the Google Cloud Console, navigate to IAM & Admin > Quotas & System Limits, search for the Generative Language API (or Vertex AI API if using Enterprise), find the specific metric causing the block (such as Generate Content requests per minute), and click Edit Quotas to submit an official request to the engineering team.

Once it's working again, two free Tickd tools can help: AI Setup Profile writes setup text for Gemini so you repeat yourself less, and Agent Builder turns a repeat task into a reusable assistant.

While you're here

Tickd is more than troubleshooting — these three are free and take seconds.

Agent BuilderDesign your own AI agent and export it to ChatGPT, Claude, Gemini or Grok.Build one free