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.

Details page error stating that content[].thinking must be passed back to the API and showing trace_id


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

Assistant chat interface showing an HTTP 400 error after switching to deepseek-v4-flash

2. I obtained a barely usable free MiniMax-M3. Start a new session and use /goal mode to analyze the problematic session
/goal 
In 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.

Assistant No. 9 interface showing an HTTP 400 error after switching to MiniMax-M3


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.

Assistant No. 9 terminal showing the cliproxyapi version and a 400 error via cat

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 error HTTP 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

https://github.com/crazypeace/CLIProxyAPI/blob/for-agentrouter-d4f/docs/agentrouter-deepseek-v4-flash-setup_CN.md


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

Oryxen says claudecode with ccswitch keeps returning 400 errors; switching the upstream option to native under advanced settings resolves it


One day later, the usage statistics on the agentrouter backend show that it was indeed still operating.

Bar chart of model consumption distribution showing total deepseek-v4-flash usage of $125.96


Comments