Skip to navigation

Electron running usage on every streamed chunk

Electron chat completions accept stream_options.continuous_usage_stats. With include_usage: true, every streamed chunk carries a usage block with the token counts so far, not just the last one. It has no effect without include_usage.

{ "stream_options": { "include_usage": true, "continuous_usage_stats": true } }

What changed

  • continuous_usage_stats added to the chat completions API reference and the Supported Parameters page.
  • New “Running usage on every chunk” section on the Streaming page.

→ Streaming