Home → Help
usage is null on every chunk of a streamed responseToken counts appear for non-streamed calls and never for streamed onesYour own cost tracking reads zero while the provider bills normallyUsage cannot be known until generation stops, so there is nothing to put in the early chunks. Rather than send a placeholder, the API leaves the field null and adds a final chunk when the numbers exist.
That final chunk has an empty choices array. Code that stops reading as soon as it sees finish_reason, or that skips chunks with no delta, throws away the very chunk it needs.
Not every OpenAI-compatible implementation supports the option. Where it is missing you either estimate locally or read the authoritative numbers from the provider's own log.
Ask for usage and look at the last line of the stream:
curl -N 'YOUR_BASE_URL/chat/completions' \
-H 'Authorization: Bearer YOUR_KEY' -H 'Content-Type: application/json' \
-d '{"model":"MODEL","stream":true,"stream_options":{"include_usage":true},"messages":[{"role":"user","content":"hi"}]}' | tail -3
The chunk before [DONE] should carry a populated usage object with an empty choices array.
Last checked 2026-10-01. Written from problems diagnosed on a live OpenAI-compatible gateway, not collected from other sites.