Skip to main content
Watch: I Built an AI App Without Leaving Databricks

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

  1. Step 1.

    Install the Codex CLI.

    Terminal
    npm install -g @openai/codex
  2. 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.

    Terminal
    ollama launch codex
  3. Step 3.

    Configure without launching.

    Terminal
    ollama launch codex --config
  4. Step 4.

    Manual setup: use the --oss flag.

    Terminal
    codex --oss
  5. Step 5.

    Use a specific local model.

    Terminal
    codex --oss -m gpt-oss:120b
  6. Step 6.

    Use a cloud model.

    Terminal
    codex --oss -m gpt-oss:120b-cloud
  7. Step 7.

    Profile-based setup: create ~/.codex/ollama-launch.config.toml with the following content.

    TOML
    model = "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"
  8. Step 8.

    Then run Codex with that profile.

    Terminal
    codex --profile ollama-launch
  9. Step 9.

    To remove the Ollama launch profile and generated model catalog.

    Terminal
    ollama 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.

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.

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.