A near-miss label won't fix itself on retry — a normalization layer for closed-vocabulary classification
When responseSchema enum returns an out-of-set label, retrying tends to return the same near-miss. From a wallpaper app's 30-category batch, here is the distribution of how labels miss, plus a normalization layer built on an alias table and gemini-embedding-2 nearest-neighbor, with measured results.
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.
The Day We Went From 30 Categories to 34 — Reclassifying 1,180 Assets Instead of 8,142
Adding categories to a taxonomy does not require reclassifying everything. Here is how embeddings and confidence margins narrowed a backfill from 8,142 assets to 1,180, with the numbers.
When Context Caching Didn't Lower My Gemini Bill — Field Notes on Measuring the Real Hit Rate
When Context Caching is enabled but the Gemini API bill barely drops, this field note measures the real hit rate from usage_metadata, separates TTL churn from fragmentation, and walks through a staged recovery.
Your Tool Results Are Quietly Eating the Conversation — Handle Passing to Keep Gemini Function Calling Contexts Lean
Tool results linger in Function Calling history and compound your input tokens every turn. Two implementations — a token-budgeted compactor and handle passing — cut my measured input by roughly 8x, with the pitfalls I hit along the way.
Is Gemini 3.5 Flash Actually Cheaper? Measuring Retry Amplification to Find the Flash vs Pro Break-Even
Now that 3.5 Flash is generally available, it is tempting to route everything to it. But once you measure effective cost per success instead of per-call price, the decision changes. Here is a small harness to measure retry amplification and find the break-even.
Routing Gemini by Pipeline Stage: Draft on Flash, Finish on the Top Tier
A record of reworking which Gemini model handles which stage of an automation pipeline, prompted by the general availability of Gemini 3.5 Flash and the rollout of 3.1 Flash-Lite. Includes a small router that splits work into draft, classify, and finalize stages, how the cost picture changes, and the guardrails I settled on.
Generate With Flash, Escalate to Deep Think Only When Unsure: A Two-Stage Pipeline
With Deep Think opening up on the API, the move is not to route every request through the heavy model but to have Deep Think verify only when Flash's output looks shaky. Here is the cost reasoning and working code.
Reconciling Orphaned Gemini Files API Uploads Across a Fleet of Apps
Files API uploads quietly expire after 48 hours. Here's how I keep orphaned files and quota under control across six apps, using reconciliation against my own database and a scheduled cleanup job — written up as production notes from running wallpaper apps.
Trimming Gemini Embeddings from 3072 to 768 Dimensions: A Matryoshka Approach to Cutting Vector DB Cost and Latency
gemini-embedding-001 returns 3072-dimensional vectors, but thanks to Matryoshka representation you can keep only the leading dimensions with almost no quality loss. This is a design for trimming to 768 to cut vector DB storage and latency, including the re-normalization pitfall and coarse-to-fine search code.
Running Gemini 3 Pro and Flash in Parallel on AdMob Monthly Reports — Notes from Ten Mornings
Implementation notes from sending the same AdMob monthly report to Gemini 3 Pro and Gemini 3 Flash in parallel for ten days. Cost, latency, and summary quality compared from an indie developer's perspective.
Coalescing Gemini API Requests with SSE Fan-out: Collapsing 100 Simultaneous Hits into a Single Call
How I rebuilt the post-push-notification thundering herd on a 50M-download wallpaper app into a Cloudflare Durable Objects coalescer with SSE fan-out, cutting Gemini API costs by 92% with 14 days of production telemetry.