api failed deserialize json body into cc-switch
Quick fix
Depending on the error: roll Claude Code back, upgrade cc-switch, turn the local proxy off, or stop sending unsupported fields.
Symptom
Section titled “Symptom”API Error: 400 Failed to deserialize the JSON body into the target type: messages[1].role: unknown variant `system`, expected `user` or `assistant` at line 1 column 4371This error means the upstream model API rejected the JSON request body that cc-switch forwarded or the client generated. The issues hold several variants. Claude Code 2.1.154 puts the system prompt into the messages array with role: "system", while the DeepSeek /anthropic endpoint requires system as a top-level field. When Codex /responses is converted to Chat Completions through cc-switch, a tool call can lose its name field — fixed in cc-switch 3.16.4. A non-multimodal DeepSeek model receiving image_url / image content produces the same class of 400. And users found that turning the cc-switch local proxy on or off changes compatibility for some models.
If the error contains messages[1].role: unknown variant `system`, roll Claude Code back to 2.1.153 or 2.1.152 and turn auto-update off.
If the error contains missing field `name`, upgrade cc-switch to 3.16.4 or newer — it is still present in 3.16.3.
If the error contains unknown variant `image_url`, unknown variant `image`, or a similar multimodal field, stop sending images to non-multimodal models such as DeepSeek.
If some models work and others 400 while switching between them, try turning the local proxy on the cc-switch home screen off and on again. Maintainers explain some providers are more compatible with the local proxy on, and others more stable with it off.
If the DeepSeek official API previously reported a system / developer role problem, maintainers report DeepSeek fixed it upstream — retry first, and only fall back to rolling Claude Code back if it still fails.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 7 real issues
- #1075Some models don't seem to work in Claude Code on my Mac. I'm not sure if it's a configuration issue or something else.
- #1584测试配置deepseek3.2,识别图片显示无法解析
- #3278[Bug] Claude Code 2.1.154: system role in messages array breaks DeepSeek /anthropic endpoint
- #3281DeepSeek API 报错:unknown variant 'system', expected 'user' or 'assistant'
- #3306用CCS给claude code接入deepseek后api报错
- #3330调用DeepSeek报错,怎么解决。
- #4582cause: Failed to deserialize the JSON body into the target type: messages[5]: missing field `name` at line 1 column 41824
- Which Claude Code version should I roll back to?
- Several users confirm npm i -g @anthropic-ai/[email protected] works, and others solved it by rolling back to 2.1.152. Turn Claude Code auto-update off afterwards.
- Does the VS Code Claude Code plugin need rolling back too?
- If you use the VS Code plugin, uninstall the current one and reinstall version 2.1.153.
- Why does DeepSeek work once I turn the cc-switch local proxy off?
- Providers differ in how they handle Anthropic-specific fields and proxy conversion. Maintainers suggest some models do better with the local proxy and Claude takeover on, while others are more stable with the local proxy off.
- Why can DeepSeek not accept images?
- Maintainers and users in the issues confirm models such as DeepSeek V3.2 are not multimodal and do not support image / image_url content, so sending an image triggers the deserialize 400.
- Is missing field `name` a model problem or a cc-switch problem?
- It relates to a tool call losing its name when Codex /responses is converted to Chat Completions. Maintainers confirmed cc-switch 3.16.3 is affected and 3.16.4 fixed it.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.