System Info / 系統信息
Notes
- Affected models observed:
glm-4.6, glm-5.1.
- Client: Claude Code
2.1.156.
- Current client-side workaround: a local proxy that moves
system-role
messages into the top-level system field before the request reaches GLM.
Your Anthropic-compatible endpoint (/api/anthropic/v1/messages) returns
HTTP 422 when the messages array contains an entry with role: "system":
422 {"detail":[{"type":"literal_error","loc":["body","messages",1,"role"],
"msg":"Input should be 'user' or 'assistant'","input":"system",
"ctx":{"expected":"'user' or 'assistant'"}}]}
The official Anthropic Messages API accepts such requests (it effectively folds
system-role message content into system handling rather than rejecting the
request). Tools built against the Anthropic API — notably Claude Code, which
injects hook/session context as a system-role message in messages[] — send
this shape and therefore fail against GLM while succeeding against Anthropic.
Who can help? / 谁可以帮助到您?
No response
Information / 问题信息
Reproduction / 复现过程
A) Accepted today → HTTP 200
curl -s -w "\nHTTP %{http_code}\n" \
https://open.bigmodel.cn/api/anthropic/v1/messages \
-H "Authorization: Bearer <TOKEN>" \
-H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
-d '{"model":"glm-4.6","max_tokens":20,"system":"You are helpful.",
"messages":[{"role":"user","content":"Hello"}]}'
B) Rejected today → HTTP 422 (only difference: a system entry in messages)
curl -s -w "\nHTTP %{http_code}\n" \
https://open.bigmodel.cn/api/anthropic/v1/messages \
-H "Authorization: Bearer <TOKEN>" \
-H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
-d '{"model":"glm-4.6","max_tokens":20,
"messages":[{"role":"user","content":"ctx"},
{"role":"system","content":"injected"},
{"role":"user","content":"Hello"}]}'
C plugin test in Claude Code
- Enable any plugin with a
SessionStart hook that emits additionalContext
(e.g. the superpowers plugin, which injects its using-superpowers skill text).
- Point Claude Code at an Anthropic-compatible endpoint that strictly validates
message roles (GLM/Zhipu):
ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropic
ANTHROPIC_AUTH_TOKEN=<token>, model glm-4.6 / glm-5.1
- Start an interactive session and send any message ("Hello").
- →
422 on the first turn, every turn.
Expected behavior / 期待表现
Requested fix (either is sufficient)
- Tolerate
system-role entries in messages[]: fold their content into
the system prompt instead of returning 422 (match Anthropic's behavior); or
- Document the strict behavior and, ideally, normalize on the server side so
Anthropic-targeted clients work unmodified.
System Info / 系統信息
Notes
glm-4.6,glm-5.1.2.1.156.system-rolemessages into the top-level
systemfield before the request reaches GLM.Your Anthropic-compatible endpoint (
/api/anthropic/v1/messages) returnsHTTP 422 when the
messagesarray contains an entry withrole: "system":The official Anthropic Messages API accepts such requests (it effectively folds
system-role message content into system handling rather than rejecting therequest). Tools built against the Anthropic API — notably Claude Code, which
injects hook/session context as a
system-role message inmessages[]— sendthis shape and therefore fail against GLM while succeeding against Anthropic.
Who can help? / 谁可以帮助到您?
No response
Information / 问题信息
Reproduction / 复现过程
A) Accepted today → HTTP 200
B) Rejected today → HTTP 422 (only difference: a
systementry inmessages)C plugin test in Claude Code
SessionStarthook that emitsadditionalContext(e.g. the
superpowersplugin, which injects itsusing-superpowersskill text).message roles (GLM/Zhipu):
ANTHROPIC_BASE_URL=https://open.bigmodel.cn/api/anthropicANTHROPIC_AUTH_TOKEN=<token>, modelglm-4.6/glm-5.1422on the first turn, every turn.Expected behavior / 期待表现
Requested fix (either is sufficient)
system-role entries inmessages[]: fold their content intothe system prompt instead of returning 422 (match Anthropic's behavior); or
Anthropic-targeted clients work unmodified.