GEMINI LABJP
FLASH — Gemini 3.5 Flash is now generally available and powers gemini-flash-latestAGENTS — Managed Agents in the Gemini API enter public preview, running autonomously in Google-hosted isolated Linux sandboxesSTUDIO — Google AI Studio adds project-level spend caps and native Android vibe codingLIVE — Gemini 3.1 Flash Live Preview, an audio-to-audio model for real-time dialogue, is now availableIMAGE — Nano Banana 2 Lite arrives as the fastest, most cost-efficient image model, and Gemini Omni Flash is in API previewLYRIA — Lyria 3 music generation models (clip-preview and pro-preview) are now availableFLASH — Gemini 3.5 Flash is now generally available and powers gemini-flash-latestAGENTS — Managed Agents in the Gemini API enter public preview, running autonomously in Google-hosted isolated Linux sandboxesSTUDIO — Google AI Studio adds project-level spend caps and native Android vibe codingLIVE — Gemini 3.1 Flash Live Preview, an audio-to-audio model for real-time dialogue, is now availableIMAGE — Nano Banana 2 Lite arrives as the fastest, most cost-efficient image model, and Gemini Omni Flash is in API previewLYRIA — Lyria 3 music generation models (clip-preview and pro-preview) are now available
Articles/Advanced
Advanced/2026-07-09Advanced

Setting a Token Budget Per Free User: Balancing AdMob Revenue Against AI Feature Cost

Rate limits protect requests per minute. They do nothing for the invoice that arrives at the end of the month. Here is how I derive a per-user token budget from ad revenue, keep the ledger inside a single call wrapper, degrade gracefully at a soft cap, and detect abuse with one concentration ratio.

gemini-api269cost-management7production136python99AdMob9architecture15

Premium Article

Last month I put the AdMob report next to the Gemini API invoice, and only one of the two numbers had moved.

Ad revenue: essentially flat. API cost: 2.4x the previous month.

No outage, no bug. Digging through the logs, a single user had been calling the AI feature more than 300 times a day. Nothing malicious as far as I could tell — someone had simply found a feature they enjoyed and kept pulling the lever. The rate limiter had worked perfectly. Requests per minute stayed under the cap. Daily call counts stayed under the cap.

The thing that was not protected was the invoice.

What a rate limit protects, and what it does not

A rate limit governs flow per unit of time. What we actually want to protect is money per billing period. These look similar and measure entirely different quantities.

Ten calls a minute and 300 calls a day is not, on its face, a broken policy. But 300 x 30 = 9,000 calls from one free user is absurd. It is dozens of times more than that user will ever return in ad revenue.

When you run apps as an indie developer, that asymmetry lands directly on your bank balance. The month your user count grows is the month your balance shrinks.

What you need is a guard on the money axis. And a guard on the money axis needs a number derived from revenue.

Derive the budget from what a user is worth

Start with what one free user earns you in a month. My apps monetize primarily through AdMob interstitials, so the figure comes from eCPM and impressions per user.

InputValueSource
eCPMJPY 380AdMob, trailing 30 days
Daily impressions per DAU3.0AdMob ÷ Firebase DAU
Daily revenue per DAUJPY 1.14380 ÷ 1000 × 3.0
Median active days per month9In-app instrumentation
Monthly ARPUJPY 10.31.14 × 9

Next, decide what share of that may go to AI cost. I cap it at 30%. After server costs and payment fees, that is the level at which the feature still pays for itself.

So the per-user monthly token budget is about JPY 3.0. Now apply your effective unit cost.

Use the number you back out of your own invoice, not the published rate card. Cache hit ratio and prompt length move the per-call figure substantially for the same model. Mine came to JPY 0.42 per call on average.

MetricMy measurementImplied ceiling
Monthly ARPUJPY 10.3
Max AI cost share30%JPY 3.09 per user / month
Effective cost per callJPY 0.42
Monthly call ceiling, free tier7 calls

Seven. The first time that number appeared on my screen I sat with it for a while. Offering an unlimited AI feature on a free tier had never been arithmetically coherent in the first place.

Budgeting in tokens rather than calls is more precise, so in the implementation I convert to a token-denominated budget — 7,500 weighted tokens per month, in my case.

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
A worked calculation that turns eCPM and DAU into a per-user monthly spend ceiling, applied to my measured effective cost of JPY 0.42 per call
Python code that reconstructs true cost from the four usage_metadata fields and keeps the per-user ledger inside one call wrapper
A three-step degradation ladder (model downgrade at 70%, cached-only at 100%) plus the top-1% concentration ratio that surfaces abusive clients
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

Advanced2026-04-20
to Production Architecture for Gemini API 2026— Design Patterns for Building Scalable, Reliable AI Systems
A comprehensive guide to production-grade design patterns for Gemini API. Covers resilient API clients, multi-layer caching, multi-tenant design, observability, and cost control with complete code examples.
Advanced2026-07-07
Designing So the Next Shutdown Notice Doesn't Cost You an Afternoon: Isolating Gemini Behind a Single Port
The morning an image model shutdown notice landed, I couldn't say where my app touched that model. This is the design I use now: collapse Gemini dependencies into one port, with fallback and a CI deadline guard, shown as working code.
Advanced2026-04-26
Custom Gemini API Agent Loop Without ADK — A Complete Production Guide to Tool Calling, Memory, and Parallel Execution
Build production-grade AI agents using Gemini API directly without Google ADK. This guide covers custom agent loops, tool calling patterns, sliding window memory, parallel execution, and battle-tested error recovery strategies.
📚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 →