The problem
How it works
Ollama documents three ways to run the Codex CLI coding agent against models served by Ollama. The quickest is ollama launch codex, which refreshes the model list and starts Codex with a dedicated profile; inside the session /model switches between installed tool-capable models. The manual route is codex --oss with -m to pick a model such as gpt-oss:120b. For a lasting setup you save a profile pointing Codex at Ollama’s local endpoint on port 11434. Ollama recommends a context window of at least 64k tokens for Codex. Web searches from Codex go through Ollama’s web-search service, which needs ollama signin, and can be disabled for a session.
Results and limitations
This is setup documentation, not a report of results, so it is marked planned. How well the agent codes depends heavily on which model and hardware you use.
Before you try it
Large models such as gpt-oss:120b need a lot of memory, and a 64k context raises that further; smaller models fit more machines but plan and edit less reliably. Names ending in -cloud run on Ollama’s servers, not your machine, so pick a local model if code must stay on your hardware, and disable web search if prompts should not leave it. Codex still edits and runs commands, so keep its approval settings on and work in a repository under version control. Results depend on your setup and were not independently reproduced by Top 200 Repos.
Tools and repositories
- Tools
- Codex CLI · Ollama · gpt-oss or another tool-capable open model
- Prerequisites
- A machine with enough RAM or GPU memory for the chosen model at a 64k context, Node.js for Codex CLI, and Ollama.
Try it yourself: Give a local coding agent a small, checkable task
Fill the fields to adapt the prompt. Empty fields stay as visible [placeholders].
You are running on a local model, so keep each step small. In this repository, [Task]. Before editing, list the files you plan to change and why. Change at most [Maximum files to change] files. After editing, run [Test command] and show me the result. If tests fail twice, stop and explain what you tried instead of continuing.Start with a model that fits comfortably in memory with a 64k context, and compare it on a task you already know the answer to.
Related videos
About openai/codex
Meet the New Codex CLI (opens in a new tab)
Published by the project’s official channel.
Watch on YouTube (opens in a new tab)Independent creators. Listing a video implies no endorsement, sponsorship or partnership.
Sources
- Codex CLI (opens in a new tab)
Project documentation · docs.ollama.com · Undated · Source checked 12 Nov 2026, 09:55 UTC
What this source supports
- ollama launch codex starts Codex with a dedicated profile; /model switches between installed tool-capable models
- Manual setup uses codex --oss, with -m to choose a model such as gpt-oss:120b, or a -cloud model
- A profile can point Codex at http://localhost:11434/v1/
- Use a context window of at least 64k tokens for Codex
- Web search goes through Ollama, needs ollama signin, and can be disabled per session
