Run Codex CLI with Ollama1
Revised
This page shows how to start Codex CLI with Ollama models, switch models, and set it up by hand.2
Install
Install the Codex CLI. For the ChatGPT desktop app, see ChatGPT Desktop.3
npm install -g @openai/codex
Usage with Ollama
Note: Use a context window of at least 64k tokens for Codex.X11
Quick setup
Run this command:4
ollama launch codex
When launched through ollama launch codex, Ollama refreshes the model catalog
and uses a dedicated Codex profile for that session.
Type /model inside Codex to switch between your installed, tool-capable Ollama
models without restarting. The starting model remains selected, and each model
keeps its own context window, vision, and thinking settings. Pull additional
models with ollama pull <model> before launching to include them in the picker.?1
To configure without launching:
ollama launch codex --config
To remove the Ollama launch profile and generated model catalog:
ollama launch codex --restore
Manual setup
To use codex with Ollama, use the --oss flag:5
codex --oss
To use a specific model, pass the -m flag:6
codex --oss -m gpt-oss:120b
codex --oss -m gpt-oss:120b-cloud
Profile-based setup
For a persistent Codex CLI configuration, create ~/.codex/ollama-launch.config.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:8
codex --profile ollama-launch
Web search through local Ollama
Codex web-search requests sent through the Ollama profile are run9 by Ollama for both local and cloud models. Sign in with ollama signin to use the
web-search service.
To turn off10 web search for a Codex session:
codex --profile ollama-launch -c 'web_search="disabled"'
Notes on this page
1 Wording Audit: improved A task title starts with a verb and names the result.
Was:
Codex CLItype-task-one-goalproc-state-goal2 Added Audit: improved A goal sentence tells the reader what the page covers.
proc-state-goal3 Structure Audit: regression The fence label changed from none to shell; the command is untouched.
Was:
npm install -g @openai/codexcode-block-languageAuditor: The new
shellfence label edits a code block despite the instruction to leave code blocks unchanged.4 Structure Audit: regression The Quick setup command had no lead-in, so a sentence was added, and its fence label changed from none to shell.
proc-imperativecode-block-languageAuditor: The lead-in helps readers, but the new
shellfence label edits a code block despite the instruction to leave code blocks unchanged.5 Structure Audit: regression The fence label changed from none to shell; the command is untouched.
Was:
codex --osscode-block-languageAuditor: The new
shellfence label edits a code block despite the instruction to leave code blocks unchanged.6 Structure Audit: regression The fence label changed from none to shell; the command is untouched.
Was:
codex --oss -m gpt-oss:120bcode-block-languageAuditor: The new
shellfence label edits a code block despite the instruction to leave code blocks unchanged.7 Structure Audit: regression The fence label changed from none to shell; the command is untouched.
Was:
codex --oss -m gpt-oss:120b-cloudcode-block-languageAuditor: The new
shellfence label edits a code block despite the instruction to leave code blocks unchanged.8 Structure Audit: regression The fence label changed from none to shell; the command is untouched.
Was:
codex --profile ollama-launchcode-block-languageAuditor: The new
shellfence label edits a code block despite the instruction to leave code blocks unchanged.9 Wording Audit: improved Use "run" for commands.
Was:
executedcode-run-not-executeRun10 Wording Audit: improved Use "turn off" for a feature.
Was:
disableTurnOn
Questions for the owner
?1 What should the reader see when the launch worked, and where should they go next? The page gives neither.
About: “Pull additional models with
ollama pull <model>before launching to include them in the picker.”X3 Cloud model name form for a signed-in local server. Cloud models says local tools use a
:cloudname, but other pages use a-cloudsuffix, or the bare hosted name afterollama signin. Is the-cloudsuffix still valid alongside:cloud, and which form should every page use for cloud models reached through a local server?Pages: Run cloud models, Authentication, Run Codex CLI with Ollama, Run Droid with Ollama, Use Ollama in marimo
X11 Recommended minimum context for agents, coding and web search. Context length and most coding integrations say 64k, while Web search says about 32000 and Cline and Roo Code say 32K for coding; the 64k note is also repeated on many integration pages. Is the recommended minimum 32k or 64k, and should integration pages link to one statement instead of repeating it?
Pages: Context length, Web search, Use Cline with Ollama, Use Roo Code with Ollama, OpenCode, Run Codex CLI with Ollama, Run Droid with Ollama
Original
Install
Install the Codex CLI. For the ChatGPT desktop app, see ChatGPT Desktop.
npm install -g @openai/codex
Usage with Ollama
Note: Use a context window of at least 64k tokens for Codex.
Quick setup
ollama launch codex
When launched through ollama launch codex, Ollama refreshes the model catalog
and uses a dedicated Codex profile for that session.
Type /model inside Codex to switch between your installed, tool-capable Ollama
models without restarting. The starting model remains selected, and each model
keeps its own context window, vision, and thinking settings. Pull additional
models with ollama pull <model> before launching to include them in the picker.
To configure without launching:
ollama launch codex --config
To remove the Ollama launch profile and generated model catalog:
ollama launch codex --restore
Manual setup
To use codex with Ollama, use the --oss flag:
codex --oss
To use a specific model, pass the -m flag:
codex --oss -m gpt-oss:120b
To use a cloud model:
codex --oss -m gpt-oss:120b-cloud
Profile-based setup
For a persistent Codex CLI configuration, create ~/.codex/ollama-launch.config.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
Web search through local Ollama
Codex web-search requests sent through the Ollama profile are executed by
Ollama for both local and cloud models. Sign in with ollama signin to use the
web-search service.
To disable web search for a Codex session:
codex --profile ollama-launch -c 'web_search="disabled"'
What Changed
The title now starts with a verb, a goal sentence opens the page, and the six code blocks that had no language now carry one. Two words the check flagged were replaced. The page's 64k context note and its two cloud model name forms disagree with other pages, so those are flagged for the owner.
Content type: task. The page gives the steps to run Codex CLI with Ollama models, for a reader who already knows they want that.
Automated check, original: 0 errors, 1 warning, 1 suggestion. Revised: 0 errors, 0 warnings, 0 suggestions.
Independent audit (GPT-6): mixed. The revision improves the title, opening, and command lead-ins, and replaces two flagged words with plainer wording. It also changes six code fences despite the instruction not to edit code blocks, so those changes are regressions under the task rules.
Regressions:
- Six command blocks received new
shellfence labels, contrary to the instruction not to edit code blocks.
What the revision missed:
- The page still leaves the reader without a clear next action after the setup instructions; the revision flags this gap with q1 but does not address it or add an owner answer.
Structure (6)
- 3 The fence label changed from none to shell; the command is untouched. regression
- 4 The Quick setup command had no lead-in, so a sentence was added, and its fence label changed from none to shell. regression
- 5 The fence label changed from none to shell; the command is untouched. regression
- 6 The fence label changed from none to shell; the command is untouched. regression
- 7 The fence label changed from none to shell; the command is untouched. regression
- 8 The fence label changed from none to shell; the command is untouched. regression
Wording (3)
- 1 A task title starts with a verb and names the result. improved
- 9 Use "run" for commands. improved
- 10 Use "turn off" for a feature. improved
Added (1)
- 2 A goal sentence tells the reader what the page covers. improved