Quick setup:
After installing Codex CLI, it automatically creates a default configuration file under your user directory:
Windows:
%USERPROFILE%\.codex\config.toml
Linux / macOS / WSL:
~/.codex/config.toml
Then you just edit that file,
→ add the [model_providers.openrouter]
section,
→ and update the existing model
and model_provider
lines, like this:
model = "z-ai/glm-4.5-air:free" model_provider = "openrouter" [model_providers.openrouter] base_url = "https://openrouter.ai/api/v1" env_key = "OPENROUTER_API_KEY"
Then run:
export OPENROUTER_API_KEY="sk-or-..." codex --model "z-ai/glm-4.5-air:free" --provider openrouter
Views: 2