Codex CLI Model Provider Picker (0.168+): Add QCode, Make It Default, Switch per Session and Profile
Since Codex CLI 0.168.0 (2026-11-13), the terminal UI lets you browse configured model providers under Sessions → Model providers and choose which one new chats use by default; chats that are already open or resumed keep the provider they were saved with. Version 0.169.0, released the same day, added adding and editing custom providers from the terminal. In this guide, the provider is defined in [model_providers.<id>] in ~/.codex/config.toml. This guide defines QCode as a provider, makes it the default, switches it per run or per profile, and covers what to check when switching doesn't take effect. As of 2026-11-25 the latest Codex CLI is 0.172.0.
QCode is an independent third-party API service and is not affiliated with OpenAI. Versions and features follow OpenAI's Codex changelog and configuration docs on learn.chatgpt.com; QCode settings follow docs.qcode.cc.
Updated 2026-11-26
Key facts
- 0.168.0 (2026-11-13): browse providers under Sessions → Model providers and choose the default for new chats. Open and resumed chats use their saved provider after you change that default.
- 0.169.0 (2026-11-13): add or edit custom model providers from the terminal; with custom gateway onboarding enabled you can create a provider during sign-in; Codex warns when a CLI-specified model is absent from the ChatGPT model list.
- 0.171.0 (2026-11-20): GPT-6.2 Sol and Astra added to model catalogs with Sol as the default selection; the TUI now uses the provider-default RPC.
- In config:
model_providerdefaults toopenai;openai,ollamaandlmstudioare reserved IDs that can't be overridden;wire_apifor custom providers supports onlyresponses. - Since 0.134.0, profiles are separate files,
~/.codex/<name>.config.toml, selected with--profile/-p. Old[profiles.<name>]tables are no longer read.
Step 1: define QCode as a provider
The picker only chooses; the provider has to exist first. Edit ~/.codex/config.toml (%USERPROFILE%\.codex\config.toml on Windows):
# Keep the official provider as default; QCode is an extra option
model = "gpt-6.2-sol"
[model_providers.qcode]
name = "QCode"
base_url = "https://api.qcode.cc/openai"
wire_api = "responses"
env_key = "QCODE_API_KEY"
# Optional: tune retries for flaky networks
request_max_retries = 4
stream_max_retries = 5
Then set the key:
# macOS / Linux
echo 'export QCODE_API_KEY="cr_your_key"' >> ~/.zshrc && source ~/.zshrc
# Windows (user scope; reopen the terminal)
[Environment]::SetEnvironmentVariable('QCODE_API_KEY', 'cr_your_key', 'User')
Notes:
- The provider ID (
qcodehere) is up to you, but notopenai,ollamaorlmstudio; those are reserved built-ins. base_urlmust behttps://api.qcode.cc/openai, without/v1or a trailing slash. In Asia you can usehttps://asia.qcode.cc/openai; in North America or Europe,https://us.qcode.cc/openai.- QCode's docs also support
requires_openai_auth = truewithauth.json, but don't combine it withenv_keyin one provider. If you also want to keep the official "Sign in with ChatGPT" provider,env_keyfor QCode is the safer choice:requires_openai_authmakes the provider use OpenAI-style auth, which may shareauth.jsonwith the ChatGPT sign-in. That combination is not tested here; if you rely on it, test that both providers coexist with a small request first. - Field meanings from the official config reference:
nameis the display name;env_keyis the environment variable holding the key;request_max_retriesdefaults to 4;stream_max_retriesdefaults to 5;stream_idle_timeout_msdefaults to 300000.
Step 2: make it the default for new chats
Two ways, same effect.
Option A: pick it in the TUI. Upgrade to 0.168.0 or later (check with codex --version), start codex, open Sessions → Model providers and choose "QCode" as the default for new chats. Every new chat then uses QCode. The chat you have open, and chats you bring back with codex resume, don't change; they keep their saved provider, which 0.168.0 made explicit.
Option B: put it in the config file. Add one top-level line to config.toml:
model_provider = "qcode"
The value must match the [model_providers.<id>] ID exactly. This suits setups you want pinned across machines, CI or a team template.
Step 3: switch per run or per profile
The usual need is "default to A, sometimes use B". Codex has several layers, from highest to lowest priority:
| Method | How | Scope | Good for |
|---|---|---|---|
| CLI override | codex -c model_provider=qcode -m gpt-6.2-astra |
This run only | Trying a model once |
| Project config | .codex/config.toml in the repo |
That project (trusted projects) | Pinning a provider per repo |
| Profile | codex -p qcode-astra |
Whenever you pass the profile | Combinations you reuse |
| User config | ~/.codex/config.toml |
Default | Most chats |
Per the official docs, a profile sits above your base user config and below project and CLI config; when several files define the same key, the file closest to your working directory wins; and -c / --config overrides a key for one run, parsing the value as TOML when it can.
Write a profile file. The file name is the profile name (letters, numbers, hyphens and underscores):
# ~/.codex/qcode-astra.config.toml
model_provider = "qcode"
model = "gpt-6.2-astra"
model_reasoning_effort = "high"
Use it:
codex -p qcode-astra
codex exec --profile qcode-astra "review this change"
Keep the [model_providers.qcode] definition in the main config.toml and put only top-level keys in profile files, as the docs require (don't nest them under [profiles.<name>]). If your old config still has [profiles.<name>] tables and a profile = "<name>" selector, Codex stopped reading them in 0.134.0; move each into its own file and delete the old tables. See Related reading for profile and MCP combinations.
Which models work in Codex through QCode
Custom Codex providers speak only the Responses protocol (wire_api = "responses" is the only value). Per QCode's endpoint docs:
| Model family | Responses API on QCode | Usable in Codex? |
|---|---|---|
GPT (e.g. gpt-6.2-sol, gpt-6.2-astra) |
Supported | Yes |
| Claude | Not supported (Anthropic only) | No; use Claude Code |
| GLM / Kimi / DeepSeek / Qwen | Not supported (Anthropic or OpenAI Chat) | No |
Check live prices on /models. For reference, OpenAI's list prices for the 2026-11-17 release are $2 input / $10 output per million tokens for GPT-6.2 Sol and $8 / $40 for Astra; QCode currently bills OpenAI models at a ×1.0 multiplier.
A practical multi-provider layout
To keep the official sign-in and QCode side by side and switch when needed:
# ~/.codex/config.toml
model = "gpt-6.2-sol"
# No model_provider line: the default stays openai (ChatGPT sign-in)
[model_providers.qcode]
name = "QCode"
base_url = "https://api.qcode.cc/openai"
wire_api = "responses"
env_key = "QCODE_API_KEY"
[model_providers.qcode-asia]
name = "QCode Asia"
base_url = "https://asia.qcode.cc/openai"
wire_api = "responses"
env_key = "QCODE_API_KEY"
Sessions → Model providers then shows the official provider, "QCode" and "QCode Asia". When your subscription allowance runs out, switch the default for new chats to QCode; when the network is unstable, switch to the nearer endpoint. Chats already running are left alone.
When switching doesn't work
| Symptom | Likely cause | Fix |
|---|---|---|
| QCode missing from the picker | Version below 0.168.0, or a config.toml syntax error |
Upgrade (codex --version); check the table is [model_providers.qcode] |
| Custom ID ignored | Used reserved openai / ollama / lmstudio |
Pick another ID such as qcode |
| Changed the default, current chat didn't change | By design since 0.168.0: open/resumed chats keep their provider | Start a new chat, or run codex -c model_provider=qcode |
-p has no effect |
Still using old [profiles.<name>] tables |
Move to ~/.codex/<name>.config.toml |
401 with You didn't provide an API key |
The env_key variable is empty or the terminal wasn't reopened |
echo $QCODE_API_KEY; reopen the terminal |
Invalid API key |
Key truncated or has spaces | Copy the full cr_ key again |
not_found |
base_url has /v1 or a trailing slash |
Set it to https://api.qcode.cc/openai |
| Warning that the model isn't in the ChatGPT model list | The 0.169.0 warning | Safe to ignore if the model is on QCode's /models |
model_not_available_on_endpoint |
A Claude or Chinese model ID in Codex | Use GPT models in Codex |
To see what the current chat is actually using, type /status in the session.
FAQ
Where is the Codex CLI model provider picker, and which version added it?
Version 0.168.0 (2026-11-13) added it under Sessions → Model providers in the TUI, where you browse providers and pick the default for new chats. Version 0.169.0, the same day, added adding and editing custom providers from the terminal.
I changed the default provider. Why is my current chat still on the old one?
That's intended. The 0.168.0 changelog says open and resumed chats use their saved model provider after you change the default for new chats. Start a new chat to use the new default.
Can I name my provider openai ?
No. openai, ollama and lmstudio are reserved built-in IDs and can't be overridden. Use your own ID, such as qcode, and make model_provider match it exactly.
Do old [profiles.<name>] tables still work?
No. The official docs say Codex 0.134.0 and later no longer read [profiles.<name>] from config.toml. Create ~/.codex/<name>.config.toml for each profile with top-level keys, then select it with codex -p <name>.
How do I use QCode for one run without changing the default?
Use a CLI override: codex -c model_provider=qcode, adding -m gpt-6.2-astra if you want a different model. -c applies to that run only and doesn't touch your config files.
Can I use Claude or GLM in Codex through QCode?
No. Custom Codex providers only speak the Responses protocol, while QCode serves Claude only on the Anthropic API and Chinese models on Anthropic and OpenAI Chat. Use GPT models in Codex; Claude and Chinese models work in Claude Code with the same key.
Should I use env_key or requires_openai_auth ?
One or the other, never both in one provider. Either works if QCode is your only provider. If you also keep the official ChatGPT sign-in provider, env_key for QCode is the safer choice so it doesn't share auth.json with the official sign-in. We haven't tested the two coexisting; try a small request first.
Daily-35 plan: for people who live in Codex
If Codex is your main tool every day, QCode's Daily-35 plan fits: $53.57 per 30 days for $35 of usage per day, resetting at midnight Beijing time. At GPT-6.2 Sol list prices ($2 input / $10 output per million tokens), $35 is roughly 17.5 million input tokens or 3.5 million output tokens; real usage depends on cache hits and output share. The same key also runs Claude in Claude Code. See /pricing for current prices.