Skip to content

MaxxxDong/codex-enable-deepseek-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

How to Enable DeepSeek in Codex

中文标题: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.

Problem

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 不存在而失败。

Solution

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

What The Proxy Handles

  • Exposes /v1/models with deepseek-v4-pro and deepseek-v4-flash.
  • Exposes /v1/responses for Codex.
  • Maps Codex developer messages to DeepSeek-compatible chat roles.
  • Preserves DeepSeek reasoning_content for thinking-mode continuity.
  • Maps previous_response_id to an in-memory session store.
  • Converts Codex function calls and function outputs to DeepSeek-compatible tool_calls and tool messages.
  • Aliases codex-auto-review to deepseek-v4-pro.
  • Emits basic Responses-style JSON and SSE events for Codex.

中文:这不是只改 URL。它还处理 role、thinking 模式、工具调用顺序、 previous_response_id 连续性和 Codex 自动审查模型别名。

Files

  • src/deepseek-responses-proxy.mjs - local Responses-to-Chat bridge.
  • scripts/start-deepseek-proxy.ps1 - Windows launcher.

Codex Configuration Example

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 = false

After editing the config, start a new Codex session so the provider and model metadata are loaded from the updated file.

中文:修改配置后,重新开启一个新的 Codex 会话,让 provider 和模型元数据从新 配置加载。

Start

From this repository:

powershell -NoProfile -ExecutionPolicy Bypass `
  -File .\scripts\start-deepseek-proxy.ps1

Start hidden:

Start-Process `
  -FilePath "C:\Program Files\nodejs\node.exe" `
  -ArgumentList "$PWD\src\deepseek-responses-proxy.mjs" `
  -WorkingDirectory "$PWD" `
  -WindowStyle Hidden

Verify:

Invoke-RestMethod http://127.0.0.1:48177/v1/models

Expected model ids:

deepseek-v4-pro
deepseek-v4-flash

中文:先启动 proxy,再启动新的 Codex 会话。重启系统后需要重新启动 proxy, 除非你自己注册成计划任务或 Windows 服务。

Verified Case Study

The solution was developed from a real local Codex instance:

D:\AI\CodexCompose2\.codex

Verified behaviors:

  • Direct /v1/responses against DeepSeek failed with 404.
  • The local proxy exposed /v1/models successfully.
  • Non-streaming /v1/responses worked through the proxy.
  • Streaming output produced Codex-style response.output_text.delta and response.completed events.
  • developer role mapping fixed DeepSeek deserialization errors.
  • reasoning_content preservation fixed thinking-mode continuation errors.
  • Tool-call grouping fixed DeepSeek's requirement that assistant tool_calls be followed by matching tool messages.
  • previous_response_id continuity worked for ordinary memory and tool-output continuation.
  • codex-auto-review was routed to deepseek-v4-pro.
  • Fresh sessions used a 1000000 context-window config with a 950000 auto-compact threshold.

中文:这个方案来自真实实例调试,不是只写概念。已覆盖普通回复、流式回复、 developer role、thinking 模式、工具调用、会话连续性、自动审查别名和 1M context 配置。

Known Limits

  • The previous_response_id store 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。

Trust Checklist

  • 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.

中文:可信度来自可复现的根因、明确的边界和可检查的代码,而不是过度承诺。

About

CODEX内使用/开启DeepSeek方法: local Responses proxy guide for Codex

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors