一次 DeepSeek V4 Pro 接入 Codex 失败复盘为什么 Claude Code 能跑Codex 却不应该直接接如果你最近在折腾 Codex、Claude Code、DeepSeek V4 Pro大概率会遇到一个看起来很矛盾的现象同一个 deepseek-v4-pro 普通 API 调用能返回 Claude Code 里也能跑起来 但一接到 Codex就不稳定甚至直接报错。这很容易让人误判成模型能力问题是不是 DeepSeek V4 Pro 不会写代码 是不是模型太弱 是不是 Codex 不支持第三方模型我实际测下来根因不是这个。这类问题更准确的解释是Codex、Claude Code、普通 OpenAI-compatible API 不是同一层协议。DeepSeek V4 Pro 能不能回答代码问题和它能不能直接满足 Codex 的 Responses API agent loop是两件事。一句话结论2026-07-05 的实测结果如下deepseek-v4-pro 在 /v1/models 里可见 /v1/chat/completions 可用 /v1/responses 返回 HTTP 400 convert_request_failed /v1/messages 可用并且 tool_use - tool_result - final answer 流程跑通。因此我对当前接入方式的建议是使用场景建议普通代码问答可以走/v1/chat/completionsClaude Code可以通过/v1/messages兼容层测试Codex不建议直接作为/v1/responses模型使用注意这不是说 DeepSeek V4 Pro 不能写代码而是说它当前不应该被简单当成 Codex native Responses 模型。为什么这个问题容易被误判因为很多人把 “OpenAI-compatible” 理解成了只要支持 OpenAI 风格 API就能接所有 OpenAI 客户端。但实际不是。至少要拆成三层1. /v1/chat/completions 2. /v1/responses 3. /v1/messages它们都像是在“发消息拿回复”但底层合同不一样。协议入口典型客户端核心数据结构适配难度/v1/chat/completions普通聊天、OpenAI SDK 应用messages / choices低/v1/responsesCodex / OpenAI agent 工作流input items / output items / tool events高/v1/messagesClaude Code / Anthropic SDKcontent blocks / tool_use / tool_result中如果一个模型只声明openaiendpoint它通常表示可以走 OpenAI-compatible chat但不等于完整支持 Responses API。实测 1模型列表能看到但只声明 openai endpoint测试接口GET https://cn.crazyrouter.com/v1/modelsdeepseek-v4-pro的返回片段{id:deepseek-v4-pro,object:model,owned_by:custom,supported_endpoint_types:[openai],public_endpoint_types:[openai]}这里最关键的是supported_endpoint_types: [openai]这可以证明模型在线也可以证明它以 OpenAI-compatible 模型形态暴露。但它不能证明支持 /v1/responses 支持 Codex tool call item 支持 Responses streaming events 支持 reasoning continuation 支持 Codex 多轮工具结果续写所以第一条排查原则是模型出现在/v1/models里只能说明它“可见”不能说明它适合所有 agent 客户端。实测 2chat completions 可用但 token 预算要注意先测普通 OpenAI-compatible chatcurlhttps://cn.crazyrouter.com/v1/chat/completions\-HAuthorization: Bearer YOUR_API_KEY\-HContent-Type: application/json\-d{ model: deepseek-v4-pro, messages: [ { role: user, content: Return exactly: DS_V4_PRO_CHAT_OK } ], max_tokens: 128 }结果是成功的HTTP: 200 Visible content: DS_V4_PRO_CHAT_OK finish_reason: stop这说明 DeepSeek V4 Pro 作为 chat 模型没有问题。但是我第一次把max_tokens设成 30结果只返回DS响应里可以看到finish_reason: length completion_tokens: 30 reasoning_tokens: 28这说明 DeepSeek V4 Pro 会消耗 reasoning tokens。输出预算太小时HTTP 200 并不代表结果可用。如果你在 coding agent 里遇到“有响应但内容很短 / 空输出 / tool call 不完整”不要只看状态码要同时看finish_reason visible content completion_tokens reasoning_tokens tool_calls 是否完整实测 3Responses API 失败这是 Codex 不适合直接接的核心证据再测 Codex 更关心的 Responses APIcurlhttps://cn.crazyrouter.com/v1/responses\-HAuthorization: Bearer YOUR_API_KEY\-HContent-Type: application/json\-d{ model: deepseek-v4-pro, input: Return exactly: DS_V4_PRO_RESPONSES_OK, max_output_tokens: 128 }返回结果HTTP: 400 Error code: convert_request_failed Error type: new_api_error Message: Invalid request.这就是问题的核心。如果 Codex 的 provider 使用[model_providers.custom] wire_api responses base_url https://your-router.example/v1那 Codex 会按/v1/responses的语义发送请求。此时后端必须能理解 Responses API 的输入、输出、工具事件和多轮 continuation。DeepSeek V4 Pro 在本轮测试里没有跑通/v1/responses所以不能直接被当作 Codex 的 Responses 模型。Codex 到底需要什么Codex 不只是把 prompt 发给模型然后等待一段文本。一个真实 Codex 任务通常是这样读取仓库上下文 - 规划修改 - 调用工具读文件 - 接收工具结果 - 继续推理 - 调用工具改文件 - 运行测试 - 根据测试结果继续修复 - 输出最终总结这要求模型和网关能稳定处理结构化事件。Codex 可能需要能力如果缺失会怎样Responses input/output item客户端无法识别每一步输出类型tool call item工具调用可能变成普通文本tool result continuation工具执行后无法继续同一任务reasoning state长任务多轮续写容易断streaming event 顺序客户端等待事件时卡住非空最终输出HTTP 200 但没有可用结果所以 “chat completions 能返回内容” 不等于 “Codex 可以正常完成 agent 工作流”。实测 4为什么 Claude Code 能跑Claude Code 的路径不同。它通常使用 Anthropic Messages 风格POST /v1/messages本轮实测里deepseek-v4-pro通过/v1/messages完成了三步1. 文本请求成功 2. 工具调用 tool_use 成功 3. 工具结果 tool_result 续写成功文本请求返回DS_V4_PRO_MESSAGES_OK工具调用返回{type:tool_use,id:call_00_85VnDZJN9knCdt3l4aX67165,name:get_city_timezone,input:{city:Beijing}}继续传回工具结果{type:tool_result,tool_use_id:call_00_85VnDZJN9knCdt3l4aX67165,content:Asia/Shanghai}最终返回The timezone for Beijing is Asia/Shanghai.这说明 Claude Code 这条路径不是“只会普通聊天”至少基础工具闭环能跑。关键Claude Code 能跑不等于 DeepSeek 原生支持 Claude这里要说清楚Claude Code 可以通过 deepseek-v4-pro 跑起来并不代表DeepSeek V4 Pro 原生就是 Claude 模型更准确的路径是Claude Code - /v1/messages - 网关把 Claude Messages 转成 OpenAI-compatible chat - DeepSeek V4 Pro 生成内容或工具调用 - 网关再转回 Claude content blocks - Claude Code 接收结果所以真正发挥作用的是Claude Messages 兼容层。兼容层要负责Claude Code 侧OpenAI-compatible / DeepSeek 侧网关处理text blockmessage.content文本映射tool_usetool_calls工具名、参数、id 映射tool_resulttool role message工具结果续写stop_reasonfinish_reason停止原因映射SSE eventstream delta流式事件转换usagetoken usage用量字段转换这就是为什么同一个 DeepSeek V4 Pro在 Claude Code 中能跑在 Codex 中却不建议直接接。两者差异可以这样理解维度CodexClaude Code 兼容层入口/v1/responses/v1/messages核心协议OpenAI ResponsesAnthropic Messages对模型要求支持 Responses agent item 语义能被网关转换成 Claude content blocksDeepSeek V4 Pro 本轮结果400convert_request_failed文本和工具闭环成功推荐接入不建议直接接可以测试使用一句话Codex 要的是 Responses agent runtime Claude Code 兼容层要的是可转换的 Messages / tool_use 结构。这两个要求不是同一个难度。如果你要自己验证按这个顺序测不要一上来就把模型接进 Codex 或 Claude Code。先用最小请求测 endpoint。1. 测模型是否可见curlhttps://cn.crazyrouter.com/v1/models\-HAuthorization: Bearer YOUR_API_KEY看id 是否存在 supported_endpoint_types 是什么 public_endpoint_types 是什么2. 测 chat completionscurlhttps://cn.crazyrouter.com/v1/chat/completions\-HAuthorization: Bearer YOUR_API_KEY\-HContent-Type: application/json\-d{ model: deepseek-v4-pro, messages: [ { role: user, content: Return exactly: DS_V4_PRO_CHAT_OK } ], max_tokens: 128 }看HTTP status content 是否非空 finish_reason usage reasoning_tokens3. 测 responsescurlhttps://cn.crazyrouter.com/v1/responses\-HAuthorization: Bearer YOUR_API_KEY\-HContent-Type: application/json\-d{ model: deepseek-v4-pro, input: Return exactly: DS_V4_PRO_RESPONSES_OK, max_output_tokens: 128 }如果这一步失败就不要直接接 Codex。4. 测 messages 工具闭环如果目标是 Claude Code不要只测一句 hello。至少要测text tool_use tool_result final answer因为 Claude Code 真正依赖的是工具闭环而不是普通文本回复。生产环境建议如果你只是想用 DeepSeek V4 Pro 做普通代码问答用 /v1/chat/completions如果你想在 Claude Code 中试用用 /v1/messages 兼容层 先测 tool_use - tool_result 再跑真实仓库任务如果你想接 Codex先确认 /v1/responses 能跑通 再确认工具调用、工具结果续写、流式事件、reasoning state 最后再接真实仓库不要用下面这个逻辑做判断模型能聊天 模型能写代码 模型能接 Codex正确判断应该是模型能聊天 只说明 chat completions 可用 还要单独验证 Codex 所需的 Responses agent loop常见问题1. DeepSeek V4 Pro 是不是完全不能用于 Codex不是绝对不能。准确说是本轮测试中它没有作为/v1/responses模型跑通所以不建议直接接 Codex。如果有专门的 Responses adapter并且能完整转换工具调用、工具结果和流式事件可以另行验证。2. Claude Code 能跑为什么 Codex 不行因为 Claude Code 可以走/v1/messages兼容层网关负责转换 Claude content blocks 和 OpenAI-compatible chat。Codex 走/v1/responses时需要的是另一套 agent item 语义。3. HTTP 200 是不是就代表成功不是。本轮 chat completions 小 token 测试就是 HTTP 200但可见输出只有DS因为 reasoning tokens 占用了大部分输出预算。4. 该怎么设置 max_tokens不要给太小。对会消耗 reasoning tokens 的模型低max_tokens会导致正文被截断。生产环境要记录finish_reason和reasoning_tokens。5. 最推荐的接入方式是什么当前最稳的是普通 API 走/v1/chat/completions。Claude Code 可以走/v1/messages兼容层测试。Codex 不建议直接接除非/v1/responses和工具闭环都验证通过。总结这次问题的关键不是 DeepSeek V4 Pro 的代码能力而是协议适配。本轮实测说明deepseek-v4-pro 可见 /v1/chat/completions 可用 /v1/responses 返回 400 convert_request_failed /v1/messages 文本和工具闭环可用。因此普通 API可以用 DeepSeek V4 Pro Claude Code可以通过 Messages 兼容层测试 Codex不要直接当 Responses 模型接入如果你正在做 coding agent 接入最重要的经验是不要按模型名判断兼容性要按 endpoint 和工具闭环判断兼容性。原始长文和测试记录https://crazyrouter.com/blog/deepseek-v4-pro-codex-claude-code-compatibility-2026?utm_sourcecsdnutm_mediumarticleutm_campaigndeepseek_v4_pro_codex_claude_code_20260705utm_contentcsdn_v2_deepseek-v4-pro-codex-claude-code_20260705__canonicalutm_termDeepSeek%20V4%20Pro%20Codex%20Claude%20Code