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-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 API191streaming28cost design5idempotency5mobile6

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 $10 for lifetime access
View Membership →

Related Articles

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.
API / SDK2026-07-03
A Webhook Is a Claim, Not a Fact — Three Layers of Defense for Your Gemini Webhooks Endpoint
Your Gemini Webhooks receiver is a public URL, which means forged events, replays, and duplicate deliveries are all on the table. This walkthrough builds a three-layer defense — reachability checks, dedupe, and a lightweight handler that re-fetches truth from the API — with working FastAPI and SQLite code.
API / SDK2026-05-26
Why Gemini API Streaming Drops on iOS After Backgrounding — and How to Fix It
When your iOS app receives a streaming response from Gemini API and the user briefly switches to another app, the stream often goes silent forever. Here's how URLSession actually treats long-lived HTTP, and the smallest change that brings reliability back.
📚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 →