Skip to content

Use DeepSeek With Codex CLI: Full Config Walkthrough

Configure OpenAI Codex CLI to use DeepSeek through config.toml. The custom provider block, wire_api gotcha, model choice, pricing, and fixes — on Windows or WSL.

MGMCSA Guru Team June 18, 2026 3 min read
Codex CLI config.toml configured for DeepSeek on Windows

Codex CLI is fast and pleasant to use, and it doesn’t have to run on OpenAI’s models. DeepSeek’s API is OpenAI-compatible, so Codex can use it as a backend at a fraction of the cost — once you set the provider up correctly. The one trap is that a base-URL swap alone won’t do it; Codex needs a real provider definition with the right wire protocol.

This is the complete, working config plus the gotcha that wastes everyone an hour. For the general approach across providers, see Codex CLI custom provider setup.

Step 1: Install Codex CLI and get a key

Install Codex CLI per its docs, then create a DeepSeek account, add a little credit, and generate an API key. On Windows the env-var handling is cleaner in WSL — see Codex CLI on Windows with WSL.

Step 2: Add DeepSeek to config.toml

Codex reads ~/.codex/config.toml (on Windows, C:\Users\YourName\.codex\config.toml). Add a DeepSeek provider and point Codex at it:

model = "deepseek-chat"
model_provider = "deepseek"

[model_providers.deepseek]
name = "DeepSeek"
base_url = "https://api.deepseek.com/v1"
env_key = "DEEPSEEK_API_KEY"
wire_api = "chat"

Export the key and run Codex:

export DEEPSEEK_API_KEY="sk-your-key"
codex

Step 3: Use the OpenAI endpoint, not the Anthropic one

DeepSeek publishes two endpoints. Codex speaks OpenAI’s format, so use the OpenAI-compatible URL:

DeepSeek endpoints — pick the right one

https://api.deepseek.com/v1 OpenAI-compatible — use this for Codex
https://api.deepseek.com/anthropic Anthropic-compatible — for Claude Code only

If you came from a Claude Code guide, this is the difference: Claude Code wants /anthropic; Codex wants /v1.

Step 4: Pick the model

  • deepseek-chat — general coding, fastest and cheapest. Good default.
  • deepseek-reasoner — thinking mode for harder problems.

Change the model key to switch, or keep two profiles. To verify, start Codex and give it a small task; if it edits files and runs commands normally, DeepSeek is serving it.

Pricing

DeepSeek is pay-per-token with no flat coding plan, plus cache-hit discounts and off-peak windows that lower the rate during set hours. It’s one of the cheapest serious options for an agent like Codex. Numbers shift with promotions and versions, so confirm on the official pricing page — see DeepSeek V4 pricing explained.

Troubleshooting

  • Format/streaming errors — almost always missing wire_api = "chat".
  • 401 / auth errorsDEEPSEEK_API_KEY isn’t set in the shell running Codex.
  • “Model not found” — the model value doesn’t match DeepSeek’s current IDs.
  • Changes ignored — restart Codex; config.toml loads at startup only.

DeepSeek + Codex checklist

  • Codex CLI installed; DeepSeek key created
  • [model_providers.deepseek] block with /v1 base_url
  • wire_api = "chat" set
  • model and model_provider point to DeepSeek
  • DEEPSEEK_API_KEY exported; Codex restarted

Wrapping up

Using DeepSeek with Codex CLI is a clean config.toml edit: a [model_providers.deepseek] block pointing at https://api.deepseek.com/v1, an env_key for the secret, and the all-important wire_api = "chat". Set model and model_provider to match, export the key, restart Codex.

To run DeepSeek with other agents, see run DeepSeek with Claude Code or DeepSeek + OpenCode.

Frequently asked questions

Does Codex CLI support DeepSeek?

Yes. DeepSeek's API is OpenAI-compatible, and Codex CLI accepts any OpenAI-compatible provider through a [model_providers] block in config.toml. Define DeepSeek's base URL and key, set wire_api to chat, and point Codex at it.

What's the DeepSeek base URL for Codex?

Use the OpenAI-compatible endpoint https://api.deepseek.com/v1 (not the Anthropic one — that's for Claude Code). Codex speaks the OpenAI format, so the /v1 endpoint is correct here.

Why won't it work if I only change the base URL?

Codex defaults to OpenAI's responses API. DeepSeek uses chat completions, so you must set wire_api = "chat" in the provider block. Without it, requests fail even though the URL is right.

Which DeepSeek model do I set?

deepseek-chat for general coding, deepseek-reasoner for thinking-heavy tasks. Put the ID in the model key and match model_provider to your DeepSeek provider block.

How much does this cost?

DeepSeek is pay-per-token only and very cheap, with cache-hit discounts and off-peak windows. There's no coding plan. Confirm current rates on DeepSeek's pricing page since they change with promotions and versions.

Sources & further reading

Official vendor documentation referenced while writing this guide.

MG

MCSA Guru Team

IT & Systems Administration

We are working IT pros and system administrators who spend our days in Windows Server, Microsoft 365, and the wider Microsoft stack. MCSA Guru is where we write down the fixes and walkthroughs we wish we had found the first time.

MCSA Guru provides independent, educational IT guidance. Microsoft, Windows, Windows Server, Microsoft 365, Exchange, and Microsoft Teams are trademarks of Microsoft Corporation; Docker is a trademark of Docker, Inc. MCSA Guru is not affiliated with or endorsed by Microsoft or Docker. Always test changes in a safe environment before applying them in production.

Related guides

Fixing something right now?

Jump straight into the guide library or search for the exact error or task you are dealing with.