Summary
When calling the OpenAI-compatible /v1/chat/completions endpoint without explicitly specifying the stream parameter, the server appears to default to stream: true.
This behavior is not aligned with the OpenAI API convention, where omitting stream defaults to non-streaming (false).
As a result, OpenAI-compatible clients (e.g. .NET SDKs) that omit the stream field receive SSE (data:) responses instead of JSON, causing deserialization failures.
Steps to reproduce
- Load a model via:
- Call:
POST /v1/chat/completions
with body:
{
"messages": [
{ "role": "user", "content": "Hello" }
]
}
(note: no stream field)
Expected behavior
- Response is standard JSON:
Actual behavior
- Response is streamed using SSE format:
{"id":"chatcmpl-bec20bc3c001","object":"chat.completion.chunk" ...}
{"id":"chatcmpl-bec20bc3c001","object":"chat.completion.chunk" ...}
- This causes failures in clients expecting JSON (e.g.
System.Text.Json errors like):
'd' is an invalid start of a value
Additional context
produces correct JSON output.
produces expected streaming output.
- The issue only occurs when the
stream field is omitted.
Impact
- Breaks compatibility with OpenAI SDKs and abstractions (e.g. Microsoft .NET clients), which omit
stream when non-streaming is intended.
- Requires consumers to always explicitly set
"stream": false, which is not expected behavior.
Suggested fix
Default stream to false when the field is not provided, to match OpenAI API behavior.
Environment
- Unsloth Studio (local)
- Endpoint:
http://localhost:8888/v1/chat/completions
- Tested via Postman and .NET OpenAI client
Thanks for the great work on the OpenAI-compatible API — this small fix would significantly improve interoperability.
Summary
When calling the OpenAI-compatible
/v1/chat/completionsendpoint without explicitly specifying thestreamparameter, the server appears to default tostream: true.This behavior is not aligned with the OpenAI API convention, where omitting
streamdefaults to non-streaming (false).As a result, OpenAI-compatible clients (e.g. .NET SDKs) that omit the
streamfield receive SSE (data:) responses instead of JSON, causing deserialization failures.Steps to reproduce
with body:
{ "messages": [ { "role": "user", "content": "Hello" } ] }(note: no
streamfield)Expected behavior
{ "choices": [...] }Actual behavior
{"id":"chatcmpl-bec20bc3c001","object":"chat.completion.chunk" ...} {"id":"chatcmpl-bec20bc3c001","object":"chat.completion.chunk" ...}System.Text.Jsonerrors like):Additional context
produces correct JSON output.
produces expected streaming output.
streamfield is omitted.Impact
streamwhen non-streaming is intended."stream": false, which is not expected behavior.Suggested fix
Default
streamtofalsewhen the field is not provided, to match OpenAI API behavior.Environment
http://localhost:8888/v1/chat/completionsThanks for the great work on the OpenAI-compatible API — this small fix would significantly improve interoperability.