[BUG] API-Inference returns HTTP 200 with "choices": null when response_format is {"type":"json_schema"} — no completion, no error
Hello ModelScope team,
Summary
POST https://api-inference.modelscope.ai/v1/chat/completions with response_format={"type":"json_schema","json_schema":{...}} returns HTTP 200 with a syntactically valid envelope whose "choices" is null, "object" is "", "created" is 0 and "usage" is all zeros. No completion is produced and no error is raised — so any OpenAI-compatible client must treat a 200 as a failure and cannot see why. The same request works with no response_format at all, and with {"type":"json_object"}.
Environment
- Endpoint: POST https://api-inference.modelscope.ai/v1/chat/completions
- Model: deepseek-ai/DeepSeek-V4.1-Flash
- Auth: Authorization: Bearer (redacted here)
- Client: Python 3.11 urllib, non-streaming
- Probe run: 2026-09-18 16:01 local time (UTC+03:00)
- Production request_ids where the same failure was observed by our client: 2b40989c-ef33-4662-9355-a23ab9967caa 801721b7-9425-4c3a-9d78-8a5e6fbbd058 a48d0000-91d9-4678-9888-b3d115930f65 79dab94d-4e6d-4ea8-a3b4-7c19d155d63f
Minimal reproduction
curl -sS https://api-inference.modelscope.ai/v1/chat/completions
-H "Authorization: Bearer $MODELSCOPE_TOKEN"
-H "Content-Type: application/json"
-d '{
"model": "deepseek-ai/DeepSeek-V4.1-Flash",
"max_tokens": 60,
"messages": [{"role": "user", "content": "Return a short JSON title for this chat."}],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "title",
"strict": true,
"schema": {
"type": "object",
"properties": {"title": {"type": "string"}},
"required": ["title"],
"additionalProperties": false
}
}
}
}'
Observed — three raw responses, one run, seconds apart
A) no response_format -> HTTP 200, choices[0].message present (works) B) response_format json_object -> HTTP 200, choices[0].message present (works) C) response_format json_schema -> HTTP 200, body: { "id": "chatcmpl-2d37aa7f-4587-931a-8479-14d08a4816d6", "object": "", "created": 0, "model": "deepseek-ai/DeepSeek-V4.1-Flash", "system_fingerprint": "", "choices": null, "usage": {"prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0} }
Expected
Either (1) honor the JSON-schema constraint and return a normal chat.completion, or (2) reject the unsupported parameter with a 4xx carrying a machine-readable code, e.g. {"error": {"type": "invalid_request_error", "code": "unsupported_response_format", ...}}. A 200 with "choices": null is the worst of the three: it is indistinguishable from a transient empty stream, carries zero usage, and leaves the client nothing to act on.
Impact (real, observed)
Hermes Agent (a desktop/CLI agent) issues its auxiliary title-generation call with a JSON schema. On this endpoint that call aborts with: Auxiliary title_generation: LLM returned invalid response (type=ChatCompletion): "ChatCompletion(id='chatcmpl-...', choices=None, created=0, model='deepseek-ai/DeepSeek-V4.1-Flash')" Expected object with .choices[0].message — check provider adapter or custom endpoint compatibility. The user-visible effect: chat titles are never generated on this provider (two sessions hit it: 2026-09-17 18:29 and 2026-09-18 14:57 local). Any client that relies on structured output against this endpoint will hit the same wall.
Notes
- If json_schema is intentionally unsupported on API-Inference, an explicit 4xx lets clients fall back to json_object or plain prompting automatically instead of failing silently.
- Raw three-case evidence (request bodies + full response bodies) is available on request.
Regards, Hermes Agent user (contact via this report)
Source: modelscope/modelscope