Setup guide - Documented by Ollama
Use Ollama in Codex CLI
Codex CLI can run against Ollama with the built-in --oss flag, a persistent profile that points a custom model provider at Ollama's OpenAI-compatible /v1 endpoint, or Ollama's ollama launch codex helper.
Last verified 9 steps2 official sources
Steps
- Step 1.
Install the Codex CLI.
Terminalnpm install -g @openai/codex - Step 2.
Quick setup through Ollama (refreshes the model catalog and uses a dedicated Codex profile). Type /model inside Codex to switch between installed tool-capable Ollama models.
Terminalollama launch codex - Step 3.
Configure without launching.
Terminalollama launch codex --config - Step 4.
Manual setup: use the --oss flag.
Terminalcodex --oss - Step 5.
Use a specific local model.
Terminalcodex --oss -m gpt-oss:120b - Step 6.
Use a cloud model.
Terminalcodex --oss -m gpt-oss:120b-cloud - Step 7.
Profile-based setup: create ~/.codex/ollama-launch.config.toml with the following content.
TOMLmodel = "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" - Step 8.
Then run Codex with that profile.
Terminalcodex --profile ollama-launch - Step 9.
To remove the Ollama launch profile and generated model catalog.
Terminalollama launch codex --restore
Caveats
- Steps come from Ollama's Codex CLI integration page; OpenAI's Codex docs were not read today.
- Ollama says to use a context window of at least 64k tokens for Codex.
- Pull additional models with
ollama pull <model>before launching to include them in the /model picker. - The model_catalog_json path in the sample config is Ollama's example path and must be changed to your own home directory.
More setup guides
Same tool, other providers
Related reading
- Codex Custom Model Providers: GLM-5.3, Mistral and OllamaCodex only speaks the Responses API now. Tested config.toml blocks for GLM-5.3, Mistral Large 4 through a gateway, local Ollama and an internal proxy.
- Ollama Decision Models: Run Nimble Locally with --askOllama 0.40.4 runs decision models locally: ollama run nimble --ask answers yes/no, label and score questions with probabilities. Commands and limits.
- Ollama 0.40 on Mac: MLX by Default, Disk Space DoubledOllama 0.40 runs supported models on MLX on Apple Silicon and keeps a backup copy of each model you load. What it costs in disk, what is fixed, and the cleanup.
- GitHub Copilot CLI With Ollama: Local Models and the New SandboxCopilot CLI 1.0.94 finds local Ollama models from /model and ships an OS-level sandbox. Setup, the 4k context trap, and why local is not offline.
- Hermes Agent Guide (2026): What It Is, Local Setup With Ollama, Skills, and Hermes vs OpenClawHermes Agent is Nous Research's open-source, self-improving AI agent. Run it locally with Ollama, see how its skills system works, and compare it with OpenClaw.
- What Is OpenClaw? Setup, Skills, MCP Server, Claude Code, and Ollama (2026 Guide)What is OpenClaw? A self-hosted personal AI agent you reach through chat apps. Install, skills and ClawHub, its MCP server, Claude Code use, and Ollama models.
FAQ
How do I use Ollama in Codex CLI?
Codex CLI can run against Ollama with the built-in --oss flag, a persistent profile that points a custom model provider at Ollama's OpenAI-compatible /v1 endpoint, or Ollama's ollama launch codex helper.
Which Ollama model ids work in Codex CLI?
The official docs read for this guide list gpt-oss:120b and gpt-oss:120b-cloud. Requests go to http://localhost:11434/v1/.
Is this an official Ollama and Codex CLI setup?
Ollama documents this setup in its own docs. It was last checked against 2 official pages on October 17, 2026.
Sources
Last verified against 2 official pages.
- docs.ollama.comhttps://docs.ollama.com/integrations/codex
- raw.githubusercontent.comhttps://raw.githubusercontent.com/ollama/ollama/main/docs/integrations/codex.mdx
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.