Guides › Codex CLI
Use DeepSeek in Codex CLI
Bottom line: Codex only supports the Responses API, which DeepSeek supports natively, so you add one custom provider with wire_api = "responses" (base_url https://api.deepseek.com, model deepseek-flash or deepseek-v4-pro) to ~/.codex/config.toml and supply the key via DEEPSEEK_API_KEY. On 2026-10-17 we confirmed on codex-cli 0.163.0 that this config parses and reaches DeepSeek's /responses endpoint.
Scope
| Codex version | codex-cli 0.163.0 (npm @openai/codex, latest as of 2026-10-17) |
| Key type | DeepSeek Platform API key (sk-…), pay-as-you-go · source |
| Protocol | Responses API (Codex only supports wire_api = "responses"; DeepSeek supports POST /responses, stateless) · Codex config reference · DeepSeek Responses API |
| Base URL | https://api.deepseek.com |
| Model ID | deepseek-flash (DeepSeek-V4.1-Flash) · deepseek-v4-pro (DeepSeek-V4-Pro-0813) · pricing · DeepSeek price hub |
| OS | Tested: Linux x86_64, macOS ARM64 (CI), Windows x64 PS5.1/pwsh7 (CI; Codex tool calls with sandbox on not verified). Not tested: ARM Windows, Intel Mac. See one-line install below. |
One-line install (optional)
The script installs Claude Code / Codex (your choice), writes DeepSeek into settings.json / config.toml, and runs one short live request with your key. The key is never a CLI argument (stays out of shell history); type it hidden, or set APIPRICE_API_KEY.
macOS / Linux:
curl -fsSL https://apiprice.app/install.sh | bash -s -- --tool codex
Windows (PowerShell 5.1 or 7):
& ([scriptblock]::Create((irm https://apiprice.app/install.ps1))) -Tool codex
Undo: curl -fsSL https://apiprice.app/install.sh | bash -s -- --uninstall --tool codex · & ([scriptblock]::Create((irm https://apiprice.app/install.ps1))) -Uninstall -Tool codex
Assets: install.sh ·
install.ps1 ·
codex-models.json
Tested
- Linux x86_64 (local): binary / npm install, config merge + uninstall restore, Claude Code and Codex text + tool calls (Codex with -s workspace-write, sandbox on).
- macOS ARM64 (GitHub Actions macos-latest, bash and zsh): same, including Claude Code and Codex tool calls (sandbox on).
- Windows x64 (GitHub Actions windows-latest, PowerShell 5.1 and pwsh 7): binary / npm install, PATH registry restore, Claude Code text + tool calls (Write+Read), Codex text call.
Uncovered / unverified
- Windows Codex tool calls with sandbox on: not verified. The script does not pass -s danger-full-access on Windows (sandbox stays on); the deep tool-call test is skipped on Windows. A prior path that used danger-full-access is not treated as verified.
- ARM Windows: not tested.
- Intel Mac (x86_64): not tested (CI is ARM64).
- Claude Code Bash tool on Windows (needs Git for Windows): not tested; without Git the script warns that PowerShell is used as the shell tool.
- PowerShell ExecutionPolicy = Restricted: full install flow not run under Restricted; the script detects it and suggests RemoteSigned, or running the .cmd shim.
- macOS Gatekeeper quarantine on browser downloads (com.apple.quarantine): not tested (CI / curl pipe are unaffected).
- npmmirror.com: deliberately checked on the Linux local path only; Windows / macOS CI may auto-select it, but it is not claimed as a verified mirror there.
Step 1: install Codex manually and set the key
npm install -g @openai/codex codex --version # this page uses codex-cli 0.163.0 export DEEPSEEK_API_KEY="sk-..." # add to ~/.bashrc / ~/.zshrc to persist
Step 2: edit ~/.codex/config.toml
Back up first: cp ~/.codex/config.toml ~/.codex/config.toml.bak 2>/dev/null
# ~/.codex/config.toml (user-level; model_provider in project .codex/config.toml is ignored) model = "deepseek-flash" # or "deepseek-v4-pro" model_provider = "deepseek" model_reasoning_effort = "high" web_search = "disabled" # built-in web search only works with deepseek-v4-pro model_catalog_json = "~/.codex/models.json" # optional: model metadata file from DeepSeek docs [model_providers.deepseek] name = "DeepSeek" base_url = "https://api.deepseek.com" wire_api = "responses" # Codex only supports responses env_key = "DEEPSEEK_API_KEY"
models.json (optional; removes the metadata warning): copy it from the "Edit the Configuration File Manually" section of the DeepSeek docs to ~/.codex/models.json, or delete the model_catalog_json line. DeepSeek Codex docs
Manual setup above. You can also use this site’s one-line installer (see above) or the setup script in DeepSeek’s docs.
Step 3: check it works
codex exec --skip-git-repo-check "reply with OK"
- Success: header shows model: deepseek-flash, provider: deepseek, then the model replies OK.
- No key: ERROR: Missing environment variable: `DEEPSEEK_API_KEY` (tested)
- Invalid key: unexpected status 401 Unauthorized … url: https://api.deepseek.com/responses (tested)
- wire_api = "chat": Error loading config.toml: wire_api = "chat" is no longer supported (tested)
Restore defaults
mv ~/.codex/config.toml.bak ~/.codex/config.toml # or delete the lines above and the [model_providers.deepseek] section rm -f ~/.codex/models.json # if you did not have it before unset DEEPSEEK_API_KEY
To be verified
- Windows Codex tool calls with sandbox on: not verified (skipped; danger-full-access not used).
- ARM Windows, Intel Mac, Gatekeeper quarantine on browser downloads, full install under Restricted ExecutionPolicy: not tested.
- deepseek-v4-pro with web_search = "live": to be verified.
- Codex IDE extension and ChatGPT desktop: to be verified.
- Other providers (Qwen, Kimi, GLM…) in Codex: to be verified.
FAQ
Can Codex use the Chat Completions API with DeepSeek?
No. The Codex config reference says wire_api only supports "responses"; on codex-cli 0.163.0, wire_api = "chat" fails with "wire_api = "chat" is no longer supported". DeepSeek supports the Responses API (POST https://api.deepseek.com/responses).
Which model ID?
deepseek-flash (DeepSeek-V4.1-Flash, image input) or deepseek-v4-pro (DeepSeek-V4-Pro-0813). The legacy deepseek-v4-flash name still works but is served by V4.1 Flash.
What key do I need?
A DeepSeek Platform API key (starts with sk-), pay-as-you-go; no OpenAI/ChatGPT account needed.
env_key vs experimental_bearer_token in the official example?
DeepSeek’s example writes the key into experimental_bearer_token; the Codex reference marks it "discouraged; use env_key". We use env_key so the key stays out of the file. Both are documented fields.
Warning "Model metadata for deepseek-flash not found"?
Tested: without model_catalog_json, codex-cli 0.163.0 warns and uses fallback metadata; with ~/.codex/models.json from the DeepSeek docs and model_catalog_json set, the warning disappears.
How do I restore Codex defaults?
Copy your backup config.toml back (or delete the model / model_provider / model_catalog_json lines and the [model_providers.deepseek] section), then unset DEEPSEEK_API_KEY. If you used DeepSeek’s setup script, choose menu option 9.
Sources: Codex config reference · Codex advanced config · DeepSeek × Codex · DeepSeek Responses API guide · POST /responses · checked 2026-10-17