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

Status Closed — not planned
Reported on v2.1.154
Maintainer reply None cached
Activity 11 comments · opened May 29, 2026 · closed Jul 7, 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?

I'm using the Deepseek-v4-pro model, when I chat to Claude,Claude shows the error: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

What Should Happen?

Claude should answer me and work successful.

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

Steps to Reproduce

Just open a new session and chat to Claude.

Claude Model

Other

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.1.154 the latest version

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

11 Comments

YMRTZ · 3 months ago

https://www.reddit.com/r/DeepSeek/comments/1tqiz97/deepseek_not_working_with_claude_code/

Doing this and source ~/,bashrc worked for me as a temporary fix.

github-actions[bot] · 3 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/63366
  2. https://github.com/anthropics/claude-code/issues/63423
  3. https://github.com/anthropics/claude-code/issues/63396

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

wangsanshi123 · 3 months ago

+1

fandengdong · 3 months ago

+1

fandengdong · 3 months ago
+1

版本降级后恢复:npm install -g @anthropic-ai/claude-code@2.1.153

hahahp · 3 months ago

+1 and hope it will be solved asap

hahahp · 3 months ago

I resolved the issue by downgrading the version. Today, I saw a message saying "opus-4.8 is available," which likely means the Claude Code CLI updated itself in the background. Then the same problem appeared in this issue (I'm also using Deepseek-v4). I tried the methods online and those suggested by the AI ​​and found a solution:

npm install -g @anthropic-ai/claude-code@2.1.153

The problem was subsequently resolved. This was most likely caused by an official Claude update I guess.

BruceXuK · 3 months ago

Install a lower version: npm install -g @anthropic-ai/claude-code@2.1.153

Louisduong05 · 3 months ago
https://www.reddit.com/r/DeepSeek/comments/1tqiz97/deepseek_not_working_with_claude_code/ Doing this and source ~/,bashrc worked for me as a temporary fix.

Thanks

jacobfriisstrand · 2 months ago

Today I am experiencing a different kind of error, which is

API Error: 400 Failed to deserialize the JSON body into the target type: messages[6]: unknown variant 'thinking', expected 'text'

I have tried on version 2.1.152, 2.1.152 and 2.1.148 with no luck. Anyone else experiencing this?

github-actions[bot] · 1 month ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.