BerriAI/litellm · error · ValueError
Chat provider: Invalid text delta {parsed_chunk}
Error message
Chat provider: Invalid text delta {parsed_chunk} What it means
For response.output_text.delta events the transformer requires a non-None 'delta' field with the text fragment; if the event lacks it, it raises. Symmetric to the function-arguments case: the provider streamed a text-delta event without any text payload.
Source
Thrown at litellm/completion_extras/litellm_responses_transformation/transformation.py:1381
)
]
)
elif event_type == "response.output_text.delta":
# Content part added to output
content_part = parsed_chunk.get("delta", None)
if content_part is not None:
return ModelResponseStream(
choices=[
StreamingChoices(
index=0,
delta=Delta(content=content_part),
finish_reason=None,
)
]
)
else:
raise ValueError(f"Chat provider: Invalid text delta {parsed_chunk}")
elif event_type == "response.reasoning_summary_text.delta":
content_part = parsed_chunk.get("delta", None)
if content_part:
return ModelResponseStream(
choices=[
StreamingChoices(
index=cast(int, parsed_chunk.get("summary_index")),
delta=Delta(reasoning_content=content_part),
)
]
)
elif event_type == "response.completed":
# Response is fully complete - now we can signal is_finished=True
# This ensures we don't prematurely end the stream before tool_calls arrive
# Check if response contains function_call items in output
# to determine correct finish_reason
response_data: Final = parsed_chunk.get("response", {})View on GitHub (pinned to 6c2dcb801b)
Solutions
- Drop text-delta events whose delta is None before transformation
- Treat delta == '' as valid (it is) — only None/missing trips the error
- Update or report the gateway producing the malformed event
Example fix
# before
for ev in events:
chunks = transformer.chunk_parser(ev, ...)
# after
for ev in events:
if ev.get("type") == "response.output_text.delta" and ev.get("delta") is None:
continue
chunks = transformer.chunk_parser(ev, ...) Defensive patterns
Strategy: validation
Validate before calling
def text_delta_event_valid(ev: dict) -> bool:
return ev.get("type") != "response.output_text.delta" or ev.get("delta") is not None Try / catch
try:
out = transformer.chunk_parser(ev, ...)
except ValueError as e:
if "Invalid text delta" in str(e):
out = None # tolerate empty text-delta events
else:
raise Prevention
- Drop text-delta events with delta=None before transforming
- Record and diff provider SSE streams against OpenAI's in integration tests
When it happens
Trigger: A response.output_text.delta event arrives with delta missing or None — non-conformant providers, proxies rewriting events, or malformed fixtures.
Common situations: Gateway emulation quirks; recorded SSE fixtures missing fields; providers that emit empty text deltas as null instead of empty strings.
Related errors
- Chat provider: Invalid function argument delta {parsed_chunk
- Chat provider: Empty parsed_chunk
- Chat provider: Invalid chunk type {type(parsed_chunk)}
- Braintrust API error: {e.response.text}
- Failed to connect to Braintrust API: {str(e)}
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/874fa668484d5a97.
Report an issue: GitHub.