OpenAI Codex Setup
Configure OpenAI Codex CLI to use TopRouter as the API provider.
Environment Variables
bash
export OPENAI_BASE_URL="https://toprouter.cc"
export OPENAI_API_KEY="sk-your-toprouter-key"Persistent Setup
Add to your shell profile (~/.zshrc or ~/.bashrc):
bash
# TopRouter for OpenAI Codex
export OPENAI_BASE_URL="https://toprouter.cc"
export OPENAI_API_KEY="sk-your-toprouter-key"Reload:
bash
source ~/.zshrcUsing Codex
After setup, use Codex normally:
bash
codex "Refactor this function to use async/await"Codex will route requests through TopRouter automatically.
Recommended Models
| Model | Best For |
|---|---|
openai/gpt-5.5 | General coding tasks |
openai/gpt-5.5-thinking | Complex reasoning |
openai/gpt-5.4-thinking | Fast, cost-effective coding |
Troubleshooting
- Verify environment variables are set:
echo $OPENAI_BASE_URL - Check API key is valid on the API Keys page
- Ensure the base URL is set to
https://toprouter.cc(without trailing/v1)
