Skip to content

Streaming chat completions now support usage detail.

Compare
Choose a tag to compare
@jamesrochabrun jamesrochabrun released this 10 Jun 18:39
· 14 commits to main since this release
e8b912b

On June 6th OpenAI announced that streaming chat completions now support usage details. Previously, usage details were only available on non-streaming chat completions.
This patch makes streaming chat completions default to include usage details. The final chunk of each streaming response looks like this (note the prompt_tokens, completion_tokens, and total_tokens lines):
data: {"id":"chatcmpl-9YM1lpTbJLDBnrawPqt2CjT3gnoVA","object":"chat.completion.chunk","created":1717974853,"model":"gpt-4o-2024-05-13","system_fingerprint":"fp_319be4768e","choices":[],"usage":{"prompt_tokens":11,"completion_tokens":20,"total_tokens":31}}