Skip to navigation

Codex CLI (gateway)

Route Codex CLI’s LLM calls through the Respan gateway for automatic logging, caching, and model switching. Codex uses the OpenAI Responses API, which the gateway serves at https://api.respan.ai/api/responses, so only your RESPAN_API_KEY is needed.

Setup

1

Install Codex CLI

npm install -g @openai/codex
2

Set environment variable

export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No OPENAI_API_KEY is needed in your shell. The Respan gateway handles provider authentication.

3

Configure Codex

Add to ~/.codex/config.toml (user-level) or .codex/config.toml (project-level):

model = "gpt-5.5"
model_provider = "respan"
[model_providers.respan]
name = "Respan Gateway"
base_url = "https://api.respan.ai/api/"
wire_api = "responses"
env_key = "RESPAN_API_KEY"

env_key is the name of the environment variable that holds your API key, not the actual key. Current Codex CLI requires wire_api = "responses"; wire_api = "chat" is rejected by Codex itself. Both model = "gpt-5.5" and the provider-prefixed model = "openai/gpt-5.5" work.

4

Run Codex

codex "your prompt"

All LLM calls now route through Respan.

Switch models

Change the model parameter in ~/.codex/config.toml to use any OpenAI model the gateway exposes.

model = "gpt-5.5"
# model = "gpt-5-mini"
# model = "gpt-5.3-codex"

The gateway’s Responses API route serves OpenAI models only. Claude and Gemini models are available on the Chat Completions route, which Codex does not use. To run those models from a terminal agent, see OpenCode, pi, or Kilo Code.

See the full model list.