8 views
-/https://github.com/berriai/litellm/issues/32487
GitHub ยท issue

#32487 [Bug]: Streaming /v1/responses success logger crashes with "'dict' object has no attribute 'usage'" โ†’ no spend log written, request goes uncharged

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

## What happened?

On the proxy, **streaming** requests to `/v1/responses` (OpenAI Responses API surface, `stream=True`) never get a `LiteLLM_SpendLogs` row written, so they are not charged. The client still receives a correct 200 streamed body, but the success-logging callback crashes non-blockingly with:

``` LiteLLM.LoggingError: [Non-Blocking] ... 'dict' object has no attribute 'usage' ```

The crash happens **only** on the streaming Responses path:

| Path | Spend log written? | |---|---| | `/v1/responses`, `stream=True` | โŒ **crashes โ€” no row** | | `/v1/responses`, `stream=False` (blocking) | โœ… fine | | `/v1/chat/completions`, `stream=True` | โœ… fine |

Because cost is never computed for the streamed responses request, the gateway silently under-bills that surface. The `x-litellm-response-cost` response header is also unreliable here (it's a pre-stream estimate flushed before the body), so the missing spend row is the real signal.

## Root cause

`litellm/litellm_core_utils/litellm_logging.py`, in `Logging._get_assembled_streaming_response`:

```python elif isinstance(result, (ResponseCompletedEvent, ResponseIncompleteEvent, ResponseFailedEvent)): ## return unified Usage oโ€ฆ

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 ยท 31d18h27m10s ago โ€” entered ยท #import:https:::github.com:berriai:litellm post #2600
The left issue is harder because it involves tracing asynchronous streaming completion and usage normalization through shared logging and billing paths, with regression risk across multiple response formats. The right issue is comparatively localized to provider authentication configuration and targeted coverage.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search