Setup guide - Documented by DeepSeek
Use DeepSeek in Codex CLI
DeepSeek publishes a Codex integration that uses DeepSeek's native Responses API support. You add a [model_providers.deepseek] section to ~/.codex/config.toml with wire_api = "responses", plus a ~/.codex/models.json model catalog, either with a one-click setup script or by hand. The same config also covers the ChatGPT desktop app and the Codex IDE extension.
Last verified 5 steps3 official sources
Steps
- Step 1.
Make sure Codex CLI (or the ChatGPT desktop app) is installed and has been launched at least once, so that ~/.codex exists. Option 1 (recommended): run DeepSeek's setup script, choose menu option 1 (deepseek-flash) or 2 (deepseek-v4-pro) and enter your API key (it starts with sk-). macOS / Linux:
Terminalbash <(curl -fsSL https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh) - Step 2.
Windows (PowerShell):
Terminalirm https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.ps1 | iex - Step 3.
Option 2 (manual), part 1: create ~/.codex/models.json with the full model catalog given on DeepSeek's Codex page. It declares the deepseek-flash and deepseek-v4-pro entries (context_window 1048576, supported reasoning levels low/high/max, minimal_client_version "0.144.0"). The JSON is long, so copy it from the source page.
- Step 4.
Option 2 (manual), part 2: edit ~/.codex/config.toml (create it if it does not exist) and add the following, with your API key as experimental_bearer_token. If config.toml already has a [desktop] section, put enabled-reasoning-efforts in that section rather than adding a second one, because a duplicate section makes the file invalid.
TOMLmodel = "deepseek-flash" model_provider = "deepseek" preferred_auth_method = "apikey" forced_login_method = "api" model_reasoning_effort = "high" web_search = "disabled" show_raw_agent_reasoning = true model_catalog_json = "~/.codex/models.json" [model_providers.deepseek] name = "deepseek" base_url = "https://api.deepseek.com/" wire_api = "responses" experimental_bearer_token = "<your DeepSeek API Key>" [desktop] enabled-reasoning-efforts = ["low", "medium", "high", "xhigh", "ultra", "max"] - Step 5.
Go to your project and run codex. The config is working if the startup banner shows model: deepseek-flash.
Terminalcd /path/to/my-project codex
Caveats
- The script backs up ~/.codex/config.toml to ~/.codex/backup-deepseek/. Menu option 9 restores the default Codex configuration.
- Codex keeps session history separately for each login method, so sessions from a ChatGPT subscription are hidden while DeepSeek is configured (nothing is deleted).
- The API key is stored in plain text in config.toml (experimental_bearer_token).
- Only deepseek-flash accepts image input (input_modalities includes image). deepseek-v4-pro does not support vision.
- Re-running the script removes older deepseek-v4-flash / deepseek-v4-flash-vision-exp entries and leaves only deepseek-flash and deepseek-v4-pro.
More setup guides
Same tool, other providers
Related reading
- DeepSeek V4.1-Flash-1017: Benchmarks vs Opus 5, Pricing, Switch?DeepSeek V4.1-Flash-1017 jumps 11 points on Terminal-Bench 4.0 at the same deepseek-flash price. Benchmarks vs Opus 5, K3, GLM-5.3 and when to switch.
- DeepSeek 4.1 Flash as a Daily Coding Model: Cache, Peak Hours and LimitsDeepSeek 4.1 Flash as a daily coding model: what a session costs, how peak hours double the bill, why caching matters, and where the subsidy argument holds.
- Where to Run DeepSeek V4.1 Flash Free and CheapDeepSeek V4.1 Flash replaced V4 Flash. Official API: $0.15 input, $0.60 output off-peak. OpenRouter hosts start near $0.05. MIT weights are on Hugging Face.
- DeepSeek V4 Flash Vision Exp: Experimental Vision, Limits, and How to Run It in OpenCodeDeepSeek V4 Flash Vision Exp guide: supported image formats, three input methods, the 384-token per-image cap, and how to run it in OpenCode today.
- We Read DeepSeek Harness: What 453K Lines of Agent Runtime Actually SayDeepSeek Harness (dsh) code read: a 453K-line plugin runtime on a vendored Cordis fork, three patterns worth stealing, and the gaps the launch does not mention.
- DeepSeek V4 Flash Is 90% Off Through Novita on Vercel AI Gateway: The Cost MathDeepSeek V4 Flash via Novita on Vercel AI Gateway was 90% off for Pro customers through August 11. The before/after cost math and the provider-pinning setup.
FAQ
How do I use DeepSeek in Codex CLI?
DeepSeek publishes a Codex integration that uses DeepSeek's native Responses API support. You add a [model_providers.deepseek] section to ~/.codex/config.toml with wire_api = "responses", plus a ~/.codex/models.json model catalog, either with a one-click setup script or by hand. The same config also covers the ChatGPT desktop app and the Codex IDE extension.
Which DeepSeek model ids work in Codex CLI?
The official docs read for this guide list deepseek-flash and deepseek-v4-pro. Requests go to https://api.deepseek.com/.
Is this an official DeepSeek and Codex CLI setup?
DeepSeek documents this setup in its own docs. It was last checked against 3 official pages on October 17, 2026.
Sources
Last verified against 3 official pages.
- api-docs.deepseek.comhttps://api-docs.deepseek.com/quick_start/agent_integrations/codex
- api-docs.deepseek.comhttps://api-docs.deepseek.com/quick_start/pricing
- api-docs.deepseek.comhttps://api-docs.deepseek.com/updates
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.