Skip to content

Instantly share code, notes, and snippets.

@antenore
Last active July 2, 2026 08:53
Show Gist options
  • Select an option

  • Save antenore/c529e055e45559579b08b4961b517f8c to your computer and use it in GitHub Desktop.

Select an option

Save antenore/c529e055e45559579b08b4961b517f8c to your computer and use it in GitHub Desktop.
Configure OpenAI Codex CLI to use DeepSeek models

Configure OpenAI Codex CLI with DeepSeek Models

Disclaimer (May 2026). Sorry for the long radio silence on the comments, busy stretch on my side. I no longer use this setup and stopped tracking it actively. I'm refreshing the page out of thoroughness because comments kept coming in and people deserve an honest snapshot. If you find better workarounds, post them in the comments and I'll link them, but I won't be maintaining this further.

Status

Codex deprecated wire_api = "chat" in favour of OpenAI's Responses API. DeepSeek only speaks Chat Completions, so the direct integration documented below is no longer reliable. Symptoms reported by users:

  • An assistant message with 'tool_calls' must be followed by tool messages... (insufficient tool messages following tool_calls)
  • Missing 'reasoning_content' field in the assistant message at message index N
  • Deprecation warning for the chat wire API

If you want Codex + DeepSeek today, you need a translation layer (see Workarounds). If you just want to use DeepSeek for coding, there are now better paths (see Alternatives).

Workarounds (community-tested, not by me)

I haven't validated any of these personally. Credits in parentheses point to the comment thread below.

  • OpenRouter with BYOK. Point Codex at OpenRouter and bring your DeepSeek key. Routes through OpenRouter's Responses implementation while billing your DeepSeek credits. Free under 1M requests/month at the time of writing. (via @CrushedAsian255)
  • codeproxy-ai/cli. Local proxy specifically built to make DeepSeek usable inside Codex: https://github.com/codeproxy-ai/cli (via @mushan0x0)
  • LiteLLM. Translates between OpenAI format and arbitrary backends. Run it locally and point Codex at http://localhost:4000: https://github.com/BerriAI/litellm (via @LMCom)
  • dyrnq/ai-adapter. Notes and tests for Codex + DeepSeek V4 Pro: dyrnq/ai-adapter#3 (via @dyrnq)

Original configuration (kept for reference, no longer working as-is)

~/.codex/config.toml

model = "gpt-5.1-codex"

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

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

[profiles.deepseek]
model = "deepseek-chat"
model_provider = "deepseek"

[profiles.deepseek-r1]
model = "deepseek-reasoner"
model_provider = "deepseek-reasoner"

Usage (when it worked)

codex                       # default, OpenAI
codex --profile deepseek    # DeepSeek Chat
codex -p deepseek-r1        # DeepSeek Reasoner

Setup

export DEEPSEEK_API_KEY="your-deepseek-api-key"

Add the same line to ~/.bashrc or ~/.zshrc. Place the TOML above at ~/.codex/config.toml.

Alternatives

If the goal is "use DeepSeek for coding", these need no proxy.

  • Claude Code. Native DeepSeek V4 support (reported by @emergencescience).
  • Aider. Native DeepSeek support.
  • Continue. Native DeepSeek support.
  • deepseek-code. Open-source Python CLI built directly on the DeepSeek API, agent-loop with file/shell/search tools and a permission system. I contributed multiline input upstream and tested it; I'm not running it day-to-day anymore, but last time I used it the basics worked.
  • DeepSeek API directly. If you don't need a CLI wrapper.

References

@andrewbell73

Copy link
Copy Markdown

Looks like many of us are seeing the DeepSeek API down — I’ve experienced the same. Maybe we can follow a systematic troubleshooting guide whenever the API goes down:

  1. First check the official status page to confirm whether the downtime is server‑side or just on our end.
  2. status.
  3. Verify your API key — ensure it’s active, correctly typed, and hasn’t expired.
  4. Check your network: unstable internet, VPN, firewall, or DNS issues can also cause failures.
  5. Review request payload: invalid JSON, wrong parameters or too large requests may cause errors.

If everything above looks correct but it’s still down, wait a while — sometimes the service may be overloaded or under maintenance (others have reported similar outages).

Optionally, implement fallback logic or retry mechanism in your code so your application can handle temporary downtime gracefully or follow step by steps instructions as given on deepseek api down related blog.

If others have additional tips — logging, rate‑limit checks or alternate endpoints — sharing them here might help the community avoid hours of frustration 🙂

@antenore

Copy link
Copy Markdown
Author

Looks like many of us are seeing the DeepSeek API down — I’ve experienced the same. Maybe we can follow a systematic troubleshooting guide whenever the API goes down:

  1. First check the official status page to confirm whether the downtime is server‑side or just on our end.
  2. status.
  3. Verify your API key — ensure it’s active, correctly typed, and hasn’t expired.
  4. Check your network: unstable internet, VPN, firewall, or DNS issues can also cause failures.
  5. Review request payload: invalid JSON, wrong parameters or too large requests may cause errors.

If everything above looks correct but it’s still down, wait a while — sometimes the service may be overloaded or under maintenance (others have reported similar outages).

Optionally, implement fallback logic or retry mechanism in your code so your application can handle temporary downtime gracefully or follow step by steps instructions as given on deepseek api down related blog.

If others have additional tips — logging, rate‑limit checks or alternate endpoints — sharing them here might help the community avoid hours of frustration 🙂

Nice, thanks for pointing this out...
Didn't check if this is possible, can you propose a patch to the gist?

Otherwise I'll check later

@megtog

megtog commented Dec 18, 2025

Copy link
Copy Markdown

seeing this error

{"error":{"message":"Missing `reasoning_content` field in the assistant message at message index 7. For more information, please refer to https://
api-docs.deepseek.com/guides/thinking_mode#tool-calls","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

@CharlieBytesX

Copy link
Copy Markdown

Same as @megtog

@yyy1mu

yyy1mu commented Jan 4, 2026

Copy link
Copy Markdown

Same as @megtog . so which one could run?

@antenore

Copy link
Copy Markdown
Author

I've updated the gist @megtog @CharlieBytesX @yyy1mu
There was a deprecation from OpenAI side, let me know if it works for you.

Also, now the config is cleaner

@antenore

Copy link
Copy Markdown
Author

My bad @megtog @CharlieBytesX @yyy1mu
It seems Codex is not compatible anymore with DeepSeek... We might submit a bug to OpenAI maybe...

@CrushedAsian255

Copy link
Copy Markdown

One workaround is to set up OpenRouter with BYOK (bring your own key) with your DeepSeek API key, so you go through OpenRouter's Responses implementation while using your DeepSeek credits. If you're using less than 1 million requests then BYOK routing is free

@mushan0x0

mushan0x0 commented May 10, 2026

Copy link
Copy Markdown

I created https://github.com/codeproxy-ai/cli, a local proxy that makes DeepSeek usable in Codex.

@prakharprasad

Copy link
Copy Markdown

I created https://github.com/codeproxy-ai/cli, a local proxy that makes DeepSeek usable in Codex.

Good stuff, thanks!

@dyrnq

dyrnq commented May 22, 2026

Copy link
Copy Markdown

Sharing testing and practices: codex+deepseek-v4-pro.

@LMCom

LMCom commented May 27, 2026

Copy link
Copy Markdown

Wasn't LiteLLM made to solve problems like this? It translates AI API calls to and from OpenAI format.
https://github.com/BerriAI/litellm/
Your Codex then gets http://localhost:4000 as the API host instead.

@emergencescience

Copy link
Copy Markdown

There is already official support for deepseek-v4 in claude code.
When will codex follow up on the deepseek-v4 integration? Otherwise, we'll switch from codex to claude code.

@antenore

Copy link
Copy Markdown
Author

@CrushedAsian255 sorry for the late reply, busy stretch on my side.

Thanks for the OpenRouter BYOK tip, that's a clean route since the Responses translation happens on their side and DeepSeek credits stay yours. I've linked it in the updated gist under Workarounds. I won't be maintaining this setup myself, but this is the kind of pointer the next reader needs.

@antenore

Copy link
Copy Markdown
Author

@mushan0x0 sorry for the late reply, busy stretch on my side.

Nice work, a local proxy is the right shape for this problem. I've added codeproxy-ai/cli to the Workarounds list in the gist. I'm no longer maintaining the original setup, so having a dedicated tool linked is more useful than my outdated config.

@antenore

Copy link
Copy Markdown
Author

@prakharprasad agreed, credit to @mushan0x0. Sorry for chiming in this late.

@antenore

Copy link
Copy Markdown
Author

@dyrnq sorry for the late reply, busy stretch on my side.

Thanks for sharing the codex + deepseek-v4-pro notes, that's exactly what readers landing here in 2026 need. I've linked ai-adapter under Workarounds in the gist.

@antenore

Copy link
Copy Markdown
Author

@LMCom sorry for the late reply, busy stretch on my side.

Yes, LiteLLM fits exactly here. Point Codex at the local LiteLLM endpoint and let it translate to DeepSeek. I've added it to the Workarounds section in the gist. I'm not running this setup myself anymore, but for anyone still on the path it's probably the most general-purpose option.

@antenore

antenore commented May 28, 2026

Copy link
Copy Markdown
Author

@emergencescience sorry for the late reply, busy stretch on my side.

I'm not tracking Codex + DeepSeek anymore, so I can't tell you when (or if) OpenAI will follow up on V4. Honest take: I'd switch. Claude Code already supports DeepSeek V4 natively, and even on the Codex side the only paths that work now are proxies: OpenRouter BYOK, codeproxy-ai/cli, LiteLLM, ai-adapter. All linked in the refreshed gist. Thanks for flagging the Claude Code support, I've added a note about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment