◉GEMINI LABJP
●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…●ARGON — gemini-4-argon is generally available as of 10/13, aimed at complex coding, agents, math and science●DEEP RES — deep-research-pro-preview-12-2025 shuts down 10/23, 6 days left. Move to deep-research-preview-04-2026●NANO — gemini-nano-banana-2.1 is GA (10/06). gemini-3.1-flash-image is deprecated with no shutdown date yet●MCP — One write-up cut an 85,000-token tool result to 310 tokens by wrapping it in an ADK FunctionTool●FLASH — gemini-3.7-flash and 3.5-flash now route automatically to newer Flash models (10/08)●NEW — Stop Re-Reading Every Crash Report: Gre…
Articles/API / SDK
◈ API / SDK/2026-04-11Advanced

Gemini API Rate Limits and 429 Handling: Operational Notes from an Indie Mobile App

Operational notes on handling Gemini API rate limits and 429 errors in a production indie mobile app: exponential backoff, adaptive control, multi-key pooling, and Cloud Monitoring integration, all rebuilt after a real incident.

gemini-api286rate-limiting4quota-managementpython108production140retry6monitoring5

✦ Premium Article

The Night a Batch Job Went Quiet for Thirty Minutes

The backend of a wallpaper app I run as a solo developer leans on Gemini API for image captions, tag completion, and review summarisation. It is a small service funded by ad revenue, which means an API stall is not an abstraction — it is the day's work stopping.

The rate-limiting code I write today exists because of one specific bad night. A scheduled job was supposed to regenerate metadata tags for about 80,000 wallpapers. I had retries, but exponential backoff was attached at the job level, not per request. The first key that hit 429 RESOURCE_EXHAUSTED got hammered by retries from every concurrent worker, the API went silent for more than thirty minutes, and the App Store Connect review work I had lined up for the morning slipped a full day. Since then, rate limiting in this app is treated as foundational, not as a "we'll harden it later" item.

What follows is the operational shape of that hardening: how Gemini API's quota system actually behaves under load, how I run exponential backoff with jitter, what adaptive rate control buys you, how I split keys via Vertex AI service accounts, and how Cloud Monitoring stitches the alerts together. Every code block is something currently running in the wallpaper app's Cloud Functions / Cloud Run backend, with business specifics scrubbed.

Who this is for

  • Engineers who have just put Gemini API into a real service and have seen their first few 429s or TPM trips
  • Indie or small-team developers who want a Cloud Monitoring setup that fits on the back of a napkin
  • Anyone trying to draw clean cost/quality lines for AI on top of an ad-funded app economy

Understanding the Gemini API Quota System

Before you can manage quotas effectively, you need a precise understanding of how they work. Gemini API enforces limits across three distinct dimensions.

The Three Quota Dimensions

1. RPM (Requests Per Minute)

This is the limit you'll hit most often. It varies by model and billing plan. On the free tier, Gemini 2.5 Pro allows just 5 RPM. Paid plans can reach 1,000 RPM or more.

2. TPM (Tokens Per Minute)

Rather than counting requests, this limit tracks token throughput. If you're passing large contexts or documents, you may hit your TPM limit even before your RPM limit.

3. RPD (Requests Per Day)

A daily ceiling. Free-tier limits are strict; paid plans are far more generous.

How to Check Your Current Limits

You can view your current quotas in Google AI Studio under "Get API Key," or in the Google Cloud Console under "Quotas & System Limits." You can also track token consumption per-request through the API response metadata.

import google.generativeai as genai
 
genai.configure(api_key="YOUR_GEMINI_API_KEY")
 
model = genai.GenerativeModel("gemini-2.5-pro")
response = model.generate_content("Hello, production world!")
 
# usage_metadata gives you per-request token breakdown
print(f"Input tokens:  {response.usage_metadata.prompt_token_count}")
print(f"Output tokens: {response.usage_metadata.candidates_token_count}")
print(f"Total tokens:  {response.usage_metadata.total_token_count}")

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Postmortem from a wallpaper app's 80,000-item nightly batch where a 429 cascade froze the API for 30+ minutes, with the exact retry, jitter and timeout numbers I rebuilt around
✦Seven implementation insights you will not find in the official docs (usage_metadata lag, Retry-After flakiness, IAM-based multi-key pooling, TPM vs RPM disambiguation, and more)
✦Decision lines for splitting Flash vs Pro in an AdMob-funded mobile app and a daily Cloud Billing alert formula (monthly_budget / 30 * 1.3) you can copy directly
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Gemini Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

◈ API / SDK2026-07-15
Sample what you already accepted — an audit budget that catches silent quality drift
A confidence gate only ever looks at output the model hesitated on. Silent drift sinks into the batch that sailed through. Working from a fixed 30-minutes-a-day review budget, this walks through deriving detection time from the binomial, reallocating the same budget across risk strata, and catching slow decay with a cumulative monitor.
◈ API / SDK2026-07-04
When Gemini API Leaks Japanese Into Your English Output Once in a While — Field Notes on Measuring the Contamination Rate and Tightening It in Stages
You told Gemini to answer in English, and 3 out of 100 runs slip a Japanese sentence into the tail. Here is why you cannot stop that 'once in a while', and a production pattern that measures the contamination rate as an SLO and tightens it with graded recovery, with working code.
◈ API / SDK2026-05-18
Gemini API asyncio Patterns for Production: How I Cut Processing Time by 80% in My Indie App Backend
A hands-on report on integrating Gemini API asyncio into a production backend. Covers Semaphore-based rate limiting, exponential backoff, partial failure handling, and what breaks when you move the same pipeline to the current google-genai SDK.