OpenAI Codex with Ollama
Summary
OpenAI's Codex CLI, a tool designed to read, modify, and execute code within a working directory, now supports open models via Ollama. Released on January 15, 2026, this integration allows users to leverage models like `gpt-oss:20b` and `gpt-oss:120b`, or other open-weight alternatives, directly through the Codex interface. To get started, users install the Codex CLI via npm and then launch it with the `--oss` flag. The default model is `gpt-oss:20b`, but users can specify different models, including cloud-based options like `gpt-oss:120b-cloud`, using the `-m` flag. A key requirement for optimal performance is a large context window, with at least 32K tokens recommended.
Key takeaway
For AI Engineers and Software Engineers seeking to integrate local code generation capabilities into their workflows, this Ollama-Codex integration offers a direct path. You can now use open-weight models like `gpt-oss:20b` to automate code tasks directly from your command line, reducing reliance on proprietary APIs. Ensure your Ollama setup provides at least a 32K token context window for effective operation.
Key insights
OpenAI's Codex CLI now integrates with Ollama, enabling local execution of open-weight code generation models.
Principles
- Open models enhance developer tooling.
- Context window size impacts model performance.
Method
Install Codex CLI, then run `codex --oss` to use local Ollama models. Specify models with `-m` flag; ensure 32K+ context window.
In practice
- Use `gpt-oss:20b` for local code tasks.
- Switch to `gpt-oss:120b-cloud` for larger models.
Topics
- OpenAI Codex
- Ollama
- Code Generation
- Large Language Models
- Context Window
Best for: AI Engineer, Machine Learning Engineer, Software Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Ollama Blog.