claude-code - 💡(How to fix) Fix [BUG] Compatibility issue with DeepSeek API: "unknown variant 'system'" error in messages

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

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 1010

Fix Action

Fix / Workaround

As a temporary workaround, I had to downgrade to version 2.1.153 to maintain functionality. Please consider updating the message payload structure to ensure compatibility with third-party API providers like DeepSeek, or handle the system role appropriately before transmission.

Code Example

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 1010
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Since the update to version 2.1.156, I have encountered a deserialization error when using DeepSeek models (e.g., deepseek-v4-pro) via Claude Code. It appears that the recent changes to the message format have introduced an incompatibility with the DeepSeek API.

What Should Happen?

Claude should generate contents successfully withour error.

Error Messages/Logs

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 1010

Steps to Reproduce

1.Configure Claude Code to use a DeepSeek model (e.g., deepseek-v4-pro). 2.Run any command or prompt that triggers an API call. 3.Observe the 400 Bad Request error returned by the API.

Claude Model

Other

Is this a regression?

Yes, this worked in a previous version

Last Working Version

2.1.153

Claude Code Version

2.1.156

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

PowerShell

Additional Information

It seems that the client is sending a system role in the messages array, which the DeepSeek API does not support (it expects only user or assistant roles). This worked fine in previous versions (e.g., 2.1.153).

As a temporary workaround, I had to downgrade to version 2.1.153 to maintain functionality. Please consider updating the message payload structure to ensure compatibility with third-party API providers like DeepSeek, or handle the system role appropriately before transmission.

<img width="1113" height="626" alt="Image" src="https://github.com/user-attachments/assets/0159a1e2-2272-4283-87d4-c69060fd5a39" />

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Compatibility issue with DeepSeek API: "unknown variant 'system'" error in messages