In this article
Reconcile the usage recorded for interrupted requests independently of successful completions. Preserve the data source and distinguish unknown usage from a confirmed zero.
When a user stops a streamed response, the application stops receiving text. The provider may already have processed the input and generated additional output. LiteLLM v1.108.20, published on 27 November, lists fixes for cancelled OpenAI and Azure /v1/responses streams that had recorded nothing or used an estimate instead of provider usage. This is a change to the gateway’s accounting path. It establishes neither a uniform cancellation policy across providers nor a refund mechanism.
Follow usage instead of counting visible tokens
A client can count character or token fragments that it received, but that count has gaps. It can miss an input charge, cached input categories, hidden reasoning, or output produced between the last frame received and cancellation. When the provider reports a usage record, keep its request ID and original fields. Keep estimates in a different field, and leave genuinely missing usage unresolved until reconciliation.
Check cancellation at three points
In a test environment, cancel before the first text frame, midway through generation and just before normal completion. Match the gateway row to the provider’s usage data using a request ID and deployment. Compare usage fields and cost independently. Run a normal completion alongside the cancelled cases as a control. Where a provider row arrives late, check again after the billing system has had time to ingest it.
Make cancellation visible in budget reports
A product team may cancel slow responses or supersede them when a user resubmits a prompt. Group usage by normal completion, client cancellation and retry so that the cost of those choices is visible. Pay particular attention to regions or accounts that use different Azure deployments. For an upgrade, require reconciliation to preserve both the amount and its provenance. A falling estimated spend in a dashboard can reflect a measurement gap even when provider charges are steady.
What a cancellation dashboard should show
Show the share of cancelled calls with verified provider usage and the outstanding amount separately. Include the interval from cancellation to final reconciliation. A common failure mode is to count a completed transport close as a successful charge record even though the usage source never arrived. Compare results across clients that cancel by closing a browser stream and callers that cancel through an application service, because those paths can reach the gateway differently.
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.