litellm/tests/test_litellm/llms/openai/chat
Yassin Kortam cb3a7accdd
fix(streaming): surface in-body error payloads on OpenAI-compatible streams (#32237)
* fix(streaming): surface in-body error payloads on OpenAI-compatible streams

vLLM and sglang return HTTP 200 streams whose SSE body carries the error,
e.g. data: {"error": {"message": "...", "code": 400}}. The OpenAI-compatible
chunk parser had no detection for this shape: since #23931 the payload parsed
into an empty chunk (choices=[]) and the stream ended silently with 200,
losing the provider's error and never attempting configured fallbacks.

Detect the payload in OpenAIChatCompletionStreamingHandler.chunk_parser and
raise OpenAIError with the upstream message and status code. The existing
mid-stream gate then applies: 4xx surface directly to the client, 5xx wrap
into MidStreamFallbackError so the router can run configured fallbacks.

Fixes #25492

* fix(streaming): serialize messageless error payloads as JSON

Address review feedback: an error dict without a message field now
serializes via json.dumps instead of Python dict repr
2026-07-06 08:13:25 -07:00
..
guardrail_translation Litellm OSS Staging 010626 (#29422) 2026-06-01 21:42:51 -07:00
__init__.py Guardrail API - support tool call checks on OpenAI /chat/completions, OpenAI /responses, Anthropic /v1/messages (#17459) 2025-12-03 21:20:39 -08:00
test_openai_gpt_transformation.py fix(streaming): surface in-body error payloads on OpenAI-compatible streams (#32237) 2026-07-06 08:13:25 -07:00