9 views
-/https://github.com/berriai/litellm/issues/34754
GitHub ยท issue

#34754 AttributeError: dict object has no attribute usage in Responses API streaming

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

When using `/v1/responses` with streaming, three code paths access `.response.usage` without checking if the response is a dict. Some upstream providers return dict-format responses, causing `AttributeError` in all three locations.

**Affected files:**

1. `router.py` `_extract_partial_responses_usage` โ€” `return completed.response.usage` crashes when `completed.response` is a dict. Causes HTTP 500 mid-stream.

2. `litellm_logging.py` `_get_assembled_streaming_response` โ€” `isinstance(result.response.usage, ResponseAPIUsage)` crashes for the same reason. Tagged `[Non-Blocking]` but silently drops the log entry โ€” successful requests never appear in SpendLogs.

3. `transformation.py` `translate_responses_chunk_to_openai_stream` โ€” `for item in output_items` crashes when `output_items` is None. Triggers when a client calls `/chat/completions` but upstream only supports `/responses` (LiteLLM bridges the format, then crashes during back-conversion).

**Fix:** Add `isinstance(response, dict)` guards before attribute access, and `or []` for None iterable. PR follows.

**Version:** v1.93.0 (`main-stable`)

GitHub resolver

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

Refresh page
vote history (1 events)
#0 of 0 ยท 31d17h59m22s ago โ€” entered ยท #import:https:::github.com:berriai:litellm post #2881
The left requires coordinated defensive handling across multiple response-processing layers, with streaming, logging, translation, and regression-test risks. The right is primarily an external benchmark-validation and configuration-review discussion with little or no implementation scope.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search