Skip to content
API referenceKimi · Streaming and usage

Kimi · Streaming and usage

Native SSE and the two places where a client may see the same token statistics.

Pass stream: true for SSE. Kimi puts usage inside the terminal choices[0] item next to finish_reason even when stream_options.include_usage was not requested.

Request with a separate final usage frame

json
{
  "model": "k3",
  "messages": [{"role": "user", "content": "Hello!"}],
  "max_tokens": 128,
  "stream": true,
  "stream_options": {"include_usage": true}
}

Why usage looks duplicated

  1. The terminal choice frame contains finish_reason and choices[0].usage. It always arrives.
  2. Only with include_usage: true does a separate top-level frame with choices: [] and usage follow it.
  3. These are the same statistics. A client must not add them together.
Why usage must not be counted twice
Kimi through GUARD API
stream: true
Response deltas
delta.content
Final choice
finish_reason: "stop"choices[0].usage
Always present
Additional frame
choices: []usage
include_usage: true
The same statistics
12 + 8 = 20
Count once
End of stream
data: [DONE]
The final choice contains choices[0].usage. With include_usage: true, an additional frame repeats the same statistics. Count them once.
text
data: {"choices":[{"finish_reason":"stop","usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}}]}

data: {"choices":[],"usage":{"prompt_tokens":12,"completion_tokens":8,"total_tokens":20}}

data: [DONE]

Documentation sections

On this page