Quick Answer
Codex speaks the OpenAI protocol, so connecting it to DeepSeek V4 Pro is two environment variables:
export OPENAI_BASE_URL="https://api.teamorouter.com/v1"
export OPENAI_API_KEY="sk-teamo-your-key"
Then set the model to deepseek-v4-pro (paid) or deepseek-v4-pro-free (free, 200/day) in Codex. Below, both the env-var and profile approaches.
Environment Variables: The Simplest Path
Codex natively supports a custom OpenAI endpoint via env vars:
export OPENAI_BASE_URL="https://api.teamorouter.com/v1"
export OPENAI_API_KEY="sk-teamo-your-key"
Put these in your shell profile (~/.zshrc / ~/.bashrc) and every Codex request goes to TeamoRouter. Then specify the model:
codex --model deepseek-v4-pro-free "Introduce yourself in one sentence"
Note OPENAI_BASE_URL includes /v1 — Codex is built on the OpenAI SDK, which needs it.
Profiles: Route by Task
If you don't want all of Codex on DeepSeek, use a profile for precise control. In ~/.codex/config.toml:
[profiles.teamorouter-pro-free]
base_url = "https://api.teamorouter.com/v1"
api_key = "sk-teamo-your-key"
model = "deepseek-v4-pro-free"
[profiles.teamorouter-pro-free.options]
max_tokens = 4096
Then:
codex --profile teamorouter-pro-free "Refactor src/services/reporting.py to remove duplicate branches"
This keeps your default GPT-5.6 profile alongside the DeepSeek profile and lets you route by task: heavy work on native Codex GPT, daily high-frequency work on cheap DeepSeek V4.
Running V4 Pro Free Inside Codex
deepseek-v4-pro-free gives 200 free/day; wired into Codex:
- Daily edits: single-file changes cost 3–5 requests, so 200 covers a dozen+;
- Long agent loops: multi-step refactors cost 10–20 each, so 200 covers 3–5 hard tasks;
- Quota exhausted: switch the model ID to
deepseek-v4-pro(flat $1.74/$3.48, no account limit).
For light work (explanations, commit messages), use deepseek-v4-flash-free (also 200/day) and reserve the Pro free quota for hard jobs.
Common Pitfalls
Codex returns 404 / can't connect?
OPENAI_BASE_URL is missing /v1. Codex uses the OpenAI SDK, so the endpoint must be https://api.teamorouter.com/v1.
401 auth error?
OPENAI_API_KEY isn't applied or the key was copied incompletely. echo $OPENAI_API_KEY to confirm it starts with sk-teamo- and has no whitespace.
Can't switch models in Codex?
Confirm the model is all lowercase with - separators (deepseek-v4-pro-free). You can curl .../v1/models for the live list.
Do profiles conflict with env vars?
Explicit base_url / api_key in a profile win over env vars — ideal for "default GPT, specific tasks on DeepSeek" routing.
Does V4 Pro's reasoning work in Codex?
Yes. V4 Pro runs over the OpenAI-compatible protocol and reasoning passes through; no extra Codex config.
Get a key at TeamoRouter and two env vars put DeepSeek V4 Pro into Codex.