Skip to content

apr serve: chat completions with array-form message content fail with HTTP 422 (Qwen Code can't use apr serve) #5919

Closed as not planned

Description

@alfredodeza

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.

Versions

  • apr 0.71.4 (5027da6), from cargo install aprender
  • Model: Qwen3.5-4B-Q4_K_M.gguf
  • @qwen-code/qwen-code 0.25.3
  • Linux, RTX 4090

Reproduce

apr serve run -v Qwen3.5-4B-Q4_K_M.gguf --gpu -p 8199

String content works:

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":"What is 2+2? Answer with one number."}]}'
... {"role":"assistant","content":"4"},"finish_reason":"stop"} ...
HTTP 200

The same message with array content is rejected:

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

  1. added this to the 0.72.0 milestone on Oct 22, 2026
  2. noahgift commented on Oct 22, 2026

    @noahgift
    Member

    Tracked in #5348 (triage 2026-10-22).

  3. noahgift commented on Oct 22, 2026

    @noahgift
    Member

    tracked in #5348

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions