mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[GH-ISSUE #23927] fix: Inject stream_options for Anthropic OpenAI-compat endpoint to include usage in SSE #35642
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pvyswiss on GitHub (Apr 21, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/23927
Bug Description
When streaming from Anthropic's OpenAI-compatible endpoint without
stream_options: {"include_usage": true}, the final SSE chunk contains nousagefield. The middleware'snormalize_usagefinds nothing.Related to: #23917 (Bug 7)
Root Cause
Anthropic's
/v1/chat/completionssupportsstream_optionsbut only returns usage when explicitly requested. Open WebUI doesn't inject it -- relies on the client. The Web UI browser sends it, but API scripts and plugins don't.Fix
setdefaultpreserves client-provided values.Impact
stream_options)File
backend/open_webui/routers/openai.py@tjbck commented on GitHub (Apr 24, 2026):
Intended behaviour.