[BUG] Compatibility issue with DeepSeek API: "unknown variant 'system'" error in messages

Resolved 💬 10 comments Opened May 29, 2026 by huasheng-maker Closed May 29, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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" />

View original on GitHub ↗

This issue has 10 comments on GitHub. Read the full discussion on GitHub ↗