GEMINI LABJP
NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20NANOLITE — Nano Banana 2 Lite is here: Google's fastest and most cost-efficient Gemini Image model, made for running lightweight image generation cheaplyOMNIFLASH — Gemini Omni Flash is in public preview, a natively multimodal model that lets enterprises and developers build custom, dynamic video workflowsAGENTS — Managed Agents expand with background: true for async server-side runs and polling, remote MCP server integration, and refreshing credentials across interactionsMEMORY — The Memory Bank IngestEvents API is generally available, decoupling event ingestion from memory generation so you can stream content continuouslyTHROUGHPUT — Provisioned Throughput now lets you submit up to seven pending orders for the same model and regionDEPRECATE — Image generation models shut down on August 17, and the Grok 4.1 family on the Gemini Enterprise Agent Platform on August 20
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-api277rate-limiting4quota-managementpython104production140retry6monitoring5

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-03-30
Gemini API Observability in Production — Logging, Monitoring, and Cost Tracking Patterns
Learn how to build a robust observability stack for production Gemini API deployments. Covers structured logging, token usage tracking, latency monitoring, and cost optimization dashboards with full implementation code.
API / SDK2026-03-26
Gemini API AI Gateway Design Patterns — Building a Unified Proxy for Rate Limiting, Failover, and Cost Tracking
An advanced guide to designing and implementing an AI gateway (proxy server) for production Gemini API deployments. Learn how to unify rate limiting, automatic failover, token cost tracking, and multi-model routing in a single architecture layer.
API / SDK2026-03-19
Gemini 2.5 Pro × FastAPI: Building a Production-Ready AI Backend
Learn how to build a production-ready AI backend by combining Gemini 2.5 Pro with FastAPI, covering streaming, rate limiting, Function Calling, cost optimization, and Docker deployment.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →