Codex CLI
Last updated
Codex CLI is OpenAI's own tool, and out of the box it only talks to OpenAI models. Add Tempr Gateway as a model provider in its config and Codex CLI can run Claude, Gemini, DeepSeek — anything on your gateway allowlist — with the same codex commands and workflow you already use.
Codex CLI speaks OpenAI's Responses API, and Tempr Gateway serves it at /v1/responses. OpenAI models, and your Azure OpenAI deployments, pass straight through to their own Responses API. Every other model is translated to its provider's API and back, so Codex's shell and apply_patch tools, and its sub-agents, work on Claude the same way they do on GPT.
-
Create a virtual key
In the Portal, create a Gateway virtual key. Keys are prefixed
tvk_and shown once at creation. -
Add a provider key
Gateway is BYOK: add a key for at least one provider from the supported list.
-
Edit the config file
Create or edit
~/.codex/config.toml, adding Tempr Gateway as a model provider:
# Codex CLI, running on Claude instead of an OpenAI model
model = "anthropic/claude-sonnet-5"
model_provider = "tempr"
[model_providers.tempr]
name = "Tempr Gateway"
base_url = "https://api.temprhq.io/v1"
env_key = "TEMPR_API_KEY"
wire_api = "responses"
Then put your virtual key in the environment variable env_key names, and start Codex CLI as usual:
export TEMPR_API_KEY="tvk_..."
codex
Tell Codex about your models
Codex decides which tools to offer from its own catalog of models, and the models you use through Tempr aren't in it, not even OpenAI's codex models. For a model it doesn't know, Codex warns Model metadata for … not found, leaves out its apply_patch tool, so edits fall back to shell commands, and assumes a 272K-token context window. To get the full toolset, give Codex a catalog of your models. This command copies the details of a model Codex ships with, gpt-5.5, under each of your model ids. Change the list to the models you use and their context windows:
codex debug models --bundled | node -e '
const windows = { "anthropic/claude-sonnet-5": 200000, "openai/gpt-5.3-codex": 272000 };
let json = "";
process.stdin.on("data", d => json += d).on("end", () => {
const base = JSON.parse(json).models.find(m => m.slug === "gpt-5.5");
const models = Object.entries(windows).map(([slug, window]) =>
({ ...base, slug, display_name: slug, priority: 1, context_window: window, max_context_window: window }));
console.log(JSON.stringify({ models }));
});' > ~/.codex/tempr-models.json
Then point config.toml at the file, by its full path:
model_catalog_json = "/home/you/.codex/tempr-models.json"
- The catalog replaces Codex's own, so list every model you use through Tempr. Run the command again after upgrading Codex, to keep the copied instructions current.
- The copied details include reasoning levels, so
/modeloffers low to xhigh effort on every model. Tempr maps the level onto each provider's own reasoning settings.
Model ids — not just OpenAI's
Use the fully-qualified provider/model form — anthropic/claude-sonnet-4-5, deepseek/deepseek-chat, or any other id from GET /v1/models. OpenAI's own models work too, codex models included: an openai/… model goes straight through to OpenAI's Responses API, reasoning and all. So does an Azure OpenAI deployment: azure-openai/your-deployment-name goes to your resource's own Responses API. A bare id such as gpt-5-codex also works; the gateway resolves it against the providers you've added keys for.
What changes on other models
Codex's tools work on every model: its shell tools, the freeform apply_patch tool once Codex knows the model, and sub-agents, including the tool search Codex loads them with. A few OpenAI-only features don't carry over to other providers:
- Hosted tools, such as web search, run only on OpenAI's side. Tempr drops them for other models rather than failing the request, and names what it dropped in the
x-tempr-unsupported-toolsresponse header. - Encrypted reasoning is OpenAI-specific and isn't sent to other providers. The reasoning effort is: Tempr maps it onto the provider's own reasoning settings.
previous_response_idisn't available on other models, because Tempr doesn't store responses. Codex sends the whole conversation on each turn, so it isn't affected.
What's next
- Authentication & virtual keys — scoping keys with model allowlists, budgets, and rate limits.
- Models, limits & logs — request logs and analytics for everything you send through the gateway.