OpenAI Codex with Ollama Integration
Ollama has integrated with the OpenAI Codex CLI, allowing users to run open-weight models locally to read, modify, and execute code within a working directory. This integration enables developers to leverage the Codex CLI's capabilities while maintaining control over their models and data through Ollama.
Local Code Execution with Open Models
Open-weight models can now be used with the OpenAI Codex CLI via Ollama. This allows the CLI to perform actions such as reading and modifying code in the local working directory and executing that code. Supported models include gpt-oss:20b and gpt-oss:120b, as well as other open-weight alternatives available through Ollama.
Setup and Configuration
To use open models with the Codex CLI, users must first install the CLI via npm:
npm install -g @openai/codex
To activate the integration, the CLI is started with the --oss flag:
codex --oss
By default, the system uses the gpt-oss:20b model. Users can specify a different model using the -m flag, for example:
codex --oss -m gpt-oss:120b
Context Window Requirements
Because Codex requires a large context window to operate effectively, Ollama recommends a minimum of 32K tokens. Users can adjust the context length settings within Ollama to meet this requirement.
Cloud Model Support
In addition to local models, all models hosted on Ollama Cloud are compatible with the Codex CLI using the --oss flag. For example, users can access cloud-hosted versions of the models:
codex --oss -m gpt-oss:120b-cloud
Sources
- OriginalOpenAI Codex with Ollama
Related
- Dispatch
- Dispatch
- Project
- Dispatch
- Dispatch