You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
apr serve: chat completions with array-form message content fail with HTTP 422 (Qwen Code can't use apr serve) #5919
apr serve run rejects a chat request whose message content is an array of content parts, with HTTP 422. The OpenAI Chat Completions API allows content to be either a string or an array of parts ([{"type":"text","text":"..."}]), and some clients always send the array form. Qwen Code (@qwen-code/qwen-code 0.25.3) is one of them, so it can't use apr serve as its backend at all.
curl -s -w '\nHTTP %{http_code}\n' http://127.0.0.1:8199/v1/chat/completions \
-H 'Content-Type: application/json' \
-d '{"model":"x","max_tokens":40,"messages":[{"role":"user","content":[{"type":"text","text":"What is 2+2? Answer with one number."}]}]}'
{"error":"Invalid request body. Check that the JSON structure matches the expected schema."}
HTTP 422
A system message with array content plus a tools list gives the same 422.
Through Qwen Code
OPENAI_BASE_URL=http://127.0.0.1:8199/v1 OPENAI_API_KEY=local OPENAI_MODEL=qwen3.5-4b \
qwen "What is 2+2? Answer with one number." -o json
"subtype":"error_during_execution", ... "error":{"message":"[API Error: 422 \"Invalid request body. Check that the JSON structure matches the expected schema.\"]"}
Expected
Accept content as either a string or an array of content parts, at least for "type": "text" parts (concatenated in order), as other OpenAI-compatible servers do. llama.cpp's llama-server, for example, accepts both forms. A part type the server can't handle should get a clear 400 that names the unsupported part type, not a generic 422.
Activity
noahgift commentedon Oct 22, 2026
Tracked in #5348 (triage 2026-10-22).
noahgift commentedon Oct 22, 2026
tracked in #5348