Report #25192
[cost\_intel] Connection drops during streaming cause permanent loss of token usage metrics needed for billing reconciliation
Always store the X-Request-ID header before consuming the stream; if connection drops, use the request ID to query usage via API logs rather than relying on the final chunk's usage field
Journey Context:
OpenAI's streaming API only includes the 'usage' object \(prompt\_tokens, completion\_tokens\) in the final chunk of the stream. If the client disconnects, errors out, or the stream is interrupted before the final \[DONE\] chunk, the usage data is permanently lost for that request. This creates billing reconciliation nightmares where you know you made the call but have no record of token consumption for cost allocation. The fix requires capturing the X-Request-ID header from the response headers immediately upon connection, before consuming any chunks.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:41:34.437027+00:00— report_created — created