explaingit

yangfei4913438/codex-deepseek

12PythonAudience · developerComplexity · 3/5ActiveLicenseSetup · moderate

TLDR

Local Python proxy that lets OpenAI Codex talk to DeepSeek by translating Responses API requests into Chat Completions calls and SSE events back again.

Mindmap

mindmap
  root((codex-deepseek))
    Inputs
      Codex requests
      DeepSeek API key
      .env config
    Outputs
      Chat Completions calls
      SSE responses
      Local proxy port
    Use Cases
      Use DeepSeek in Codex
      Swap providers
      Translate APIs
    Tech Stack
      Python
      stdlib
      SSE
      cc-switch

Things people build with this

USE CASE 1

Use DeepSeek as the model provider for the OpenAI Codex CLI through a local proxy

USE CASE 2

Translate Responses API requests into Chat Completions for any provider that only offers the older API

USE CASE 3

Restore reasoning_content across tool-call turns that DeepSeek drops by default

USE CASE 4

Wire codex-deepseek into cc-switch so a Codex provider config points at the local port

Tech stack

PythonSSEcc-switch

Getting it running

Difficulty · moderate Time to first run · 30min

Needs a DeepSeek API key, a .env file, and a cc-switch or manual ~/.codex/config.toml entry pointing at localhost:11435.

MIT license, do almost anything with the code as long as you keep the copyright notice.

In plain English

codex-deepseek is a small Python proxy that sits between OpenAI's Codex coding tool and a model provider that does not speak Codex's preferred API. Codex talks the OpenAI Responses API, but most providers, including DeepSeek, only offer the older Chat Completions API. This program listens locally on port 11435, accepts Responses-style requests from Codex, translates them on the fly into Chat Completions requests, forwards them to the upstream provider, and translates the streaming reply back into Responses-style events. It is a Python port of an earlier project called ccswitch-deepseek and uses only the Python standard library, no external dependencies. The README starts with quick setup. You copy .env.example to .env and fill in an API key and optional fields like base_url, model name, port, timeout in minutes, and flags for whether the model is a DeepSeek one and whether it accepts image input. Then you run ./start.sh, or uv run python -m src.main if you prefer uv. The proxy then sits at http://127.0.0.1:11435 waiting for traffic. The translation tables in the README explain exactly which fields and stream events are mapped. On the way in, Responses items like input_text, function_call, function_call_output, developer messages, instructions, tools, and reasoning controls all map to Chat Completions equivalents, while images, files, and audio are skipped with stats. On the way back, Chat Completions SSE deltas for content, reasoning, and tool calls are repackaged into the matching Responses SSE events such as response.output_text.delta and response.completed. Two extra behaviors are described: the proxy remembers the previous turn's reasoning_content so it can be restored on the next message when DeepSeek drops it during tool calls, and a small system message is prepended to every request that tells the model its real identity. The proxy is meant to be used alongside cc-switch, a cross-platform tool that manages AI CLI provider configs. The README walks through adding a Codex provider with base_url http://127.0.0.1:11435, wire_api responses, and requires_openai_auth true, then shows the resulting ~/.codex/config.toml. Codex needs a non-empty OPENAI_API_KEY in ~/.codex/auth.json for its own client-side check, but the real upstream auth comes from the proxy's .env file, so any placeholder works there. The code is a few small files under src: main.py for the HTTP server, log.py for colored logging, translate.py for input translation, sse.py for SSE event translation, and recover.py for the reasoning_content restore. There are 28 unit tests runnable via ./test.sh. License is MIT.

Copy-paste prompts

Prompt 1
Walk me through copying .env.example to .env, filling in a DeepSeek key, and starting codex-deepseek with ./start.sh.
Prompt 2
Show me the exact ~/.codex/config.toml entry to add codex-deepseek as a Codex provider with wire_api responses.
Prompt 3
Explain how codex-deepseek maps Responses items like function_call_output and reasoning controls to Chat Completions fields.
Prompt 4
Help me debug why a tool call from Codex returns no reasoning_content and how the recover.py restore step is supposed to fire.
Prompt 5
Run the ./test.sh suite for codex-deepseek and walk through what each of the 28 unit tests covers in translate and sse.
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.