DeepSeek V4 Flash can run as the model backend for Codex through DeepSeek’s Responses API. You keep the Codex interface, repository access, terminal tools, sandbox controls, approvals, MCP servers, skills, and project instructions. DeepSeek processes the model requests and charges your DeepSeek API balance.
The setup requires Codex 0.144.0 or later, a funded DeepSeek API account, and DeepSeek’s Codex configuration. The supported model is currently deepseek-v4-flash, which routes to DeepSeek-V4-Flash-0731 as of August 5, 2026. DeepSeek V4 Pro does not yet support the Responses API required for direct Codex use.
Last updated: August 5 2026.
What You Need Before Setup
Prepare the following:
- Codex CLI, the Codex desktop app, or the Codex extension for VS Code.
- Codex version 0.144.0 or later.
- A DeepSeek Platform account and API key.
- Available credit in the DeepSeek API account.
- A repository that does not contain credentials or data your organization prohibits sending to DeepSeek.
- Launch Codex at least once before continuing. This creates the
~/.codexdirectory used by the integration.
Check the installed Codex version:
codex --version
Install or update Codex through npm:
npm install -g @openai/codex@latest
Read More: OpenAI Codex Commands Cheat Sheet
How to Use DeepSeek V4 in Codex
DeepSeek provides an official setup script that updates ~/.codex/config.toml and creates the required ~/.codex/models.json catalog.
The script also backs up the current configuration, preserves existing MCP and project trust settings, and validates both files before installation.
Create a DeepSeek API Key
Sign in to the DeepSeek Platform, open the API Keys page, and create a new API key.
DeepSeek API keys begin with
sk-. Add a small amount of API credit before testing.
Copy the key when it appears and store it in a password manager or another approved credential store. Do not place it in a repository, issue, screenshot, shared document, or shell command that other people can access.
Run the DeepSeek Setup Script
On Windows, open PowerShell or Windows Terminal and run:
irm https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.ps1 | iex
On macOS or Linux, run:
bash <(curl -fsSL https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh)
These commands download and execute DeepSeek’s current installer. Review the script before execution when your security policy does not permit remote scripts to run directly from a URL.
Choose DeepSeek V4 Flash from the installer menu. Enter your DeepSeek API key when prompted.
The installer performs four main tasks:
- It backs up the existing
config.tomlunder~/.codex/backup-deepseek/. - It writes the DeepSeek model catalog to
~/.codex/models.json. - It adds the DeepSeek Responses API provider to
~/.codex/config.toml. - It validates the JSON and TOML syntax before replacing the active files.
The generated configuration selects deepseek-v4-flash, uses https://api.deepseek.com/, sets wire_api = "responses", and selects high reasoning effort by default.
Restart Codex
Close all active Codex windows and terminal sessions. Start Codex again from your project directory:
cd /path/to/your-project
codex
The CLI startup banner should show:
model: deepseek-v4-flashHow to Verify the DeepSeek Connection
Begin with a read-only task whose answer is easy to check:
Read this repository without editing files. Identify the test command, the main entry point, and three likely maintenance risks. Cite the relevant file paths.Confirm that Codex reads the repository, invokes tools, and returns file paths that exist. The response should also identify commands and project files that match the repository.
Next, request one small edit on a disposable branch. Inspect the diff and run the project’s checks before accepting the provider for routine work.
Open the DeepSeek Platform usage page after the test. Confirm that the request and token charges appear under the expected account. A completed Codex response confirms connectivity. The usage record confirms that DeepSeek processed and billed the request.
How to Switch Back to OpenAI
Run the DeepSeek setup script again and select its restore option. The script restores the saved pre-DeepSeek config.toml.
Restart all Codex clients after the restoration.
Previous sessions may appear to disappear after a provider change. Codex groups ChatGPT-authenticated sessions separately from sessions created through a third-party API configuration.
The session files are not deleted. Restoring the earlier authentication method displays the previous session group again and hides the DeepSeek group.
Use separate branches when comparing providers on the same task. This keeps one model’s edits from changing the repository state used for the next test.
What Works in Codex Today
DeepSeek introduced the V4 preview family on April 24, 2026. The July 31 V4 Flash update added native Responses API support and changes aimed at coding-agent workflows. Current Codex clients use the Responses API for model requests.
| Model | Codex status | Best current use |
|---|---|---|
deepseek-v4-flash | Directly supported | Daily coding, repository analysis, tests, documentation, and high-volume tasks |
deepseek-v4-pro | Responses API support unavailable | Use V4 Flash until Codex-compatible support appears |
deepseek-chat | Retired | Do not use in a new configuration |
deepseek-reasoner | Retired | Do not use in a new configuration |
DeepSeek previously listed V4 Pro support for Codex as an early-August target. Its current pricing and model information still show no Responses API support for V4 Pro as of August 5, 2026.
Older configurations based on Chat Completions, wire_api = "chat", local translation proxies, or retired DeepSeek model names do not match the current Codex integration.
DeepSeek v4 API Pricing
DeepSeek bills API usage per 1 million tokens.
| Token type | V4 Flash | V4 Pro |
|---|---|---|
| Cached input | $0.0028 | $0.003625 |
| Uncached input | $0.14 | $0.435 |
| Output | $0.28 | $0.87 |
Note that DeepSeek V4 Pro does not yet support the Responses API required for direct Codex use.
DeepSeek has also described a future peak and off-peak pricing policy. The proposed peak rate is twice the standard rate from 9:00 a.m. to noon and from 2:00 p.m. to 6:00 p.m. Beijing time. The company has not published an effective date. Check the current pricing terms before estimating a recurring production budget.
How DeepSeek Pricing Compares with OpenAI
OpenAI’s current short-context standard API rates are $5 per 1 million input tokens and $30 per 1 million output tokens for GPT-5.6 Sol, $2 input and $12 output for GPT-5.6 Terra, and $0.20 input and $1.20 output for GPT-5.6 Luna.
Long-context requests and other processing modes can use different rates.
The example below assumes a cumulative workload of 10 million uncached input tokens and 2 million output tokens at the listed standard rates.
| Model | Cost for the example workload | Multiple of V4 Flash cost |
|---|---|---|
| DeepSeek V4 Flash | $1.96 | 1x |
| GPT-5.6 Luna | $4.40 | 2.2x |
| GPT-5.6 Terra | $44.00 | 22.4x |
| GPT-5.6 Sol | $110.00 | 56.1x |
The calculation excludes cache discounts, OpenAI cache-write charges, long-context pricing, built-in tool fees, priority or fast processing, regional adjustments, and taxes.
Token price does not measure completed-task value. A stronger model may solve a difficult problem with fewer retries and less human correction. Compare providers on the same repository tasks and record total tokens, accepted changes, elapsed time, failed attempts, and review effort.
Why DeepSeek V4 Can Lower Codex Costs
Agentic Coding Processes Large Amounts of Input
Codex repeatedly sends project instructions, file contents, tool definitions, command output, diffs, and conversation history to the model. The total API input can greatly exceed the prompt visible in the composer.
Repository-wide analysis, dependency migrations, test generation, and long debugging sessions can process millions of tokens. V4 Flash’s low input and output rates can reduce the cost of this repeated context.
Context Caching Can Reduce Repeated Input Charges
DeepSeek applies context caching automatically. A later request may receive the lower cached-input rate when it reuses an exact stored prefix.
Stable project instructions and repeated conversation prefixes have a better chance of matching than frequently changing inputs. Cache construction and matching operate on a best-effort basis. DeepSeek does not guarantee a cache hit for every repeated request.
A new prefix starts at the uncached rate because DeepSeek must store it before a later request can reuse it.
V4 Flash Targets Coding-Agent Workflows
DeepSeek reports scores of 82.7 on Terminal-Bench 2.1, 54.4 on DeepSWE, and 70.3 on Toolathlon Verified for V4 Flash. Its code-agent evaluations used the company’s minimal harness, maximum effort, top_p=0.95, and temperature=1.0.
These vendor-reported results show that the model can complete multi-step tool workflows under the tested configuration. They do not predict identical performance across every Codex repository.
Prompts, tool definitions, reasoning settings, retry behavior, repository quality, and test coverage can change the result. Evaluate V4 Flash with representative tasks from your own projects before assigning it critical work.
The Codex Workflow Remains in Place
The provider changes while Codex continues to manage repository access, tools, approvals, sandbox rules, and project instructions.
Existing AGENTS.md files, MCP servers, skills, project trust settings, and approval controls can remain in use. DeepSeek’s installer adds the provider and model catalog without requiring a move to another coding-agent interface.
This arrangement lets developers compare a lower-cost model while keeping their existing repository workflow.
Can DeepSeek Replace a ChatGPT Plus or Pro Plan?
DeepSeek can replace the model provider used inside a Codex session. Its API balance remains separate from a ChatGPT subscription.
DeepSeek charges for actual token usage in this configuration. It does not provide a flat monthly Codex allowance tied to ChatGPT Plus or Pro.
A DeepSeek-only setup may suit developers who mainly use Codex for routine repository work and whose measured API spending stays below the cost of their current subscription. Another option uses V4 Flash as the default provider and reserves an OpenAI model for selected tasks.
Keep a ChatGPT plan when you rely on its included Codex usage, ChatGPT conversations, deep research, image tools, voice, memory, projects, or other subscription features. OpenAI plan limits and purchased credits do not transfer to DeepSeek. A DeepSeek API balance cannot fund ChatGPT services.
Measure one month of actual work before changing a subscription. Record DeepSeek spending and note which tasks require an OpenAI model for quality, image input, or product-specific features.
Manual Configuration and API Key Storage
The official installer stores the API key in ~/.codex/config.toml through the experimental_bearer_token field. The essential provider block is:
model = "deepseek-v4-flash"
model_provider = "deepseek"
preferred_auth_method = "apikey"
forced_login_method = "api"
model_reasoning_effort = "high"
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>"This provider block does not complete the setup by itself. Codex also requires the current models.json catalog. Use DeepSeek’s installer or copy the complete catalog from its current Codex integration instructions.
Handle
config.tomlas a credential file. Do not commit the.codexuser directory, share the file, or paste it into a support request without removing the token.Revoke the key through the DeepSeek Platform after any suspected exposure.
Troubleshooting
Codex Returns a 404, 405, or Responses API Error
Update Codex and rerun DeepSeek’s current installer.
Old setup instructions may use wire_api = "chat", /chat/completions, a translation proxy, or a retired DeepSeek model. Those configurations do not match the current Responses API integration.
Confirm these values in config.toml:
model = "deepseek-v4-flash"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
Restart every Codex client after correcting the file.
DeepSeek V4 Pro Fails to Start
V4 Pro does not currently support DeepSeek’s Responses API. Access through Chat Completions or an Anthropic-compatible interface does not make it a direct Codex provider.
Select V4 Flash until DeepSeek lists Responses API support for V4 Pro and includes the model in its Codex catalog.
Codex Reports an Authentication or Balance Error
Confirm that the API key remains active and that the DeepSeek account has API credit. Free DeepSeek chat access does not fund API requests.
Rerun the setup script after replacing the key. Revoke the previous key when you cannot confirm where it was stored.
The Model Is Missing or Codex Rejects the Catalog
Check that Codex is version 0.144.0 or later:
codex --version
Rerun the installer to refresh models.json, then restart all Codex clients.
A manually written catalog can fail when it omits a required field or contains invalid JSON.
The Desktop Client Shows Custom
Some desktop builds identify a configured third-party provider as Custom.
Check the session model details and verify activity in the DeepSeek usage dashboard. The label alone does not indicate that Codex switched back to an OpenAI model.
Old Sessions Are Missing
Restore the previous authentication configuration and restart Codex.
Provider switching changes the session group displayed by the client. It does not erase sessions created under the other authentication method.
A Long Task Costs More Than Expected
Codex resends conversation state and relevant working context across turns. Large command output, generated files, repeated test logs, and long sessions can raise input usage quickly.
Start a new session when the task changes. Exclude irrelevant generated directories, avoid pasting large repeated logs, and keep stable instructions near the beginning of the conversation.
Use /compact when the active session becomes too large.
The 1 million-token context window represents capacity rather than a spending target. Review DeepSeek billing during the first week and set budgets from measured repository tasks.
Screenshots or Image Prompts Do Not Work
DeepSeek’s Codex uses text as the input modality for V4 Flash. The current integration does not process image input.
Use a model with vision support for screenshot diagnosis, visual interface review, or other image-dependent work.
Where DeepSeek V4 Fits Best
V4 Flash provides the clearest cost advantage on tasks that consume many tokens and have objective validation steps.
Suitable work includes:
- Repository mapping and codebase summaries
- Test generation
- Documentation updates
- Dependency migrations
- Repetitive code transformations
- Lint and formatting fixes
- First-pass code review
- File-by-file maintenance work
Tests, static analysis, and a human-reviewed diff can expose errors before merge.
Choose a stronger model when failure carries a high cost or V4 Flash repeatedly fails the same task. Security-sensitive changes, subtle concurrency problems, unfamiliar architecture, broad refactors without reliable tests, and final release review deserve a quality-first model selection.
A hybrid setup can lower the total cost of completed work. V4 Flash can handle routine, high-volume tasks, while a stronger model handles problems that require greater reliability or image input.
Do not send private keys, production credentials, confidential source code, customer records, or regulated information to a hosted model without organizational approval.
DeepSeek’s current privacy policy states that it collects user inputs such as prompts and uploaded content, may use personal data to improve and train its technology, and directly processes and stores personal data in the People’s Republic of China.
Review the current policy, contractual terms, and applicable requirements before connecting a work repository.
FAQs
Does the First Request Receive the Cached Input Price?
A new request prefix normally receives the uncached rate because DeepSeek has not stored a matching prefix yet.
Later requests may receive cache-hit pricing when they reuse the stored prefix exactly. Cache construction and matching happen automatically, and cache hits are not guaranteed.
What Happens When My DeepSeek API Balance Reaches Zero?
DeepSeek can reject paid API requests when the account has insufficient balance. Codex will return a provider or billing error until you add funds.
A ChatGPT subscription cannot pay a DeepSeek API balance.
Can I Create a Separate DeepSeek API Key for Each Computer?
Yes. Separate keys simplify device management and individual key revocation.
The keys still belong to the same DeepSeek account and draw from its account balance.
Does DeepSeek V4 Flash Use Thinking Mode in Codex?
V4 Flash supports thinking and non-thinking operation. DeepSeek’s Codex exposes low, high, and max reasoning levels. The installer selects high by default.
Higher effort can help on difficult tasks. It can also increase response time and billable output.
Will Codex Switch to V4 Pro Automatically After Its Release?
No. The Codex configuration names a specific model.
After DeepSeek adds Responses API support for V4 Pro, update the installer and select Pro. Do not change the model name until the current Codex catalog lists it as supported.
Does Switching the Model Provider Change Codex Sandbox Permissions?
No. Codex continues to apply its local sandbox, approval, and project trust settings.
DeepSeek’s installer preserves existing MCP and project trust configuration. Review the resulting config.toml when an organization manages these controls centrally.
Related Resources
- CodeWhale (DeepSeek TUI): Free, Open-source Claude Code Alternative
- OpenAI Codex Commands Cheat Sheet
- Codex Timeline: Release Dates and Major Updates
- Most Popular Agent Skills on GitHub for Coding Agents










