Repository navigation
Description
Summary
'm integrating Claude Code 2.1.333 with CommandCode using the Anthropic-compatible endpoint:
https://api.commandcode.ai/provider/v1/messages
Model: deepseek/deepseek-v4.1-flash
Basic API requests containing user messages work successfully.
However, requests containing a system role inside the messages array return:
400 Invalid discriminator value. Expected 'user' | 'assistant' at messages.1.role
I independently reproduced this error using curl, without Claude Code or any middleware.
I also disabled all Caveman hooks, but Claude Code continues to encounter the same error.
It appears the gateway strictly validates message roles and rejects system messages inside the conversation history.
Could you confirm:
Does the Anthropic-compatible endpoint support the message format emitted by Claude Code 2.1.333?
Can the gateway normalize mid-conversation system messages into the top-level system instruction?
Is there a Claude Code compatibility mode or recommended workaround?
This is preventing Claude Code from working with DeepSeek through CommandCode.
Expected Behavior
The Anthropic-compatible /v1/messages endpoint should support requests generated by Claude Code 2.1.333, including requests containing system-level instructions.
The gateway should correctly handle system instructions according to the Anthropic Messages API specification:
- System-level instructions should be accepted through the top-level
systemfield. - If Claude Code sends system-role messages within the
messagesarray, the gateway should either normalize them into the appropriate system instruction representation or provide a compatible request-handling mechanism. - Valid
userandassistantmessages, tool-use interactions, and conversation history should be preserved without data loss or changes in message ordering.
Expected result: Claude Code should be able to communicate successfully with CommandCode using supported models such as deepseek/deepseek-v4.1-flash, without encountering a 400 Invalid discriminator value error.
Actual Behavior
'm integrating Claude Code 2.1.333 with CommandCode using the Anthropic-compatible endpoint:
https://api.commandcode.ai/provider/v1/messages
Model: deepseek/deepseek-v4.1-flash
Basic API requests containing user messages work successfully.
However, requests containing a system role inside the messages array return:
400 Invalid discriminator value. Expected 'user' | 'assistant' at messages.1.role
I independently reproduced this error using curl, without Claude Code or any middleware.
I also disabled all Caveman hooks, but Claude Code continues to encounter the same error.
It appears the gateway strictly validates message roles and rejects system messages inside the conversation history.
Could you confirm:
Does the Anthropic-compatible endpoint support the message format emitted by Claude Code 2.1.333?
Can the gateway normalize mid-conversation system messages into the top-level system instruction?
Is there a Claude Code compatibility mode or recommended workaround?
This is preventing Claude Code from working with DeepSeek through CommandCode.
Steps to reproduce the issue
-
Install and launch Claude Code version 2.1.333.
-
Configure Claude Code to use CommandCode's Anthropic-compatible API endpoint:
ANTHROPIC_BASE_URL=https://api.commandcode.ai/provider -
Configure a valid CommandCode API key:
ANTHROPIC_API_KEY=<YOUR_API_KEY> -
Configure the model:
ANTHROPIC_MODEL=deepseek/deepseek-v4.1-flash -
Set the default Opus, Sonnet, and Haiku model environment variables to
deepseek/deepseek-v4.1-flash. -
Disable Caveman hooks to eliminate potential third-party middleware interference.
-
Start a fresh Claude Code session.
-
Send a simple prompt, for example:
Hello, reply with OK. -
Observe that Claude Code returns the following error:
API Error: 400 Invalid discriminator value. Expected 'user' | 'assistant' at messages.1.role
Additional verification:
- Send a basic request directly to CommandCode using curl with a single
usermessage. The request succeeds. - Send a request containing a
systemrole inside themessagesarray. The API returns the same HTTP 400 discriminator error.
This reproduces the issue independently of Claude Code and Caveman hooks.
Command Code Version
1.93.6
Operating System
macOS
Terminal/IDE
Mac Os native Terminal
Shell
No response
Session file (optional)
No response
Fix prompt (optional)
No response
Additional context
No response
Activity
sudhanshumathurlearn commentedon Dec 1, 2026
Workaround
Adding the following environment variable to Claude Code's
settings.jsonresolves the issue:This disables the
mid_conv_systemcapability for all configured models, preventing Claude Code from sending mid-conversation system messages that the CommandCode Anthropic-compatible endpoint rejects.With this configuration, Claude Code can communicate with CommandCode using
deepseek/deepseek-v4.1-flashwithout encountering the 400 discriminator error.This appears to be a compatibility workaround rather than a permanent gateway-side fix.
dan-sec commentedon Dec 2, 2026
Same problem with claude code version 2.1.334 in ubuntu.
Workaroud works.