GEMINI LABJP
ROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 termsROBOTICS — The ER 1.6 preview that shut down on August 31 does have a successor. Gemini Robotics ER 2 is in public preview, in both standard and streaming variantsVIDEO — ER 2 judges success and failure from live video rather than still snapshots, which is what lets it catch spills, slips, and misalignments while a task is still runningDEADLINE — Next up is September 30, when gemini-omni-flash-preview is retired. The target is gemini-omni-1.1-flash, GA since August 27, and there are now under four weeks leftAPIKEY — Every remaining standard API key, restricted ones included, stops working during September. The replacement is an auth key bound to a Google Cloud service accountPRICE — Gemini 3.7 Flash keeps its introductory $0.75/$3.75 per 1M through December 31, then moves to $1.50/$7.50 on January 1, 2027. Any estimate crossing the year needs both figuresAUDIO — Gemini 3.5 Transcribe handles language detection across 85+ languages, speaker diarization, word-level timestamps, and custom vocabulary biasing of up to 1,000 terms
Articles/API / SDK
API / SDK/2026-07-17Advanced

A Gemini stream drops halfway — restart it, or have the model continue?

Most apps silently restart a dropped stream. Here is the arithmetic behind continuing from the partial output instead, and where to put the threshold.

Gemini API229streaming28cost design7idempotency5mobile6

Premium Article

My train pulled into a station and the text my app was generating stopped mid-sentence. The app quietly started over, and the same opening paragraph scrolled past a second time.

What stuck with me was not the wait. It was that the 600 tokens of prose that had just vanished were almost certainly billed. The user never saw a word of it, and a second generation was already underway.

Google's Southeast Asia report put roughly three quarters of Gemini app requests on mobile. Flaky connections are not an edge case you handle later; they are the normal operating condition. As an indie developer shipping Gemini into mobile apps, I have stopped treating a dropped stream as an anomaly.

Why streams drop is a separate investigation. This piece is about the decision you make afterwards.

You cannot tell how much a dropped stream cost you

The usageMetadata block on streamGenerateContent arrives near the end of the chunk sequence. If you receive the stream to completion, you get exact input, output, and thinking token counts.

Which means that for the attempt that died, you get nothing. The client has no way to confirm how far generation had progressed when the connection dropped.

And what happens server-side when a client disconnects — whether generation stops immediately, whether billing stops with it — is not spelled out in the public documentation.

Assuming "probably not billed" quietly corrupts your design. I work on the assumption that every chunk I received was paid for. That is not pessimism so much as refusing to round an unknown in my own favour.

SituationusageMetadataActual billing
Stream completesAvailableKnown exactly
Connection dropsNever arrivesUnknown — assume the worst
Client cancelsNever arrivesUnknown (same)

If you cannot measure the spend, at least count the events. Logging each disconnect with the number of characters already received costs nothing and pays off later.

Restarting and continuing have different cost shapes

Let P be the prompt tokens, O the output tokens needed to finish, and R the output tokens you received before the drop. Let Ci be the input rate and Co the output rate.

The dead attempt (Ci×P + Co×R) is spent either way. The difference shows up in what comes next.

ApproachSecond inputSecond outputWhat you throw away
RestartPOThe R tokens you already have
ContinueP + RO − RA clean seam

Subtract one from the other:

restart − continue
 = (Ci×P + Co×O) − (Ci×(P+R) + Co×(O−R))
 = Co×R − Ci×R
 = R × (Co − Ci)

Gemini prices output above input, so Co − Ci is positive and continuing is always nominally cheaper.

Read the formula more carefully, though. The saving scales with R. At R = 60 tokens you save 60 × (Co − Ci), which will not repay the code you are about to write.

Deciding "always continue" on cost alone misreads this result. Continuation earns its keep only when R is large — when a long piece of prose died near the end.

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 can replace blanket retries with a rule that decides per drop whether to reuse the text you already received
You can plug your own pricing into R × (output rate − input rate) and see whether continuation is worth building at all
You can fix the three seam defects — restatement, tonal steps, renumbered lists — before they reach users
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-08-01
When Sampling Parameters Were Deprecated, Diversity Broke Before Determinism Did
Deprecating temperature, top_p and top_k hurt the diversity-generating side of my pipeline, not the deterministic side. Counting real call sites, moving diversity to the input layer, and measuring effective diversity.
API / SDK2026-07-19
Still image or short clip? Deciding feature placement from the cost gap between Nano Banana 2 Lite and Omni Flash
When I froze over whether a wallpaper app's hero asset should be a still image or a short moving loop, the deciding factor was not taste but the order of magnitude of the cost. Here is how to normalize Nano Banana 2 Lite and Omni Flash onto the same footing, down to a working decision function.
API / SDK2026-07-05
Splitting Bulk Image Generation Cost in Two with Nano Banana 2 Lite: A Draft-and-Render Design
A two-tier cost design that routes first-pass generation to Nano Banana 2 Lite and final renders to the standard Nano Banana 2, with a minimal Python router you can adapt.
📚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 →