◉GEMINI LABJP
●2.5 ROUTE — Since 12/1, gemini-2.5-pro routes to 3.8 Flash and gemini-2.5-flash to 3.5 Flash-Lite, billed at the new model's rates●CARBON — Intro pricing for Gemini 4 Carbon and Argon has ended. Standard rates: $4.00 input, $20.00 output per 1M tokens●OMNI 1.1 — gemini-omni-1.1-flash starts routing to 1.2 Flash on 12/3, one day from now●COMPRESS — Some Gemini CLI users report auto-compression that barely shrinks the context, round after round●FALLBACK — Planning for model changes or traffic spikes? Decide your retry count and fallback model up front●LONG DOC — Feeding Gemini a long document? State your goal and the part to read first, and fewer details get dropped●2.5 ROUTE — Since 12/1, gemini-2.5-pro routes to 3.8 Flash and gemini-2.5-flash to 3.5 Flash-Lite, billed at the new model's rates●CARBON — Intro pricing for Gemini 4 Carbon and Argon has ended. Standard rates: $4.00 input, $20.00 output per 1M tokens●OMNI 1.1 — gemini-omni-1.1-flash starts routing to 1.2 Flash on 12/3, one day from now●COMPRESS — Some Gemini CLI users report auto-compression that barely shrinks the context, round after round●FALLBACK — Planning for model changes or traffic spikes? Decide your retry count and fallback model up front●LONG DOC — Feeding Gemini a long document? State your goal and the part to read first, and fewer details get dropped
Articles/API / SDK
◈ API / SDK/2026-04-26Advanced

Gemini API × Stripe — Production Usage-Based Billing for Indie AI SaaS

Build flat-plus-metered billing for a Gemini API SaaS with Stripe Billing Meters and webhooks: frozen batches that prevent double charges, basil-era period fields, @google/genai metering, and a troubleshooting table.

Gemini API256Stripe10SaaS11BillingWebhook3Metered BillingProduction33

✦ Premium Article

The first time I opened an invoice preview in test mode, the Pro line read "¥98,000" and I just sat there. I'd meant ¥980 a month. I had forgotten that the yen is a zero-decimal currency and had multiplied by 100 out of dollar habit. The only reason no real customer ever saw that number is that I'd pushed one subscription all the way to an invoice in test mode before going live.

When you're building a Gemini-powered SaaS on your own, billing looks like the part you can bolt on later. But usage-based billing has three moving pieces — counting, reporting, and deciding what a user is allowed to do — and if any one of them drifts, you either double-charge someone or quietly stop charging them. Both cost you trust in a single invoice.

Below is the hybrid setup I rebuilt: a flat base plan plus metered overage, using the Gemini API and Stripe Billing Meters. I've updated everything to how Stripe and the Gemini API work as of November 2026; several things in the earlier version of this article were out of date, and one was simply wrong.

The one idea I'd like you to take away: make counting, reporting, and entitlement each safe to re-run on their own. Every section below is ordered around that.

The short answer — which billing model to pick

What I'd say first is that with an LLM behind your product, usage varies so much between users that it breaks most flat pricing. If someone who calls your feature a few dozen times a month pays the same as someone who calls it hundreds of times a day, either the light users subsidize the heavy ones or you eat the difference.

ModelFits whenWhere it hurts
Flat subscription onlyA small feature where you can hard-cap callsHeavy users turn directly into losses
Pure usage-basedDeveloper-facing APIs whose users expect variable bills"I can't predict the bill" stops sign-ups
Flat base + metered overage (hybrid)Consumer-facing products with wide usage spreadYou need your own metering and reporting pipeline
Prepaid creditsProducts built around occasional heavy jobs (long video summaries, say)You need balance tracking and expiry terms

If you want both "the customer can predict the bill" and "my cost can't run away," pick the hybrid. The example tiers in this article are:

  • Free: up to 50,000 tokens/month (room to try the product)
  • Pro (¥980/month): 500,000 tokens included, then ¥150 per 100,000 tokens
  • Team (¥4,800/month): 5,000,000 tokens included, then ¥100 per 100,000 tokens

Treat the numbers as placeholders. I'd set your own only after running the shadow metering I describe near the end.

The flow — from one call to one invoice line

  1. Every Gemini call writes one row to your own database with the usageMetadata breakdown.
  2. A job runs every minute, groups unsent rows per user into a batch, and freezes that batch with an ID.
  3. Each frozen batch goes to Stripe as a Meter Event, using the batch ID as its identifier.
  4. At the end of the billing period, Stripe issues one invoice: base fee plus metered quantity times unit price.
  5. Webhooks tell you something changed; you re-fetch the current subscription from Stripe and update entitlements from that.

The important part is that the Gemini call and the Stripe report are decoupled. Reporting inline adds latency and lets a Stripe hiccup break the user's response. Buffering in your own database keeps each failure local.

✦

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
✦You'll get a setup script for one Meter and two Prices, written so a zero-decimal JPY price never comes out 100× too high
✦You'll build retry-safe usage reporting with frozen batches and webhook sync that doesn't depend on delivery order
✦You'll have a symptom-to-fix troubleshooting table plus the grace-period and reconciliation design you need after launch
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-04-26
Architecting a Multi-Tenant SaaS on Gemini API — Tenant Isolation, Usage Metering, and Runaway Cost Defense in Production
A field-tested blueprint for serving Gemini API to multiple tenants on a single backend — covering tenant isolation choices, per-tenant rate limiting in Redis, request-level usage metering for billing, and runaway-cost defenses.
◈ API / SDK2026-05-03
Building a Subscription SaaS on Gemini API and Cloudflare Workers — A Complete 2026 Implementation Guide
How I wire Gemini API, Stripe, and Cloudflare Workers into a subscription SaaS — with code, and with the places that actually bite: signature checks on Workers, webhook idempotency, KV access control, and the limits of a KV rate limiter.
◈ API / SDK2026-05-21
Designing Event-Driven AI Workflows with Gemini API and Cloud Pub/Sub — Notes from an Indie Developer
An implementation memo on wiring Gemini API into Cloud Pub/Sub event-driven workflows. Using an app-review analysis pipeline as the running example, the article covers retry policy, dead-lettering, idempotency, and cost guardrails — from the perspective of someone running it solo.