Repository navigation
Description
▎ Note: this is an inference/serving issue with the OpenAI-compatible /v1/chat/completions endpoint, not a training run — so the notebook/trainer questions are N/A. Added a "Serving command" line since the template doesn't have one.
- Did you update? pip install --upgrade unsloth unsloth_zoo →
- Colab or Kaggle or local / cloud → Local — self-hosted OpenAI-compatible server at http://localhost:8888 (<local box or cloud VM?>)
- Number GPUs used, use nvidia-smi → 1
- Which notebook? Please link! → N/A
- Which Unsloth version, TRL version, transformers version, PyTorch version? → unsloth v0.1.47-beta
- Which trainer? SFTTrainer, GRPOTrainer etc → N/A — no trainer; bug is in the OpenAI-compatible /v1/chat/completions serving endpoint.
Serving command / method (added — essential for this bug): <exact command or Docker image+tag used to serve unsloth/gemma-4-12b-it-GGUF on :8888, e.g. the unsloth serve / llama.cpp / vLLM invocation>
Minimal repro: a NON-streaming request still comes back as an SSE stream.
No Hugging Face token needed (this is a serving call). Redact any local server key.
import requests
BASE_URL = "http://localhost:8888/v1" # unsloth.ai-served endpoint
API_KEY = "REDACTED" # local server key if required — do NOT paste a HF token
payload = {
"model": "unsloth/gemma-4-12b-it-GGUF",
"messages": [{"role": "user", "content": "ping"}],
"max_tokens": 1,
"stream": False, # <-- explicitly non-streaming
}
resp = requests.post(
f"{BASE_URL}/chat/completions",
headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"},
json=payload,
)
print("Content-Type:", resp.headers.get("content-type"))
print("Body:\n", resp.text)
print(resp.json()) # <-- raises JSONDecodeError: body is an SSE stream, not a JSON object
Summary
With "stream": false, the OpenAI-compatible endpoint still returns a Server-Sent Events stream (data: {…} chunks of object: "chat.completion.chunk", ending in data: [DONE]) instead of a single chat.completion JSON object.
Non-streaming clients/SDKs that call resp.json() fail, breaking OpenAI API compatibility.
Actual behavior
data: {"id":"chatcmpl-15d67ad1b5a5","object":"chat.completion.chunk","created":1782132847,"model":"unsloth/gemma-4-12b-it-GGUF","choices":[{"index":0,"delta":{"role":"assistant"}}]}
data: {"id":"chatcmpl-15d67ad1b5a5","object":"chat.completion.chunk","created":1782132847,"model":"unsloth/gemma-4-12b-it-GGUF","choices":[{"index":0,"delta":{"content":"**"}}]}
data: {"type": "tool_status", "content": ""}
data: {"id":"chatcmpl-15d67ad1b5a5","object":"chat.completion.chunk","created":1782132847,"model":"unsloth/gemma-4-12b-it-GGUF","choices":[{"index":0,"delta":{},"finish_reason":"length"}]}
data: [DONE]
Content-Type appears to be text/event-stream (<confirm with curl -i>).
Expected behavior
With "stream": false, a single JSON object with Content-Type: application/json and object: "chat.completion", per the OpenAI Chat Completions spec (stream defaults to false):
{"id":"chatcmpl-...","object":"chat.completion","model":"unsloth/gemma-4-12b-it-GGUF",
"choices":[{"index":0,"message":{"role":"assistant","content":"..."},"finish_reason":"length"}],
"usage":{"prompt_tokens":0,"completion_tokens":1,"total_tokens":0}}
Impact
Breaks every non-streaming OpenAI-compatible integration (SDKs with stream=False, gateways, health checks). Streaming clients are unaffected, which masks the issue during normal chat use.
Additional note (possibly related)
A non-standard event is emitted that isn't part of the OpenAI streaming schema (no id/object/choices): data: {"type": "tool_status", "content": ""}. Strict parsers may reject it even in streaming mode.
Activity
oobabooga commentedon Jun 23, 2026
I can't reproduce the issue, see this example showing that stream: false gets respected:
Running it here against gemma-4-12b:
This looks like it was already fixed (#5047 / #5524), and you're on v0.1.47-beta -- could you update to the latest and check again? If it still happens, run the script and let me know what Content-Type you get.
mtbitcoin commentedon Jun 23, 2026
After digging around a little bit (and testing different runtime settings) this is what i observed. Passing in the model parameter like the below breaks the streaming :
unsloth studio run --model 'unsloth/gemma-4-12b-it-GGUF:UD-Q5_K_XL' (breaks the stream=false settings)
unsloth studio -H 0.0.0.0 -p 8888 (then switching the model to the above model from inside unsloth studio, works)
In the past (before the recent updates) i was able to pass in the run --model 'xxx' without issues. But with with the recent releases this breaks. Its not really a big issue but the health check features from certain application like LiteLLM etc which expect a non streaming chat shows it the as an unhealthy instance
I am currently able to get around this by just running without the model parameter and then switching it manually from unsloth studio gui.
Studio: dedup the unslothai#6570 non-streaming tool tests and cover c…
Studio: cover the cached_tokens metadata fix and clarify the drain co…
Studio: align the GGUF tool drain naming and tighten its comment (uns…
Studio: honor `stream=false` on the GGUF agentic tool path (#6570) (#…
Keep non-streaming tool requests working under the auto default
Studio: default tool-call permission to Approve for me, prompt only o…