Skip to main content
With an AI Gateway API key you can run OpenAI’s Codex CLI on the models your organization gives you. Requests go through AI Gateway like any other: the key only reaches models you’re allowed, and usage counts toward your limit. Codex works best with OpenAI models, which get Codex’s requests as they are. Other models (Claude, Gemini, DeepSeek and the rest) work too: AI Gateway answers Codex in the format it expects for every model.

Set it up

Create a key in My Library › Models and pick OpenAI Codex under Start using this key. Already have a key? Open its menu and select Set up.
  1. Put the key in your shell profile. Add this line to ~/.zshrc (or ~/.bashrc), then open a new terminal:
  2. Add the provider to Codex. Choose a model (and a thinking level, for models that have levels) on the page, then put the configuration it shows at the top of ~/.codex/config.toml, replacing any model or model_provider lines already there. It looks like this:
  3. Restart Codex’s background server. In a new terminal (one that has the key), run:
    Codex runs a background server that keeps going after you quit Codex or close the terminal. It reads the key and config.toml when it starts, so without this step it keeps using what it had before, even in a new terminal. Run it again whenever you change the key or config.toml.
  4. Start Codex in your project with codex.
  5. Check it. Run /status: it should show the openwork provider. /model lists your models and their thinking levels.
The key is read through a command (the auth block) rather than env_key: only then does Codex load your models from AI Gateway, with their context windows and thinking levels, for /model.

On Windows

Set the key with setx OPENWORK_API_KEY "<your API key>", open a new terminal, run codex app-server daemon restart, and use this auth block instead:

Model names

Each of your models has a name for Codex:
The four characters tell apart models with the same name. Copy names from the page rather than typing them, or pick one with /model.
  • Thinking level: model_reasoning_effort (or the level you pick in /model) sets it. A level at the end of the name (openwork/gpt-5.5-k3f9:high) wins over it.
  • OpenAI models (including Azure OpenAI) get Codex’s requests as they are, so reasoning carries across turns as it does with OpenAI.
  • Other models are translated. Codex’s tools (running commands, editing files with apply_patch, sub-agents) work on them too.
  • Web search isn’t available through AI Gateway: it runs on OpenAI’s side. Codex works without it.
  • /model also lists Codex’s own OpenAI models, after yours. They only work when your organization offers that model.

When it doesn’t work