GEMINI LABJP
PRO35 — July 17, the date reports had pointed to, has passed without an official Gemini 3.5 Pro announcement or model card. July 24 is being cited as the fallbackNB2LITE — Nano Banana 2 Lite, otherwise known as Gemini 3.1 Flash-Lite Image, arrives as the fastest of the family: roughly four seconds per image at $0.034 per thousandOMNI — Gemini Omni Flash enters public preview, generating video up to ten seconds long at $0.10 per second of outputEDIT — Omni Flash is built around conversational editing. Swap a character, relight a scene, or change the angle in plain language, and the original audio and video tracks stay intactSYNTHID — Both new models carry SynthID watermarking, so anything they produce can be checked for provenance from inside the Gemini appSHUTDOWN — The older image generation models are deprecated and switch off on August 17. Worth checking your migration windowPRO35 — July 17, the date reports had pointed to, has passed without an official Gemini 3.5 Pro announcement or model card. July 24 is being cited as the fallbackNB2LITE — Nano Banana 2 Lite, otherwise known as Gemini 3.1 Flash-Lite Image, arrives as the fastest of the family: roughly four seconds per image at $0.034 per thousandOMNI — Gemini Omni Flash enters public preview, generating video up to ten seconds long at $0.10 per second of outputEDIT — Omni Flash is built around conversational editing. Swap a character, relight a scene, or change the angle in plain language, and the original audio and video tracks stay intactSYNTHID — Both new models carry SynthID watermarking, so anything they produce can be checked for provenance from inside the Gemini appSHUTDOWN — The older image generation models are deprecated and switch off on August 17. Worth checking your migration window
Articles/API / SDK
API / SDK/2026-06-18Advanced

Stop a Batch Before It Overspends — A Budget Gate Built on countTokens That Survives a Default-Model Swap

Nightly batches overspend because you only learn the cost after billing. Starting from countTokens, this guide builds a budget gate that folds in thinking tokens and keeps your estimate intact even when the default model changes underneath you.

Gemini API190countTokens2Cost Management5Batch Processing5Production32

Premium Article

The day the default model changed, my monthly estimate quietly drifted

Alongside my day job I run a couple of Gemini batches as an indie developer: one classifies the overnight reviews for my wallpaper app, another summarizes daily AdMob reports. Both have predictable item counts, so at the start of each month I would pencil in a rough monthly figure and trust the batch to land inside it.

Then the default model switched to a newer Flash generation, and that rough figure quietly stopped holding. The item count and the input contents were unchanged, yet by mid-month I had already crossed roughly a day's worth of budget. Tracing the logs, I found the visible output text was the same length as before — but the billed tokens had grown. The culprit was thinking tokens. My estimate counted only "input tokens plus visible output tokens," so it missed the thinking tokens the model burns internally.

What that taught me was how fragile it is to discover cost from the invoice, after the fact. A batch fires through thousands of items at once. Even if you notice mid-run, most of it is already billed by the time you stop it. So I rebuilt the design to put a budget gate at the entrance: estimate the cost just before submission, and refuse to run if it exceeds the budget. This article shares that design in a form you can reproduce.

Why "notice it after submission" overspend happens

Batch overspend follows a few shapes that indie developers walk into easily.

One is variance in input size. Even in a task where each item is short, like review classification, an occasional very long body inflates the total. Estimating from an average misses that long tail.

Another is underestimating output tokens. Summaries and classifications look short, but returning a JSON schema as structured output spends tokens on field names and delimiters. "How much text it looks like" and "how many tokens are billed" are not the same.

The biggest blind spot is thinking tokens. Newer model generations reason internally before responding, and those tokens are billed on the output side. A static estimate that counts only visible text structurally misses them. In my environment, around 30 percent of output billing for the classification task was thinking tokens. When the default model swaps, that ratio surfaces directly as estimation error.

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
Python for a gate that computes projected_cost from countTokens and halts a batch before it overspends
A procedure to fold Gemini 3.5 Flash thinking tokens into the estimate, correcting the ~30% undercount of output-only math
A design that follows a default-model swap with a single recalibrated coefficient, easy to keep in production
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-23
Preventing Gemini API Cost Spikes in Solo Products — Guardrails That Save You from Month-End Shocks
Nearly every solo developer using the Gemini API eventually has the 'why is my bill 10x what I expected' month. Here are the production-grade guardrails I always install in my own wallpaper app and client projects to stop cost runaways before they start.
API / SDK2026-07-11
When Gemini's Context Cache Quietly Expires Mid-Run: A TTL Guard for Pipelines That Pause
When a nightly batch or a retry backoff pauses your pipeline, Gemini's explicit context cache can expire on the wall clock while nothing errors out, sending later calls back to full-token billing. Here is a small lease guard that decides whether to re-arm or run uncached based on cost.
API / SDK2026-07-05
Designing Batch Image Costs with Nano Banana 2 Lite: Decide by Measuring
How to fold the fastest, cheapest image model, Nano Banana 2 Lite, into high-volume generation: measuring per-image cost, a two-tier setup with a quality model, and retry handling grounded in real numbers.
📚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 →