Install
Install the Codex CLI. For the desktop app, see Codex App.
npm install -g @openai/codexUsage with Ollama
Note
Codex requires a larger context window. It is recommended to use a context window of at least 64k tokens.
Quick setup
ollama launch codexWhen launched through ollama launch codex, Ollama refreshes the model catalog and uses a dedicated Codex profile for that session.
To configure without launching:
shell
ollama launch codex --configTo remove the Ollama launch profile and generated model catalog:
shell
ollama launch codex --restoreManual setup
To use codex with Ollama, use the --oss flag:
codex --ossTo use a specific model, pass the -m flag:
codex --oss -m gpt-oss:120bTo use a cloud model:
codex --oss -m gpt-oss:120b-cloudProfile-based setup
For a persistent Codex CLI configuration, create ~/.codex/ollama-launch.config.toml:
toml
model = "gpt-oss:120b"
model_provider = "ollama-launch"
model_catalog_json = "/Users/you/.codex/model.json"
[model_providers.ollama-launch]
name = "Ollama"
base_url = "http://localhost:11434/v1/"
wire_api = "responses"Then run:
codex --profile ollama-launch