Quick setup
OpenAI's configuration docs say Codex can run against a local open-source provider such as Ollama or LM Studio when you pass --oss. Choose the provider for one run with --local-provider, or set a default:
# ~/.codex/config.toml
oss_provider = "ollama" # or "lmstudio"Ollama's Codex page adds ollama launch codex (and --config / --restore), and shows codex --oss -m gpt-oss:120b for a specific model. Without -m, Codex uses gpt-oss:20b on Ollama (source). LM Studio has its own Codex guide.
Both tools need a large context: Ollama's docs ask for 64K tokens or more, while its default on most Macs is 4K (under 24 GiB) or 32K (24–48 GiB). Raise it in the Ollama app's settings or with OLLAMA_CONTEXT_LENGTH=65536 ollama serve, and check ollama ps (context length docs).
A custom provider in config.toml
From OpenAI's docs, a provider block for a local Ollama server:
[model_providers.local_ollama]
name = "Ollama"
base_url = "http://localhost:11434/v1"Ollama's launch profile uses the Responses API (wire_api = "responses"); Codex no longer supports the older chat wire format.
Which Mac and model
| Model | Memory at 64K | Mac mini M6 16GB | Mac mini M6 32GB | Mac mini M5 Pro 48GB | Mac mini M5 Pro 64GB | Mac Studio M5 Max 128GB |
|---|---|---|---|---|---|---|
| Qwen3-Coder-Next 80B-A3B (Q4_K_M) | ~75 GB | too tight | too tight | too tight | too tight | ~142 tok/s |
| Devstral Small 2 24B (Q4_K_M) | ~29 GB | too tight | too tight | ~15.3 tok/s | ~15.3 tok/s | ~30.7 tok/s |
| GLM-4.7-Flash 30B-A3B (Q4_K_M) | ~34 GB | too tight | too tight | ~72.7 tok/s | ~72.7 tok/s | ~145 tok/s |
| Qwen3 Coder 30B-A3B (Q4_K_M) | ~34 GB | too tight | too tight | ~67.2 tok/s | ~67.2 tok/s | ~134 tok/s |
| gpt-oss 20B (MXFP4) | ~27 GB | too tight | ~31.9 tok/s | ~57.6 tok/s | 61.0 tok/s | ~115 tok/s |
gpt-oss 20B, Codex's default, fits a 32 GB Mac with a 64K context; gpt-oss 120B needs a 96–128 GB Mac (see gpt-oss-120b requirements).
FAQ
How do I use Codex CLI with Ollama?
What model does codex --oss use?
Can Codex use LM Studio?
See any model on the exact Mac you're considering.
- OpenAI: Codex advanced configuration
- Ollama: Codex integration
- Codex source: default Ollama model
- LM Studio: Codex
- Ollama: context length
Speeds come from published measurements (with source links) or labeled estimates. How we measure