Codex is OpenAI's coding agent, available as a CLI and app. Codex communicates with models through the OpenAI Responses API, so it needs a forwarding layer to handle requests. This guide uses Moon Bridge as that forwarding layer.
npm install -g @openai/codexVerify the installation:
codex --version
go versionGo to the DeepSeek Platform, create an API key, and copy it.
Clone Moon Bridge and create a local config file:
git clone https://github.com/ZhiYi-R/moon-bridge.git
cd moon-bridgeCreate config.yml and set your DeepSeek API key:
mode: "Transform"
server:
addr: "127.0.0.1:38440"
models:
deepseek-v4-pro:
context_window: 1000000
max_output_tokens: 384000
default_reasoning_level: "high"
supported_reasoning_levels:
- effort: "high"
description: "High reasoning effort"
- effort: "xhigh"
description: "Extra high reasoning effort"
supports_reasoning_summaries: true
default_reasoning_summary: "auto"
extensions:
deepseek_v4:
enabled: true
deepseek-v4-flash:
context_window: 1000000
max_output_tokens: 384000
default_reasoning_level: "high"
supported_reasoning_levels:
- effort: "high"
description: "High reasoning effort"
- effort: "xhigh"
description: "Extra high reasoning effort"
supports_reasoning_summaries: true
default_reasoning_summary: "auto"
extensions:
deepseek_v4:
enabled: true
providers:
deepseek:
base_url: "https://api.deepseek.com/anthropic"
api_key: "sk-your-deepseek-api-key"
offers:
- model: deepseek-v4-pro
- model: deepseek-v4-flash
routes:
moonbridge:
model: deepseek-v4-pro
provider: deepseek
defaults:
model: moonbridge
max_tokens: 65536This minimal config uses the current Moon Bridge configuration structure and enables DeepSeek V4 Pro / Flash, Codex model metadata, and the DeepSeek V4 compatibility extension. For image input, Web Search, or multi-provider routing, extend it with the options from Moon Bridge's config.example.yml.
go run ./cmd/moonbridge --config config.ymlKeep this terminal open. By default Moon Bridge listens on 127.0.0.1:38440 and exposes an OpenAI Responses-compatible endpoint at:
http://127.0.0.1:38440/v1/responses
In another terminal, run the following commands from the Moon Bridge directory to write Codex's config.toml and models_catalog.json into CODEX_HOME_DIR.
If you already have a Codex config, back up your current config.toml first:
macOS / Linux:
CODEX_HOME_DIR="${CODEX_HOME:-$HOME/.codex}"
mkdir -p "$CODEX_HOME_DIR"
# Back up the current config.toml
cp "$CODEX_HOME_DIR/config.toml" "$CODEX_HOME_DIR/config.toml.bak" 2>/dev/null || true
# Create config.toml and models_catalog.json
MODEL="$(go run ./cmd/moonbridge --config config.yml --print-codex-model)"
go run ./cmd/moonbridge \
--config config.yml \
--print-codex-config "$MODEL" \
--codex-base-url "http://127.0.0.1:38440/v1" \
--codex-home "$CODEX_HOME_DIR" \
> "$CODEX_HOME_DIR/config.toml"Windows PowerShell:
$CODEX_HOME_DIR = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { "$HOME\.codex" }
New-Item -ItemType Directory -Force -Path $CODEX_HOME_DIR | Out-Null
# Back up the current config.toml
if (Test-Path "$CODEX_HOME_DIR\config.toml") {
Copy-Item "$CODEX_HOME_DIR\config.toml" "$CODEX_HOME_DIR\config.toml.bak" -Force
}
# Create config.toml and models_catalog.json
$MODEL = go run ./cmd/moonbridge --config config.yml --print-codex-model
go run ./cmd/moonbridge `
--config config.yml `
--print-codex-config "$MODEL" `
--codex-base-url "http://127.0.0.1:38440/v1" `
--codex-home "$CODEX_HOME_DIR" `
| Set-Content -Path "$CODEX_HOME_DIR\config.toml"This creates:
config.toml: Codex provider configuration usingwire_api = "responses".models_catalog.json: model capability metadata for Codex, including context window, reasoning levels, and tool support.
Before generating the files, you can check the default Codex model read by Moon Bridge:
go run ./cmd/moonbridge --config config.yml --print-codex-model
# moonbridgeEnter the project you want to work on and launch Codex:
cd /path/to/my-project
codexCodex now sends OpenAI Responses requests to Moon Bridge, and Moon Bridge routes them to DeepSeek V4.
Codex App can use the same generated Codex configuration.
Moon Bridge provides a helper script for Codex CLI that can build and start the proxy, generate the Codex config, and launch Codex in one command:
./scripts/start_codex_with_moonbridge.sh --project-directory /path/to/my-projectWindows PowerShell users can use:
.\scripts\start_codex_with_moonbridge.ps1 -ProjectDirectory C:\path\to\my-projectCheck the available models:
curl http://127.0.0.1:38440/v1/modelsSend a direct Responses test request:
curl http://127.0.0.1:38440/v1/responses \
-H "Content-Type: application/json" \
-d '{
"model": "moonbridge",
"input": "Say hello in one short sentence.",
"max_output_tokens": 1024
}'After Codex sends a message, the Moon Bridge terminal should show a POST /v1/responses log line.
You can also verify that the reasoning level is passed through:
curl http://127.0.0.1:38440/v1/responses \
-H "Content-Type: application/json" \
-d '{
"model": "moonbridge",
"input": "Explain what Moon Bridge does in one sentence.",
"reasoning": {"effort": "high"},
"max_output_tokens": 1024
}'connection refused: Moon Bridge is not running, orserver.addrinconfig.ymluses a different port.- Codex cannot see the model: rerun step 5; Codex needs
models_catalog.jsoninCODEX_HOME. - Config loading fails with
field provider not found: you are using the oldprovider.providersformat. The current format uses top-levelproviders,models,routes, anddefaults. 401or authentication errors: check the DeepSeek API key inconfig.yml.402or payment errors: check your DeepSeek Platform balance.- Image input fails: if you enabled the Visual extension, configure a separate visual provider (e.g., Kimi) with its API key. You can configure that provider, or remove
visual.enabled: trueto disable the Visual extension.