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
- Install Codex CLI (see Codex CLI Setup).
- Confirm the exact DeepSeek
<model-id>supported by your API key's group on RKAPI Pricing. - 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):
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 = trueTo use DeepSeek's reasoning model instead, set:
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:
[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 Value | Endpoint Called | When to Use |
|---|---|---|
"chat" (Recommended default for DeepSeek) | https://api.zwwbai.com/v1/chat/completions | Highest compatibility across DeepSeek channels for streaming responses and structured tool calling |
"responses" | https://api.zwwbai.com/v1/responses | Use 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):
{
"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:
export DEEPSEEK_API_KEY="<YOUR_API_KEY>"[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:
codex exec "Reply with OK and confirm which directory you are running in."Or if using the named profile:
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
404orunsupported_endpointon/v1/responses: Setwire_api = "chat"in[model_providers.deepseek_gateway]and re-test. 401 Unauthorized: Confirm~/.codex/auth.jsoncontains valid JSON with"OPENAI_API_KEY"(or your configuredenv_keyis exported in the active terminal).model_not_found: Verify thatdeepseek-chatordeepseek-reasonermatches 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.