Codex
Run the Codex CLI through OpenLLM with openllm codex, pick a model with -m, or add OpenLLM as a custom model provider in ~/.codex/config.toml.
| Command | openllm codex |
| Mode | Per session. Nothing is installed. |
| Talks to | OpenAI Responses API at <gateway>/v1 |
| Default model | ultra |
| Skip approvals | openllm -d codex (adds --dangerously-bypass-approvals-and-sandbox) |
| Remove | Nothing to remove. Run codex directly. |
Before you begin
- Install the OpenLLM CLI. See Install.
- Install the Codex CLI so that
codexis on yourPATH. If it is missing,openllm codexprints the official installer,https://chatgpt.com/codex/install.sh. - Have at least one model available. See Providers.
For the ChatGPT desktop app, use ChatGPT for Mac instead.
Set up with openllm codex
openllm codexEvery argument after codex goes to Codex unchanged, so openllm codex exec "…" runs a non-interactive task. OpenLLM's own flags go before the client name: -d, --new, and --attach [id].
At launch, OpenLLM picks a gateway: your local daemon at http://127.0.0.1:8787 if it answers, otherwise https://www.openllm.sh. It then starts the real codex binary with -c key=value overrides layered on your own config:
| Override | Value |
|---|---|
model_provider | openllm |
model | ultra |
model_providers.openllm.base_url | <gateway>/v1 |
model_providers.openllm.wire_api | responses |
model_providers.openllm.env_key | OPENLLM_API_KEY |
model_catalog_json | ~/.openllm/run/codex/<pid>/models.json |
mcp_servers.openllm | openllm mcp |
Your key is passed in the OPENLLM_API_KEY environment variable of the Codex process, so it never appears in the command line. The model catalog is fetched from your account at each launch and deleted when Codex exits. If the fetch fails, Codex starts without it.
Your ~/.codex/config.toml, login, and history are untouched. Interactive sessions run in a background session host; run openllm --new codex to skip the offer to attach to a running session.
Set up without the CLI
openllm codex is the recommended path. To run Codex against OpenLLM without the OpenLLM CLI, add a custom model provider to ~/.codex/config.toml. These match the provider settings that the launcher passes with -c:
model_provider = "openllm"
model = "ultra"
[model_providers.openllm]
name = "OpenLLM"
base_url = "https://www.openllm.sh/v1"
wire_api = "responses"
env_key = "OPENLLM_API_KEY"Then export your key in the shell that starts codex:
export OPENLLM_API_KEY="sk-llm-YOUR_KEY"
codexenv_keynames the variable that holds your key, so the key stays out of the config file.- To use the daemon on the same machine, set
base_url = "http://127.0.0.1:8787/v1". See Use the local daemon. - Without the model catalog that
openllm codexfetches, Codex can warnModel metadata for <slug> not found. - To go back to your usual provider, remove these lines.
A manual setup doesn't get the openllm MCP server. To add it yourself, see MCP server.
Choose models
Codex has one model setting, and OpenLLM sets it to ultra. The catalog lists ultra, plus, lite, and every model you have activated, with their context limits.
To pin a model, pass Codex's own flag: openllm codex -m plus or openllm codex -m <provider/model>. You can also switch with /model inside a session. To change what the aliases resolve to, edit the chains in Configuration. See Routing and fallback.
Codex sessions get OpenLLM memory tools through MCP. Automatic recall and save hooks are not added for Codex. See Memory.
Who pays for a request
The model that serves the request decides. A ChatGPT subscription hop runs on your own ChatGPT login through the daemon on one of your devices. An API-key hop bills your provider account. Included openllm/ models count against your plan's allowance. See Providers and Plans and limits.
Check that it works
openllm codex exec "Reply with OK"The reply prints to your terminal. Open Overview in the app: the request appears with the model that served it.
Common problems
| Symptom | Cause | Fix |
|---|---|---|
Codex is not installed | codex is not on your PATH | Install Codex, then run openllm codex again |
No models are available for your OpenLLM account. | Nothing in your model list | Connect a provider on Providers |
Codex warns Model metadata for <slug> not found | The catalog fetch failed at launch | Check your connection and launch again |
Compaction fails with subscription_requires_daemon | /v1/responses/compact is served only by a device signed in to ChatGPT | Start the daemon on that device. See Devices |
OpenLLM could not authorize the model-list check. | Key is invalid or revoked | Save a new key with openllm login |
For anything else, see Troubleshooting.
Remove it
There is nothing to uninstall. Exit Codex and run codex directly to use it without OpenLLM. Temporary files are deleted on exit.
Last updated on
Claude Code
Run Claude Code through OpenLLM with openllm claude, map the Opus, Sonnet and Haiku slots to your models, or set ANTHROPIC_BASE_URL yourself.
OpenCode
Run OpenCode through OpenLLM with openllm opencode, which adds an openllm provider with all your models per session and leaves your own config untouched.