What happened?
my openai model api backend enables stream by default, it means that my api backend responds as streaming when stream field is omitted
when I call my api backend via litellm, if I specified {stream: true} it works fine. But when i request with {stream:false} or omit stream field, litellm try to parse response as fully received json and failed:
- client request to litellm without stream field, litellm parse stream response as json failed and respond 500
- client request to litellm with {stream: false}, litellm removed stream field, and parse stream reponse as json failed, 500
- on model configuration or healthcheck page, run test or healthcheck, litellm request backend without stream field and parse stream response as json failed, 500
error example:
litellm.InternalServerError: InternalServerError: OpenAIException - Empty or invalid response from LLM endpoint. Received: 'data:{"id":"cbe99165da0d49569fc616dedd9ed517","object":"chat.completion","request_timestamp":1767773234456,"created":1767773235,"created_timestamp":1767773235676,"model":"glm-4.6","choices":[{"index":0,"finish_reason":"stop","message":{"content":"\\nThat\'s an easy one! **1 + 1 = 2**.","reasoning_content":null,"role":"assistant","tool_calls":[]},"logprobs":null}],"system_fi
ld
how to fix:
- by pass stream field if it presents
- add {stream: false} to avoid difference default streaming behavior
- parse response according to response content-type header
Relevant log output
What part of LiteLLM is this about?
Proxy
What LiteLLM version are you on ?
v1.80.11
Twitter / LinkedIn details
No response
What happened?
my openai model api backend enables stream by default, it means that my api backend responds as streaming when stream field is omitted
when I call my api backend via litellm, if I specified {stream: true} it works fine. But when i request with {stream:false} or omit stream field, litellm try to parse response as fully received json and failed:
error example:
how to fix:
Relevant log output
What part of LiteLLM is this about?
Proxy
What LiteLLM version are you on ?
v1.80.11
Twitter / LinkedIn details
No response