Request body format invalid error - Claude Code
Quick fix
Upgrade cc-switch and enable the Rectifier, or add MAX_THINKING_TOKENS=0, for compatibility with third-party API formats.
Symptom
Section titled “Symptom”API Error: 400 {"error":{"code":"invalid_parameter_error","message":"event:error\ndata:{"code":"InvalidParameter","message":"Request body format invalid","request_id":"eedf1443-5885-9123-b239-ea0ad34d499a"}\n\n","param":null,"type":"invalid_request_error"},"request_id":"f7cd2ca2-718e-9a2b-93a5-56bb212e493a"}This 400 comes from the request body Claude Code or Codex sends being incompatible with the API specification of a third-party provider such as Alibaba Bailian or DeepSeek. Three main variants: 1. Thinking mode incompatibility: Claude sends thinking: adaptive by default while some third parties only support enabled/disabled. 2. System prompt format change: Claude Code >= 2.1.154 puts the system prompt into the messages array as role: system, while third parties expect it at the top level as a string. 3. Oversized parameter conversion anomalies: very large or deeply nested tool_call parameters in Codex produce an invalid payload during protocol conversion.
Upgrade cc-switch to v3.11.0 or newer (v3.12.3+ preferred) for the Thinking Budget Rectifier and Normalize system messages features.
Enable the rectifier in cc-switch settings: go to Settings > Proxy > Rectifier and make sure Normalize system messages is on.
If the problem persists, force adaptive thinking mode off in the config.
// .claude/settings.json{"env": {"MAX_THINKING_TOKENS": "0"},"alwaysThinkingEnabled": false}(Alternative) On Alibaba Bailian, try switching to the OpenAI-compatible protocol: set the Base URL to https://coding.dashscope.aliyuncs.com/v1, pick openai as the API format, and enable the proxy.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 4 real issues
- Why does it still error after adding the MAX_THINKING_TOKENS=0 environment variable?
- After changing an environment variable or config, you must save and restart the Claude Code terminal for it to apply. Also, if the cause is the system prompt format change in Claude Code >= 2.1.154, turning thinking off is not enough — you have to upgrade cc-switch and enable Normalize system messages.
- After switching to the OpenAI-compatible protocol I get Cannot read properties of null (reading 'output_tokens'). What now?
- That usually means the model name is not mapped correctly, or the upstream response format is non-standard. Drop the OpenAI-compatible protocol, go back to the Anthropic protocol, and rely on the cc-switch Rectifier to correct the request body automatically.
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.