In this article
Replay content, finish and usage events through the real client parser; removing an empty post-finish choice must preserve final usage and provider cost.
LiteLLM v1.111.0-dev.4 includes an OpenRouter streaming fix for an empty choice emitted after finish_reason: stop. The November 15 prerelease preserves the later usage information while removing the misleading choice. Clients that separate answer completion from final accounting should test the exact event sequence rather than only the assembled text.
Capture events before assembling the answer
Use a synthetic stream containing content, a terminal finish and the provider’s accounting trailer. Record normalized chunks as well as the final string. An answer-only assertion cannot reveal an extra assistant choice, because that choice may contain no text. The fixture should check event types and order, including whether the accounting chunk retains usage and cost after normalization by the gateway.
Completion does not end every bookkeeping task
A user interface may stop showing generation when it sees finish while its request consumer still waits for usage. Model those two states explicitly. Check that the final answer becomes visible promptly and that accounting completes once. Avoid reopening an assistant message when a post-finish event arrives. This application behavior remains necessary even after the gateway suppresses the particular empty choice described in the release.
Keep usage-free streams as a control
Repeat parsing with a stream that has no usage trailer and with one interrupted before finish. These cases should not be confused with the corrected provider trailer. A robust consumer can report unknown accounting without inventing zero usage. Use the same client adapter as the application, because a passing raw event test does not establish that its SDK or frontend wrapper preserves the relevant metadata.
Reconcile one request across views
Bind the stream capture, client result and spend record to one request identity. Assert a single completed answer and the expected final accounting. The change is about normalized event shape, not model quality or a universal streaming speedup. Pin the prerelease in the evidence and keep the provider-shaped regression fixture so a later adapter update cannot silently reintroduce the same parser ambiguity.
Sources
Related reading
Earn rental income from GPUs
Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.