Skip to content

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 ~/.zshrc

Using Codex

After setup, use Codex normally:

bash
codex "Refactor this function to use async/await"

Codex will route requests through TopRouter automatically.

ModelBest For
openai/gpt-5.5General coding tasks
openai/gpt-5.5-thinkingComplex reasoning
openai/gpt-5.4-thinkingFast, 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)

Unified AI API Gateway — Access 200+ models through one endpoint.