◉GEMINI LABJP
●TTS — Gemini 3.8 Flash TTS and Flash-Lite TTS are GA as of September 22. Voice replication works on Flash only; Flash-Lite returns a 400●2.5 — Access to the 2.5 models is now limited to accounts with prior active usage (September 18). Not a deprecation: new projects should start on 3.5 Flash-Lite or 3.8 Flash●9/30 — Two days until gemini-omni-flash-preview shuts down, and gemini-2.5-flash-image follows on October 2. In practice the replacement for the latter is gemini-3.1-flash-image●AUTH — Reports continue of Gemini CLI sign-in failing only for Workspace Enterprise accounts while personal accounts work. Isolating the two is the current focus●NEW — Moving to 3.8 Flash-Lite TTS meant re-picking the voice for our guidance audio●429 — A brand-new project shows Free tier yet returns 429 with limit: 0. Here is what to check in the first hour●TTS — Gemini 3.8 Flash TTS and Flash-Lite TTS are GA as of September 22. Voice replication works on Flash only; Flash-Lite returns a 400●2.5 — Access to the 2.5 models is now limited to accounts with prior active usage (September 18). Not a deprecation: new projects should start on 3.5 Flash-Lite or 3.8 Flash●9/30 — Two days until gemini-omni-flash-preview shuts down, and gemini-2.5-flash-image follows on October 2. In practice the replacement for the latter is gemini-3.1-flash-image●AUTH — Reports continue of Gemini CLI sign-in failing only for Workspace Enterprise accounts while personal accounts work. Isolating the two is the current focus●NEW — Moving to 3.8 Flash-Lite TTS meant re-picking the voice for our guidance audio●429 — A brand-new project shows Free tier yet returns 429 with limit: 0. Here is what to check in the first hour
Articles/API / SDK
◈ API / SDK/2026-06-27Advanced

Stopping Runaway Costs Twice: Project Spend Caps Plus an App-Side Soft Limit

Pairing Gemini API Project Spend Caps (a monthly USD ceiling) with an app-side soft circuit breaker that trips before the hard cap. Includes a working Python and sqlite daily cost ledger.

Gemini API243Cost Management5Spend Caps2Automation14Operations12

✦ Premium Article

One morning, before I had even made coffee, I opened the Gemini API dashboard and my hand froze for a second. The automated publishing pipeline I run unattended overnight had fired several times more requests than I expected. The cause was mundane: an external API was intermittently returning 5xx, and the retry logic I had written was dutifully hammering it again and again. The bill never became serious, but it left a quiet mark on me. Running something unattended means keeping a path open through which costs can quietly pile up while you are not watching.

Project Spend Caps, which reached general availability on June 26, 2026, speaks directly to that anxiety. You can set a monthly USD ceiling on Gemini API usage per project, and it stays in force until you change or disable it. Even so, a hard ceiling alone is not enough — that has been my honest experience as an indie developer running several apps and blogs unattended in parallel. In this piece I want to leave behind a two-layer design: Project Spend Caps as the foundation, with an app-side soft limit layered just inside it that quietly slows things down before the hard cap ever fires.

Where costs actually spike in unattended runs

Costs spike, almost always, during the hours when nobody is watching. And the causes are few enough to count on one hand.

First, retry storms. If you fire requests again immediately on a transient 429 or 5xx without exponential backoff, every failure becomes another call, and the volume swells in minutes. My own near-miss was exactly this.

Second, model misrouting. If you point a heavy model at light preprocessing such as background lookups or tagging, your per-request unit cost multiplies for no reason. Output tokens are priced higher than input, so casually letting a model return long responses adds up too.

Third, loops that never settle. In agentic flows that keep retrying "once more if it isn't enough," a loose stop condition spawns near-infinite round trips. When you run autonomous execution like Managed Agents unattended, this is the scariest pitfall of all.

None of these surface in normal testing. They bare their teeth only in production, in the hours while you sleep. That is exactly why you need a ceiling on cost itself, in a layer separate from the correctness of your code.

What Project Spend Caps protect, and what they don't

The role of Project Spend Caps is clear. Once monthly spend tied to a project reaches the USD amount you set, further billable requests are stopped. It works like a credit card limit — a last line of defense.

But a hard ceiling has an inherent limitation. The moment the cap is reached, in-flight work is rejected uniformly. A half-assembled article and a batch that was halfway done are stopped without distinction. From the app's point of view, calls suddenly start returning errors past a certain moment in time.

In other words, a hard cap exists to prevent disaster, not to decelerate gracefully. As the cap approaches near month-end, it cannot make the judgment to let important jobs through while deferring trivial ones. Filling that gap is the job of the soft limit we build next.

✦

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
✦How to assign a monthly USD ceiling per project with Project Spend Caps so a runaway loop can't bleed your budget
✦A daily cost ledger in Python and sqlite, with a soft circuit breaker that trips before the hard cap
✦Routing preprocessing to gemini-flash-latest and capping thinking budget to lower your baseline cost
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 $15 for lifetime access
View Membership →

Related Articles

◈ API / SDK2026-09-02
Taking stock of Gemini standard API keys before September, across CI, servers, and my own machine
Standard API keys, including restricted ones, stop being accepted during September. Because this changes where keys come from rather than what they say, here is the three-layer inventory I ran across code, deploy settings, and my local machine, plus a dual-path client to switch behind.
◈ API / SDK2026-07-29
A 17% Drop in Output Tokens Sounded Big. Then I Decomposed the Bill
Output pricing fell 16.67% and output tokens fell about 17%. Adding those numbers does not give you the savings. Here is an exact price/volume/cross-term decomposition, plus a loop measurement where the savings rate went down instead of up.
◈ API / SDK2026-07-18
Keeping a Long-Running Managed Agent Alive Across Sandbox Recycling — Durable Checkpoints and Idempotent Resume
A Managed Agents sandbox can be recycled out from under you. Before 40 minutes of work resets to zero, we design a durable checkpoint that pushes progress outside the sandbox and an idempotent resume that never runs a side effect twice. With working SQLite code.
📚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