中文标题:CODEX 内使用和开启 DeepSeek 方法
This repository documents a practical way to run DeepSeek V4 models inside Codex by using a small localhost proxy.
Default language is English. Chinese explanations are included in each section.
Codex custom providers may call an OpenAI-style Responses API endpoint:
POST /v1/responses
DeepSeek's public API is Chat Completions compatible:
POST /v1/chat/completions
If Codex is pointed directly at https://api.deepseek.com/v1 with a
Responses-style provider, the observed failure is:
unexpected status 404 Not Found, url: https://api.deepseek.com/v1/responses
中文:问题不是 DeepSeek 模型不可用,而是 Codex 侧调用的是 Responses API,
DeepSeek 公开接口提供的是 Chat Completions API。直接把 Codex base URL 指向
DeepSeek 会因为 /v1/responses 不存在而失败。
Run a local bridge:
Codex
|
| Responses-style request
v
http://127.0.0.1:48177/v1/responses
|
| translated to Chat Completions
v
https://api.deepseek.com/v1/chat/completions
The proxy is local-only and does not store your API key.
中文:本方案在本机启动一个小型转发服务。Codex 仍然访问本机
/v1/responses,proxy 再转成 DeepSeek 的 /v1/chat/completions。
- Exposes
/v1/modelswithdeepseek-v4-proanddeepseek-v4-flash. - Exposes
/v1/responsesfor Codex. - Maps Codex
developermessages to DeepSeek-compatible chat roles. - Preserves DeepSeek
reasoning_contentfor thinking-mode continuity. - Maps
previous_response_idto an in-memory session store. - Converts Codex function calls and function outputs to DeepSeek-compatible
tool_callsandtoolmessages. - Aliases
codex-auto-reviewtodeepseek-v4-pro. - Emits basic Responses-style JSON and SSE events for Codex.
中文:这不是只改 URL。它还处理 role、thinking 模式、工具调用顺序、
previous_response_id 连续性和 Codex 自动审查模型别名。
src/deepseek-responses-proxy.mjs- local Responses-to-Chat bridge.scripts/start-deepseek-proxy.ps1- Windows launcher.
For your Codex home, set the effective .codex/config.toml provider to the
local proxy:
model = "deepseek-v4-pro"
model_provider = "codex_local_access"
model_context_window = 1000000
model_auto_compact_token_limit = 950000
[model_providers.codex_local_access]
name = "DeepSeek V4 Proxy"
base_url = "http://127.0.0.1:48177/v1"
wire_api = "responses"
requires_openai_auth = true
supports_websockets = falseAfter editing the config, start a new Codex session so the provider and model metadata are loaded from the updated file.
中文:修改配置后,重新开启一个新的 Codex 会话,让 provider 和模型元数据从新 配置加载。
From this repository:
powershell -NoProfile -ExecutionPolicy Bypass `
-File .\scripts\start-deepseek-proxy.ps1Start hidden:
Start-Process `
-FilePath "C:\Program Files\nodejs\node.exe" `
-ArgumentList "$PWD\src\deepseek-responses-proxy.mjs" `
-WorkingDirectory "$PWD" `
-WindowStyle HiddenVerify:
Invoke-RestMethod http://127.0.0.1:48177/v1/modelsExpected model ids:
deepseek-v4-pro
deepseek-v4-flash
中文:先启动 proxy,再启动新的 Codex 会话。重启系统后需要重新启动 proxy, 除非你自己注册成计划任务或 Windows 服务。
The solution was developed from a real local Codex instance:
D:\AI\CodexCompose2\.codex
Verified behaviors:
- Direct
/v1/responsesagainst DeepSeek failed with 404. - The local proxy exposed
/v1/modelssuccessfully. - Non-streaming
/v1/responsesworked through the proxy. - Streaming output produced Codex-style
response.output_text.deltaandresponse.completedevents. developerrole mapping fixed DeepSeek deserialization errors.reasoning_contentpreservation fixed thinking-mode continuation errors.- Tool-call grouping fixed DeepSeek's requirement that assistant
tool_callsbe followed by matchingtoolmessages. previous_response_idcontinuity worked for ordinary memory and tool-output continuation.codex-auto-reviewwas routed todeepseek-v4-pro.- Fresh sessions used a
1000000context-window config with a950000auto-compact threshold.
中文:这个方案来自真实实例调试,不是只写概念。已覆盖普通回复、流式回复、 developer role、thinking 模式、工具调用、会话连续性、自动审查别名和 1M context 配置。
- The
previous_response_idstore is in memory. Restarting the proxy clears it. - This is a local development bridge, not a public production gateway.
- It does not change Codex Desktop UI behavior. Token usage can be present in session logs even when the Desktop UI does not show a context meter.
- It does not bypass DeepSeek account limits, rate limits, or model-side validation.
- Do not bind this to a public interface without redesigning authentication, logging, rate limiting, and secret handling.
中文:这是本机 Codex 适配方案,不是公网服务。proxy 重启会清空内存会话缓存, 也不会让 Codex Desktop 一定显示 token/context meter。
- No API key committed.
- Localhost-only listener.
- Explicit supported model ids.
- Documents why direct DeepSeek configuration fails.
- Documents thinking-mode and tool-call constraints.
- Documents session-continuity limitation.
中文:可信度来自可复现的根因、明确的边界和可检查的代码,而不是过度承诺。