8 views
-/https://github.com/berriai/litellm/issues/26784
GitHub · issue

#26784 [Bug] aresponses streaming on OpenAI emits Pydantic serializer warning: chat-completion Usage assigned to ResponseAPIUsage field

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

## What's going wrong

Calling `litellm.aresponses(model="gpt-4o-mini", stream=True, ...)` emits a Pydantic serializer warning during the standard logging callback:

``` UserWarning: Pydantic serializer warnings: PydanticSerializationUnexpectedValue(Expected `ResponseAPIUsage` - serialized value may not be as expected [field_name='usage', input_value={'completion_tokens': 8, ..., 'video_tokens': None}}, input_type=dict]) ```

LiteLLM also logs its own line:

``` LiteLLM:ERROR: litellm_logging.py:5553 - Error creating standard logging object - Pydantic serializer warnings: ... ```

The non-streaming call (`stream=False`) on the same model is clean. The same streaming call on `claude-haiku-4-5` and `gemini/gemini-2.5-flash` is also clean — so the issue is specific to OpenAI's streaming Responses path.

## Script to Reproduce

```python import asyncio import os import warnings

import litellm

os.environ["OPENAI_API_KEY"] = "sk-..." # replace

caught = [] def _capture(message, category, filename, lineno, file=None, line=None): caught.append((category.__name__, str(message), filename.split("/")[-1], lineno)) warnings.showwarning = _capture

INPUT_ITEMS = [ {"role": "s…

GitHub resolver

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

Refresh page
vote history (3 events)
#0 of 0 · 31d18h54m31s ago — entered · #import:https:::github.com:berriai:litellm post #1947
Issue #31831 is harder because it requires cross-cutting configuration design, timezone-aware aggregation and boundary handling, propagation across backend APIs, exports, and UI, plus migration, compatibility, and extensive consistency testing. Issue #26784 is comparatively localized to correcting a streaming response model/serialization mismatch and validating provider-specific regression behavior.
FIPS work is a cross-cutting security and dependency change with compatibility, validation, and certification risks, while the other issue is a localized serialization-path fix.
#0 of 0 · 31d17h50m24s ago — current · #import:https:::github.com:berriai:litellm post #3016
The right issue spans provider-specific streaming conversion, response-model compatibility, and callback serialization behavior, requiring broader tracing and regression coverage. The left issue is a localized route response-schema mismatch with a comparatively direct fix and focused tests.
discussed in #import:https:::github.com:berriai:litellm

ranked child groups

no voted pairs yet in this scope

cli
src
spread
search