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 on Linux x86_64; macOS / Windows to be verified |
Step 1: install Codex 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
DeepSeek also provides a setup script (backs up and rewrites config); see their docs. This page covers manual setup only.
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
- deepseek-v4-pro with web_search = "live": to be verified.
- macOS / Windows, 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