Codex CLI profiles isolate Azure from ChatGPT login
Configuring the OpenAI Codex CLI to talk to a non-default provider without disturbing existing auth.
Codex CLI supports multi-provider routing via [model_providers.X] + [profiles.X] blocks in ~/.codex/config.toml — passing --profile X swaps the entire (base_url, api_key env var, wire_api, model) tuple. For Azure OpenAI specifically, the provider block needs wire_api = "responses" (not chat) and query_params = { "api-version" = "..." }, and the model field in the profile is the Azure deployment name, not the underlying model id. This isolates the Azure-billed flow from the existing ChatGPT-login auth.json so the default codex command keeps using the subscription, and you opt in to Azure with the flag.
For any non-default codex destination (Azure, vLLM, Ollama, custom proxy), reach for the profile pattern instead of swapping global model + env vars. Wrap with a one-line shell script that calls codex --profile <name> so the per-project intent is captured.