Skip to content

DeepSeek via Codex CLI ​

You can run DeepSeek models (deepseek-chat, deepseek-reasoner, or exact channel-specific IDs from RKAPI Pricing) directly inside Codex CLI by pointing a custom provider in ~/.codex/config.toml to RKAPI (https://api.zwwbai.com/v1).

1. Prerequisites ​

  1. Install Codex CLI (see Codex CLI Setup).
  2. Confirm the exact DeepSeek <model-id> supported by your API key's group on RKAPI Pricing.
  3. Create an API key in the RKAPI Console.

2. Configure ~/.codex/config.toml ​

Create or edit ~/.codex/config.toml (on Windows, %USERPROFILE%\.codex\config.toml):

toml
model_provider = "deepseek_gateway"
model = "deepseek-chat"

[model_providers.deepseek_gateway]
name = "RKAPI (DeepSeek)"
base_url = "https://api.zwwbai.com/v1"
wire_api = "chat"
requires_openai_auth = true

To use DeepSeek's reasoning model instead, set:

toml
model = "deepseek-reasoner"

Keeping GPT as Default & Adding a DeepSeek Profile ​

If you already use Codex CLI with GPT models, define a named profile so you can invoke DeepSeek on demand with codex --profile deepseek:

toml
[model_providers.deepseek_gateway]
name = "RKAPI (DeepSeek)"
base_url = "https://api.zwwbai.com/v1"
wire_api = "chat"
env_key = "DEEPSEEK_API_KEY"

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

3. Choosing wire_api = "chat" vs. wire_api = "responses" ​

Understanding wire_api is essential when pairing Codex CLI with DeepSeek:

wire_api ValueEndpoint CalledWhen to Use
"chat" (Recommended default for DeepSeek)https://api.zwwbai.com/v1/chat/completionsHighest compatibility across DeepSeek channels for streaming responses and structured tool calling
"responses"https://api.zwwbai.com/v1/responsesUse only when both your Codex CLI version requires the OpenAI Responses protocol and your selected RKAPI DeepSeek channel explicitly supports /v1/responses translation

Watch Out for 400 / 404 / 501 on /v1/responses

If Codex CLI returns an error indicating that /v1/responses is unsupported for the selected DeepSeek channel, switch wire_api to "chat". Conversely, if you run a newer Codex CLI build that dropped Chat Completions support in favor of Responses-only mode, verify whether your target channel supports /v1/responses (check Channel Availability) or use a Codex CLI release that retains wire_api = "chat" support.

4. Configure ~/.codex/auth.json ​

When requires_openai_auth = true is set in ~/.codex/config.toml, place your RKAPI API key in ~/.codex/auth.json (on Windows, %USERPROFILE%\.codex\auth.json):

json
{
  "OPENAI_API_KEY": "<YOUR_API_KEY>"
}

If you used env_key = "DEEPSEEK_API_KEY" in a named profile instead, export that variable in your shell:

bash
export DEEPSEEK_API_KEY="<YOUR_API_KEY>"
powershell
[Environment]::SetEnvironmentVariable("DEEPSEEK_API_KEY", "<YOUR_API_KEY>", "User")

5. Verify Execution ​

Run a quick non-interactive test first to confirm authentication and model routing:

bash
codex exec "Reply with OK and confirm which directory you are running in."

Or if using the named profile:

bash
codex --profile deepseek exec "Reply with OK and list the top-level files."

Once verified, launch an interactive coding session with codex (or codex --profile deepseek) and confirm file inspection and patch generation work smoothly.

Troubleshooting ​

  • Requests fail with 404 or unsupported_endpoint on /v1/responses: Set wire_api = "chat" in [model_providers.deepseek_gateway] and re-test.
  • 401 Unauthorized: Confirm ~/.codex/auth.json contains valid JSON with "OPENAI_API_KEY" (or your configured env_key is exported in the active terminal).
  • model_not_found: Verify that deepseek-chat or deepseek-reasoner matches an exact model ID enabled in your API key's group on RKAPI Pricing.
  • Prefer GUI profile switching? Manage multiple Codex profiles cleanly via CC Switch — Codex CLI Setup, or consult the Codex FAQ.