claude-code - 💡(How to fix) Fix v2.1.154+ breaks third-party API compatibility - system role injected mid-conversation

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

Error API Error: 400 Failed to deserialize the JSON body into the target type:

Error Messages/Logs

  1. Observe the API error immediately Error received:

Fix Action

Workaround

Downgraded to v2.1.153 - works fine.

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?

Last working version:2.1.153 OS: Ubuntu 24 (Linux) API used: DeepSeek API (third-party OpenAI-compatible endpoint)

Error API Error: 400 Failed to deserialize the JSON body into the target type: messages[1].role: unknown variant system, expected user or assistant

What happened

After updating to v2.1.154+, Claude Code started injecting a message with role: "system" into the middle of the messages[] array. Third-party APIs that follow strict OpenAI spec only accept "user" or "assistant" roles in message turns. This makes Claude Code completely unusable with third-party API providers.

Workaround

Downgraded to v2.1.153 - works fine.

What Should Happen?

claude code should work correctly with third-party openAI-compatible api's (such as deepseek) the same way it did in v2.1.153 and earlier. the messages array sent to the api should only contain "user" and "assistant" roles in the conversation turns, with any system level instructions placed at the beginning as a proper system prompt not injected as a mid conversation message with role: "system". this was working correctly before v2.1.154.

Error Messages/Logs

Steps to Reproduce

  1. Install Claude Code v2.1.154 or higher
  2. Configure a third-party OpenAI-compatible API endpoint (e.g. DeepSeek) in Claude Code settings
  3. Launch Claude Code: $ claude
  4. Give any simple prompt, e.g. "write a hello world python script"
  5. Observe the API error immediately

Error received: "400 Failed to deserialize the JSON body into the target type: messages[1].role: unknown variant system, expected user or assistant"

Note: Downgrading to v2.1.153 resolves the issue immediately with no other changes. The same API key and endpoint configuration works perfectly on v2.1.153.

Claude Model

None

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.154, 2.1.156

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

No response

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 v2.1.154+ breaks third-party API compatibility - system role injected mid-conversation