Codex + DeepSeek V4: How to Use DeepSeek in Codex CLI (Official Setup, 2026)
Connect OpenAI Codex CLI, the ChatGPT desktop app and the Codex IDE extension to DeepSeek V4 with DeepSeek's official config.toml. Model choice, what changes, and a worked monthly cost comparison against GPT-6.1 Sol.
Codex can run on DeepSeek V4 without a proxy. DeepSeek’s API natively supports the Responses API that Codex uses, and DeepSeek publishes an official Codex integration guide. One config file covers Codex CLI, the ChatGPT desktop app and the Codex IDE extension for VS Code.
Everything below follows DeepSeek’s Codex integration guide and the Codex advanced configuration docs, both checked on 2026-11-16. Prices come from DeepSeek’s pricing page as recorded on our DeepSeek V4.1 Flash and DeepSeek V4 Pro pages.
Quick answer
| Setting | Value |
|---|---|
| Config file | ~/.codex/config.toml plus a model catalog at ~/.codex/models.json |
| Provider base URL | https://api.deepseek.com/ |
| Wire API | responses |
| Models | deepseek-flash (DeepSeek V4.1 Flash, accepts images) or deepseek-v4-pro (text only) |
| Minimum Codex version | 0.164 (for DeepSeek’s setup script 1.5.0) |
| Billing | Your DeepSeek API balance, not your ChatGPT plan |
Step 1: install Codex and run it once
Install Codex CLI or the ChatGPT desktop app and launch it at least once, so the ~/.codex directory exists. Get an API key (it starts with sk-) from the DeepSeek Platform.
Step 2a: DeepSeek’s setup script
DeepSeek provides a script that backs up your existing config to ~/.codex/backup-deepseek/, writes the model catalog, and updates config.toml while keeping MCP servers and project trust settings.
macOS / Linux:
bash <(curl -fsSL https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh)
Windows PowerShell:
irm https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.ps1 | iex
Choose 1 for deepseek-flash, 2 for deepseek-v4-pro, or 9 to restore your original Codex configuration. The script asks for your API key on first run.
As with any piped install script, read it before you run it. If you prefer to see every line that changes, use the manual setup below.
Step 2b: manual setup
First create ~/.codex/models.json. This file tells Codex each model’s context window, reasoning levels and tool-call format. DeepSeek’s guide has the full file (it is long because it includes Codex’s instruction template), so copy it from the official page rather than retyping it.
Then add this to ~/.codex/config.toml (create the file if it doesn’t exist):
model = "deepseek-flash"
model_provider = "deepseek"
preferred_auth_method = "apikey"
forced_login_method = "api"
model_reasoning_effort = "high"
show_raw_agent_reasoning = true
suppress_unstable_features_warning = true
model_catalog_json = "~/.codex/models.json"
[features]
standalone_web_search = true
[model_providers.deepseek]
name = "deepseek"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
experimental_bearer_token = "<your DeepSeek API Key>"
supports_standalone_web_search = true
[desktop]
enabled-reasoning-efforts = ["low", "medium", "high", "xhigh", "ultra", "max"]
If you are editing an existing file, DeepSeek says to remove any top-level web_search setting, keep suppress_unstable_features_warning at the top level before the first [section], and add the other keys to their sections instead of duplicating sections.
The key sits in this file in plain text. Don’t commit it, and don’t sync ~/.codex/ to a shared drive.
To use V4 Pro by default, change the first line to model = "deepseek-v4-pro".
Step 3: start Codex
cd /path/to/my-project
codex
Restart the ChatGPT desktop app after switching providers so it picks up the new config.
What changes when Codex runs on DeepSeek
| Area | What happens |
|---|---|
| Sign-in | forced_login_method = "api" skips ChatGPT sign-in. Usage is billed to your DeepSeek account and does not touch your ChatGPT plan limits. |
| Cloud features | Codex’s pricing page lists Codex cloud, GitHub code review and Slack as unavailable when you use an API key instead of ChatGPT sign-in. Plan on local CLI, desktop and IDE use. |
| Images | Only deepseek-flash accepts image input. deepseek-v4-pro is text-only. |
| Reasoning display | show_raw_agent_reasoning only works in Codex CLI. Press Ctrl + T to view it. |
| Web search | Setup script 1.5.0 turns on DeepSeek’s Alpha Search. It is billed per Search request and per Fetch request on top of tokens. Add web_search = "disabled" at the top level to turn it off. |
| Session history | Earlier sessions are stored per login method. After switching, they look missing but are not deleted. |
| Rolling back | Run the script and pick 9, or restore the backup in ~/.codex/backup-deepseek/. |
Cost: DeepSeek vs Codex’s own models
Codex with ChatGPT sign-in uses plan limits, and OpenAI does not publish token allowances for them. So the useful comparison is API to API: what the same month of agent work costs on DeepSeek versus OpenAI’s API.
Assumed workload: 100M input tokens and 2M output tokens a month. Coding agents resend the same repository context, so we assume 90% of input is cache hits (90M cached, 10M uncached). Long-context surcharges and OpenAI cache-write charges are left out.
| Model | Uncached input | Cached input | Output | Monthly total |
|---|---|---|---|---|
| GPT-6.1 Sol | 10M × $2.00 = $20.00 | 90M × $0.10 = $9.00 | 2M × $10.00 = $20.00 | $49.00 |
| GPT-5.3-Codex | 10M × $1.75 = $17.50 | 90M × $0.175 = $15.75 | 2M × $14.00 = $28.00 | $61.25 |
| DeepSeek V4 Pro (peak) | 10M × $1.32 = $13.20 | 90M × $0.044 = $3.96 | 2M × $3.96 = $7.92 | $25.08 |
| DeepSeek V4 Pro (off-peak) | 10M × $0.66 = $6.60 | 90M × $0.022 = $1.98 | 2M × $1.98 = $3.96 | $12.54 |
| DeepSeek V4.1 Flash (peak) | 10M × $0.30 = $3.00 | 90M × $0.006 = $0.54 | 2M × $1.20 = $2.40 | $5.94 |
| DeepSeek V4.1 Flash (off-peak) | 10M × $0.15 = $1.50 | 90M × $0.003 = $0.27 | 2M × $0.60 = $1.20 | $2.97 |
DeepSeek’s peak hours are 01:00-04:00 and 06:00-10:00 UTC on weekdays. Weekends, other weekday hours and Chinese public holidays bill at the off-peak rate.
On this workload, deepseek-flash at peak costs about 12% of GPT-6.1 Sol ($5.94 vs $49.00), and V4 Pro at peak about half ($25.08). Your own ratio depends on your cache-hit rate and on how much output the agent writes, so treat these as rough estimates and check real usage in the DeepSeek console after a few days. The pricing calculator lets you plug in your own numbers.
Price is not the whole picture. Codex is tuned for OpenAI’s models, and DeepSeek’s catalog file reuses Codex’s instruction template. Try your normal tasks on both before you switch a team over.
Troubleshooting
| Symptom | Fix |
|---|---|
| Codex still asks you to sign in to ChatGPT | Check that preferred_auth_method and forced_login_method are at the top level of config.toml, before any [section] |
| Model not found or wrong context size | Make sure model_catalog_json points to ~/.codex/models.json and that the file is DeepSeek’s current version (older catalogs used deepseek-v4-flash, now deepseek-flash) |
| 401 errors | Check experimental_bearer_token in [model_providers.deepseek] |
| Images ignored | Switch to deepseek-flash; V4 Pro is text-only |
| Unexpected search charges | Add web_search = "disabled" and restart Codex |
Related
Next step
Related Posts
DeepSeek V4 Agent Setup: Codex, OpenCode, Qoder, OpenClaw (Official Configs)
2026-04-28
How to Configure DeepSeek V4 in Claude Code (Official Setup, 2026)
2026-04-28
How to Use GLM-5.3 in Claude Code (Official Z.AI Setup, 2026)
2026-11-16