Skip to main content
Codex is a command-line coding assistant. You can route Codex requests through AI Gateway by configuring the OpenAI-compatible base URL and providing your API key.
Create or copy your API key from the console before starting Codex.
If you use multiple coding agents, consider using cc switch or a similar profile manager to maintain separate configurations for Codex, Claude Code, and other tools.

Configure the API Base URL

Set the OpenAI-compatible base URL before starting Codex.
To make this persistent, add it to your shell profile.

Start Codex

Provide Your API Key

When Codex opens the authentication menu, choose Provide your own API key. Paste your API key into the prompt and press Enter to save it.

Start Using Codex

After configuration is complete, you can use Codex from the terminal for code generation, explanation, debugging, and refactoring tasks.