5>CLI agent· 11 local models ranked
Best Local LLMs for Codex CLI
OpenAI's coding agent, driven by a local model via its built-in Ollama provider
Codex CLI is OpenAI's agentic terminal coder. Out of the box it talks to the GPT-5 family, but the CLI ships with Ollama and LM Studio as first-class open-source providers (built into the openai/codex repo), so you can point it at a local model through config.toml and get the same terminal agent loop without an OpenAI account. Codex drives the modern Responses API, which Ollama exposes at /v1/responses, making local tool-calling work end to end. This page ranks the open-weight models that hold up in Codex's tool-call-heavy loop.
