﻿# How should a gateway account for cancelled Responses API streams?

LiteLLM v1.108.20 changed cost accounting for cancelled OpenAI and Azure Responses streams. Here is how to reconcile gateway and provider usage without guessing.

Author: Retrivium editorial team
Updated: 2026-11-28
Canonical URL: https://retrivium.ai/journal/daily-20261128-routing-litellm-provider-usage-after-cancel/
Language: en

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

- [Primary source · litellm v1.108.20](https://github.com/BerriAI/litellm/releases/tag/v1.108.20)
- [Primary source · litellm #54755](https://github.com/BerriAI/litellm/pull/54755)
- [Primary source · litellm #54772](https://github.com/BerriAI/litellm/pull/54772)

## Related reading

- [Related guide · Openrouter usage accounting](/journal/openrouter-usage-accounting/)
- [Related guide · Openrouter streaming client](/journal/openrouter-streaming-client/)
