摘要:本文针对使用 Claude Code 时遇到的
400 API Error报错,分析了其根本原因——第三方 API 供应商(如 minimax-m2.7、deepseekV4-pro)不支持reasoning参数。文章提供了一种通过自定义 Transformer 在请求发送前移除不支持的参数,并结合claude-code-router配置文件进行集成的完整解决方案。
报错信息
API Error: 400
{
"error": {
"message": "Error from provider(Nvidia,minimaxai/minimax-m2.7: 400): {\"error\":{\"message\":\"Validation: Unsupported parameter(s): reasoning\",\"type\":\"Bad Request\",\"code\":400}}",
"type": "api_error",
"code": "provider_response_error"
}
}

原因
使用的 API 供应商(通过第三方接入的 LLM 模型)不支持 reasoning(推理)参数,当 Claude Code 发起工具调用或深度分析时的 API 请求体中传入了模型无法识别的参数时,系统就会返回 400 Bad Request 验证错误。
- 目前已知存在该问题的模型
- deepseekV4-pro
https://api-docs.deepseek.com/guides/thinking_mode - minimax-m2.7
- deepseekV4-pro
解决方法
自定义 Transformer 在请求发送之前移除不支持的参数
- 配置Transformer:remove-reasoning.js
class customtransformer{
constructor(options={}){
this.name = "customtransformer";
this.options = options;
}
// Transform the request before sending to provider
transformRequestIn(request = {}, options = {}) {
const body = { ...request };
// Remove unsupported field
if (Object.prototype.hasOwnProperty.call(body, "reasoning")) {
delete body.reasoning;
}
// Remove temperature if present
if (Object.prototype.hasOwnProperty.call(body, "temperature")) {
delete body.temperature;
}
return body;
}
// Pass-through for now; adjust if provider responses need normalization
transformResponseOut(response) {
return response;
}
}
module.exports = customtransformer;
- 配置ccr config文件,参考官方文档
https://github.com/musistudio/claude-code-router/blob/main/README_zh.md或 使用ccr ui页面内创建transformer
...
"transformers": [
{
"name": "customtransformer",
"path": "C:\\xxx\\.claude-code-router\\transformers\\remove-reasoning.js",
"options": {}
}
],
...
// 具体第三方models配置块内
{
"models": ["xxx", "xxx"],
"transformer": {
"use": [
"customtransformer"
],
"minimaxai/minimax-m2.7": {
"use": [
"customtransformer"
]
}
}
}
- ccr restart 重启ccr后再次尝试使用claude,正常返回


8194

被折叠的 条评论
为什么被折叠?



