一次 DeepSeek V4 Pro 接入 Codex 失败复盘:为什么 Claude Code 能跑,Codex 却不应该直接接?
一次 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/completions |
| Claude 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/responses |
Codex / OpenAI agent 工作流 | input items / output items / tool events | 高 |
/v1/messages |
Claude Code / Anthropic SDK | content blocks / tool_use / tool_result | 中 |
如果一个模型只声明 openai endpoint,它通常表示可以走 OpenAI-compatible chat,但不等于完整支持 Responses API。
实测 1:模型列表能看到,但只声明 openai endpoint
测试接口:
GET https://cn.crazyrouter.com/v1/models
deepseek-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 客户端。
实测 2:chat completions 可用,但 token 预算要注意
先测普通 OpenAI-compatible chat:
curl https://cn.crazyrouter.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-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 是否完整

实测 3:Responses API 失败,这是 Codex 不适合直接接的核心证据
再测 Codex 更关心的 Responses API:
curl https://cn.crazyrouter.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-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 block | message.content | 文本映射 |
| tool_use | tool_calls | 工具名、参数、id 映射 |
| tool_result | tool role message | 工具结果续写 |
| stop_reason | finish_reason | 停止原因映射 |
| SSE event | stream delta | 流式事件转换 |
| usage | token usage | 用量字段转换 |
这就是为什么同一个 DeepSeek V4 Pro,在 Claude Code 中能跑,在 Codex 中却不建议直接接。
两者差异可以这样理解

| 维度 | Codex | Claude Code 兼容层 |
|---|---|---|
| 入口 | /v1/responses |
/v1/messages |
| 核心协议 | OpenAI Responses | Anthropic Messages |
| 对模型要求 | 支持 Responses agent item 语义 | 能被网关转换成 Claude content blocks |
| DeepSeek V4 Pro 本轮结果 | 400 convert_request_failed |
文本和工具闭环成功 |
| 推荐接入 | 不建议直接接 | 可以测试使用 |
一句话:
Codex 要的是 Responses agent runtime;
Claude Code 兼容层要的是可转换的 Messages / tool_use 结构。
这两个要求不是同一个难度。
如果你要自己验证,按这个顺序测
不要一上来就把模型接进 Codex 或 Claude Code。先用最小请求测 endpoint。
1. 测模型是否可见
curl https://cn.crazyrouter.com/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"
看:
id 是否存在
supported_endpoint_types 是什么
public_endpoint_types 是什么
2. 测 chat completions
curl https://cn.crazyrouter.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-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_tokens
3. 测 responses
curl https://cn.crazyrouter.com/v1/responses \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-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_source=csdn&utm_medium=article&utm_campaign=deepseek_v4_pro_codex_claude_code_20260705&utm_content=csdn_v2_deepseek-v4-pro-codex-claude-code_20260705__canonical&utm_term=DeepSeek%20V4%20Pro%20Codex%20Claude%20Code
更多推荐


所有评论(0)