What a Streamed Response Costs, Token by Token
A streamed answer appears gradually, but its animation is not an invoice. To understand what one response costs, follow a single request from its input through generation to the final usage record. This walkthrough separates a useful live estimate from the amount you should ultimately reconcile.
§1 Step 1: Count the Complete Request
Start before the first visible response token. Input includes more than the latest question: message structure, supplied conversation history, tool definitions, and attached content can affect the count. A token can represent part of a word, a whole word, or punctuation, so counting words is not an exact substitute. Use the target model’s tokenizer or supported input-counting endpoint. ([help.openai.com](https://help.openai.com/articles/4936856))
For our worked example, assume the complete request contains 2,000 input tokens. Treat that number as a measured request total, not an estimate based only on the text inside the chat box.
§2 Step 2: Assign a Price to Each Token Category
Token-based pricing can distinguish ordinary input, cached input, and output. Do not multiply the combined token total by a single rate unless the selected pricing schedule actually uses one. Other capabilities may have separate billing units. ([help.openai.com](https://help.openai.com/articles/4936856))
For arithmetic only, assume hypothetical rates of $2 per million input tokens and $8 per million output tokens, with no cached input or additional charges. These are illustrative rates, not advertised prices for Fluxio or any model.
The input component is 2,000 × $2 ÷ 1,000,000 = $0.004. Each output token adds $0.000008 under these assumptions. That gives us a running estimate before we reconcile actual usage.
§3 Step 3: Track Output Without Counting Stream Events
Streaming delivers incremental updates rather than one completed response. In Chat Completions, those updates are chunks containing deltas; some carry metadata rather than answer text. Consequently, counting received events is not a reliable way to count billable tokens. ([developers.openai.com](https://developers.openai.com/api/reference/resources/chat/subresources/completions/streaming-events))
Suppose generation reaches the following output-token counts. Our hypothetical running totals become:
- – At 100 output tokens, the output component is $0.0008 and the combined estimate is $0.0048.
- – At 300 output tokens, the output component is $0.0024 and the combined estimate is $0.0064.
- – At 600 output tokens, the output component is $0.0048 and the combined estimate is $0.0088.
Label a live counter estimated cost. Avoid rounding each update to cents: all three examples would lose meaningful precision.
§4 Step 4: Capture the Final Usage Record
For OpenAI Chat Completions, enable streaming and request usage through stream_options with include_usage set to true. An additional final chunk reports usage for the entire request, and its choices array is empty. Do not discard that chunk just because it contains no answer text. Verify equivalent support when using a compatible relay. ([help.openai.com](https://help.openai.com/en/articles/10478918-reviewing-api-usage-and-costs))
Also inspect detailed categories where available. OpenAI documents that internal reasoning tokens can count toward billed output even though they are not displayed. Cached input can have different pricing. Do not add reasoning tokens twice if they are already included in the output total. ([help.openai.com](https://help.openai.com/articles/4936856))
§5 Step 5: Reconcile Interrupted Streams and Retries
An interrupted stream may never deliver its final usage chunk. Missing usage therefore does not establish zero consumption. Mark that request as unresolved and reconcile it against provider-side usage records rather than silently recording a free response. ([help.openai.com](https://help.openai.com/en/articles/10478918-reviewing-api-usage-and-costs))
Give each retry its own attempt identifier beneath the original user action. Record the selected model, reported token categories, applicable rates, completion status, and calculated cost. This makes repeated attempts visible instead of hiding them behind one successful answer.
§6 Step 6: Compare Complete Tasks Through Fluxio
Fluxio fits teams seeking a streaming-first, pay-per-token AI API relay with one key across multiple model providers. Use the same accounting checklist when evaluating Gemini 2.5 Flash and Claude Haiku 4.5, without assuming either has the hypothetical rates above.
Compare complete task costs alongside answer quality, not merely the advertised price per million tokens: tokenization and generated output can differ between models. Keep application hosting and observability expenses separate from the token subtotal. ([help.openai.com](https://help.openai.com/articles/4936856))
Sign up for Fluxio.