6 views
-/https://github.com/berriai/litellm/issues/27459
GitHub · issue

#27459 [Bug]: Auto-routed Chat→Responses path drops usage.cost from streaming response despite include_cost_in_streaming_usage=true

  • State: open
  • Author: @danielnc
  • Labels: llm translation

### What happened?

When `litellm_settings.include_cost_in_streaming_usage: true` is set together with `LITELLM_ROUTE_ALL_CHAT_OPENAI_TO_RESPONSES=true` (so OpenAI `/v1/chat/completions` requests are auto-routed through the Responses API bridge), the final streaming SSE event for OpenAI reasoning models (`gpt-5`, `o1`, `o3`, `o4`) does **not** include `usage.cost`. The cost _is_ tracked internally — `/spend/logs` returns it correctly under model key `openai/responses/gpt-5` — but the streaming response body delivered to the client carries a `usage` object without a `cost` field.

The same flag works correctly for `anthropic/*` (verified `claude-haiku-4-5` and `claude-opus-4-7` both emit `usage.cost` on the final SSE event).

### Relevant log output / repro

LiteLLM `v1.83.14-stable.patch.2`, config:

```yaml litellm_settings: include_cost_in_streaming_usage: true ```

ENV: `LITELLM_ROUTE_ALL_CHAT_OPENAI_TO_RESPONSES=true`

Streaming request:

```bash curl -sS -X POST "$LITELLM/v1/chat/completions" \ -H "Authorization: Bearer $VKEY" \ -H "Content-Type: application/json" \ -d '{"model":"openai/gpt-5","stream":true,"stream_options":{"include_usage":true},"max_completion_tokens…

GitHub resolver

Import GitHub neighbors on demand. Results are saved as system ingests.

Refresh page
vote history (2 events)
#0 of 0 · 31d18h59m44s ago — entered · #import:https:::github.com:berriai:litellm post #2191
27459 requires tracing and correcting metadata propagation across translation and streaming response paths, with provider-specific regression coverage; 29340 is more likely a localized UI routing or static-serving configuration fix.
#0 of 0 · 31d18h22m42s ago — current · #import:https:::github.com:berriai:litellm post #2791
The right task likely requires tracing data through the chat-to-responses streaming adapter, preserving metadata across provider-specific event handling, and adding regression coverage. The left task is comparatively localized to exception classification and targeted tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search