// 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
- 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 - Local models: pull a model with Ollama, confirm
http://localhost:11434responds, then point the provider at it - Set the default model to one served by that provider, or pass it on the command line
- 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.