Fix agentrouter DeepSeek-V4-Flash HTTP 400 in CLIProxyAPI
Introduction
Previously, we set up CPA cliproxyapi
configured User-Agent to access the free agentrouter service
Recently, I always encounter this error when using agentrouter's deepseek-v4-flash
HTTP 400: The content[].thinking in the thinking mode must be passed back to the API.
Agent-Focused Analysis
1. In a new session, use agentrouter's deepseek-v4-flash until an error occurs.
Use /title to obtain the ID for this session
2. I obtained a barely usable free MiniMax-M3. Start a new session and use
/goal mode to analyze the problematic session/goalIn this Session: 20260923_022641_b698c237, I encountered the following issue:HTTP 400: The content[].thinking in the thinking mode must be passed back to the API.That was the error.The model being used is the deepseek-v4-flash model from the CPA provider,This CPA is running in your own environment, where you can access the logs.Please investigate this issue and identify its root cause.
Agent-Oriented Development
3. The Agent produced a ton of analysis that I couldn't understand. I pretended the Agent had already figured it out and said,
Based on the CPA source code, make your own modified copy and run a separate new CPA in your environment, leaving the original CPA untouched.In this new CPA, add only the deepseek-v4-flash model from the agentrouter provider.Then recreate the original failing conversation history and see whether the same problem still occurs when the new CPA is paired with agentrouter.
4. The Agent encountered a minor hiccup during testing: it could not obtain the agentrouter API key from the original CPA configuration file.
The reason is that Hermes automatically redacts strings such as API keys, tokens, and passwords after reading them, preventing the model from seeing them.
You can handle this sensitive information manually yourself. I chose the lazy option and simply disabled Hermes's terminal output redaction setting.
Terminal command:
hermes config set security.redact_secrets false
You can also set it in ~/.hermes/.env
HERMES_REDACT_SECRETS=0
5. After this new CPA was running, I tried it and found that it really worked.
Summary
The code was committed to Github
https://github.com/crazypeace/CLIProxyAPI/tree/for-agentrouter-d4f
A release was published
https://github.com/crazypeace/CLIProxyAPI/releases/tag/for-agentrouter-d4f
6. I then compiled a usage guide together with the Agent.
Assume the following prerequisites:The user has already installed and is running the official cpa version and has configured agentrouter.Then, the user encounters the errorHTTP 400: The content[].thinking in the thinking mode must be passed back to the API..The user has obtained the for-agentrouter-d4f executable,At this point, what should the user do to run a new cpa locally that can use agentrouter normally?Write a user-guide.md file.
Commit to Github
Afterword
I reviewed the code change history. The changes were not substantial. The basic idea is that agentrouter's deepseek-v4-flash model works only in anthropic mode. Therefore, when an external caller uses the openai-compatible format to call CPA, CPA must convert the request to anthropic mode before calling agentrouter
This development was very crude and highly ad hoc. It specifically addresses handling the recent HTTP 400: The content[].thinking in the thinking mode must be passed back to the API encountered with agentrouter's deepseek-v4-flash.
If you have a choice, you may want to use claude code to call agentrouter's deepseek-v4-flash
In my NodeSeek forum post, a forum member reposted relevant user feedback from Discord
One day later, the usage statistics on the agentrouter backend show that it was indeed still operating.