Skip to content
English

Switch theme

// How-to · Switch models: your own key, Chinese or local models

Use Codex CLI with local or custom model providers

Codex CLI’s config file supports custom model providers that point at any OpenAI-compatible endpoint, including a local Ollama.

verified 2026-10-102 official sources

Scenario: Switch models: your own key, Chinese or local models →

Symptoms

  • You want to use Codex CLI offline or on an internal network
  • You want to use your company’s model service

Common causes

  • Only the official OpenAI provider is configured by default

How to fix

  1. Open Codex’s config file (~/.codex/config.toml) and add a model provider with its base URL and environment variable name, following the official config docs
  2. Local models: pull a model with Ollama, confirm http://localhost:11434 responds, then point the provider at it
  3. Set the default model to one served by that provider, or pass it on the command line
  4. Small local models have limited tool-calling ability; validate with simple tasks first

Official references

Compiled from official documentation and public discussions on 2026-10-10; not yet reproduced in our own environment. Follow the official docs if they differ.

Data updated: Problems & errors