Skip to content

docs: include_usage streaming behavior rewritten in Chat and FIM Completion APIs - #17

Open
github-actions[bot] wants to merge 1 commit into
mainfrom
docs/sync
Open

docs: include_usage streaming behavior rewritten in Chat and FIM Completion APIs#17
github-actions[bot] wants to merge 1 commit into
mainfrom
docs/sync

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

The include_usage streaming contract changed on both the Chat Completions and FIM Completion (Beta) API reference pages. The docs previously promised that setting include_usage: true streamed a separate usage-only chunk (empty choices array) just before data: [DONE]. They now describe a different response shape: no extra chunk is emitted at all, and the full-request token statistics ride on the final content chunk. Any client that parses streams by hunting for a dedicated usage chunk — or that keys off an empty choices array to find it — needs to re-check its parsing logic against the new shape.

  • include_usage: true → every chunk carries a usage field, null on all but the last; omitted/false → usage is absent from every chunk except the last. Either way, no separate usage-only chunk is emitted.
  • The last chunk before data: [DONE] carries the request's token-usage stats in usage, and its choices array always contains exactly one element: no new content, non-null finish_reason.
  • Changed on both create-chat-completion and create-completion (FIM Beta) in en and zh-cn, so both API families are affected.
  • fetched: dates bumped to 2026-08-26; index churn only otherwise. One metadata note: zh-cn/news/news250120 now records a fallback-shell error, meaning that page's title could not be fetched — content of the article itself is unchanged.

…letion APIs

The `include_usage` streaming contract changed on both the Chat Completions and FIM Completion (Beta) API reference pages. The docs previously promised that setting `include_usage: true` streamed a *separate usage-only chunk* (empty `choices` array) just before `data: [DONE]`. They now describe a different response shape: no extra chunk is emitted at all, and the full-request token statistics ride on the final content chunk. Any client that parses streams by hunting for a dedicated usage chunk — or that keys off an empty `choices` array to find it — needs to re-check its parsing logic against the new shape.

- `include_usage: true` → every chunk carries a `usage` field, `null` on all but the last; omitted/false → `usage` is absent from every chunk except the last. Either way, no separate usage-only chunk is emitted.
- The last chunk before `data: [DONE]` carries the request's token-usage stats in `usage`, and its `choices` array always contains exactly one element: no new content, non-null `finish_reason`.
- Changed on both `create-chat-completion` and `create-completion` (FIM Beta) in en and zh-cn, so both API families are affected.
- `fetched:` dates bumped to 2026-08-26; index churn only otherwise. One metadata note: `zh-cn/news/news250120` now records a fallback-shell error, meaning that page's title could not be fetched — content of the article itself is unchanged.
@github-actions github-actions Bot changed the title docs: include_usage streaming behavior rewritten: usage rides on the last content chunk, no separate usage-only chunk docs: include_usage streaming behavior rewritten in Chat and FIM Completion APIs Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants