model_catalog_json catalog file so you can switch anytime from the /model list).
Installation
Official Download (macOS Version)
https://openai.com/en/codex/Install via Command Line
Environment Variable Configuration
Configure Using Configuration Files
- Modify the
~/.codex/config.tomlconfiguration file to add the following settings:
- Modify the
~/.codex/auth.jsonconfiguration file to change the following settings:
Configure via cc-switch
- Run CC-Switch and add the provider.

- Select “AiHubMix” from the preset list.

- Enter your key in the “API Key” field and click “Add” to save the settings.

- Return to the home page, select “AiHubMix” from the provider list, and click “Enable” to start using it.

Using Codex
Using in the Terminal
- Open the terminal, navigate to your project directory, and run the
codexcommand.
- Set permissions as needed.

- Select the model you need based on your requirements.

- Input natural language; if you receive a normal response, the configuration is successful.

Using in the Codex Desktop Application
- Open the Codex desktop application and select the working directory.
- Enter the task in the input box; if you receive a normal response, the configuration is successful.

Useful Command References
Help Command
Complete Command Options
Using Custom Models in Codex
By default, Codex only shows OpenAI’s official models in the/model list. If you want to pick any model available on AIHubMix (GLM, Claude, Gemini, DeepSeek, Kimi, Qwen, etc.) directly from the list, you can use the officially supported “custom models” mechanism: declare the selectable models via a local JSON file (model_catalog_json), then point requests at AIHubMix with [model_providers.aihubmix].
Official documentation: Advanced Configuration · OSS mode / local providers
Two integration approaches
The “Environment Variable Configuration” section earlier on this page covers the basic approach, while this section covers the custom models approach. The differences are as follows — choose based on your needs:
The whole process is just 4 steps: generate the catalog file → edit
config.toml → set the environment variable → restart and select a model.
Step 1: Generate the model catalog file
The catalog file is a{ "models": [ ... ] } structure, where each element in the array describes a model that can be selected in /model. Below we first explain the fields using a single fixed model, then provide a script to batch-generate the top 30.
1.1 First understand the format: a single fixed model
Below is a minimal complete catalog that has been verified to parse correctly in Codex (containing only one model,glm-5.2). Save it as ~/.codex/model-catalogs/custom-models.json and it’s ready to use; to add more models, keep appending entries with the same structure to the models array.
About
base_instructions: it is the system prompt for that model. The example uses a single sentence as a placeholder, and the model runs fine; to get coding performance closest to native Codex, replace it with the full base_instructions of any built-in model from codex debug models --bundled (that’s exactly what the batch script in the next section does).
The official catalog uses snake_case fields (
display_name, supported_in_api, visibility). Two kinds of errors both cause the entire catalog to be discarded so no model shows up in /model: missing required fields report missing field ...; using camelCase legacy formats like displayName, hidden or unrecognized values report unknown variant .... Just stick to the field set in this article to avoid them.1.2 Batch-generate the top 30
Writing multiple entries by hand makes it easy to miss fields. To write the first 30 LLMs from the AIHubMix model list API into the catalog all at once, use the script below — it clones a built-in model as a template, so the required fields (including the correctbase_instructions) are inherently complete and never missing across Codex versions. Requires curl, python3, and the installed codex CLI:
slug, display_name, description, context_window, etc.); all other required fields are cloned from the built-in template — which is exactly the field set from 1.1, except base_instructions uses the full official prompt.
The generated file is fairly large (each entry contains the fullbase_instructions, roughly 1–2 MB), which is normal. After running it, verify it parses correctly withcodex debug models(see Step 5).
Theimage_generationfilter line in the script is intentional: among thetype=llmresults, a very small number of models also carry theimage_generationtag (e.g.gpt-image-2) and aren’t suitable for conversation; the script automatically skips them before taking the first 30.
Step 2: Modify config.toml
Edit ~/.codex/config.toml, add model_catalog_json at the root level, and define the aihubmix provider:
wire_api = "responses" is critical — omitting it or setting it to chat will fail to connect. Newer versions of Codex only use OpenAI’s Responses API (/v1/responses), and AIHubMix is natively compatible with the Responses API, so you can point directly at https://aihubmix.com/v1 without building your own conversion proxy.config.toml looks roughly like this (the red boxes are the key items for this step: the root-level model / model_provider / model_catalog_json, and the [model_providers.aihubmix] section):

Step 3: Set the environment variable
Set up the environment variable specified byenv_key above (note: no spaces around =):
~/.zshrc / ~/.bashrc to persist it. Get your Key from the AIHubMix console.
Step 4: Restart and select a model
Restart the Codex App / TUI for the catalog file to take effect, then:/model, all models declared in the catalog are listed; use the arrow keys to select and Enter to confirm:

/model will also let you choose a reasoning level (effort); pick low / medium / high as needed.
Step 5: Verify it works
- Enter Codex and type
/model, confirm you can see the models declared in the catalog, and switch to one of them (e.g.glm-5.2). - Ask any question to verify the link is working. Note: don’t judge by asking “which model are you” —
base_instructionssays “You are Codex… based on GPT-5”, so all models will claim to be GPT-5 accordingly, and asking won’t reveal the real model. To confirm which model was actually called, log in to the AIHubMix console and check themodel_idof that request record on the “Logs” page — that’s the truth.
Model changed to ..., and the bottom status bar also displays the current model and context window (the image below switched to glm-5.2, window 258K):

Custom Models FAQ
-
Custom models don’t show up in
/model? Troubleshoot in order:- First run
codex debug models. If it reportsmissing field ...(most common — a required field is missing) orunknown variant ...(wrong field name/value), the entire catalog failed to parse and was discarded — just regenerate it using the “clone a built-in template” script from Step 1. - Confirm
model_catalog_jsonis written at the root level ofconfig.toml, not inside a[model_providers.*]section; - Confirm the JSON uses snake_case official fields and
visibilityislist; - If
codex debug modelscan already see all the models but the Desktop App only shows one or two with the current model displayed as “custom” — this is a known Desktop App bug: it layers an additional official-slug allowlist filter on top of the local catalog, removing non-official models from the selector (see GitHub Issues #19694, #15138). The model is in fact still called normally per themodel = "..."inconfig.toml(you can confirm in the AIHubMix logs); only the name fails to display. For correct display, use the terminalcodexCLI / TUI; on the Desktop App you can only hard-codemodel = "the model you want"inconfig.tomland wait for the official fix.
- First run
-
The catalog is a “replace”, not a “merge”.
model_catalog_jsonreplaces the entire model list rather than appending (tested: with only 2 models in the catalog,codex debug modelsshows only those 2, and all built-ingpt-5.xmodels disappear). If you want both kinds, write them all into the custom catalog together. -
Request reports a protocol error / can’t connect. Most likely the provider’s
base_urlorwire_apiisn’t configured correctly. AIHubMix requireswire_api = "responses"+base_url = "https://aihubmix.com/v1". If you’re connecting to a third party that only supports Chat Completions, you’ll need a local conversion proxy — AIHubMix users don’t need this step. -
Frequent “Reconnecting” reconnects. In some network/proxy environments WebSocket (WSS) doesn’t work; add
supports_websockets = falseto the provider section to force HTTP. -
Parsing reports
missing field ...(e.g.missing field base_instructions). The entry is missing a required field. Newer versions of Codex parse strictly, andbase_instructions,availability_nux,upgrade,supports_reasoning_summaries,support_verbosity,default_verbosity,apply_patch_tool_type,truncation_policy,supports_parallel_tool_calls,experimental_supported_toolsmust all be present. The “clone a built-in template” script from Step 1 can fill them all in at once. -
Parsing reports
unknown variant. The catalog JSON has a field name or value that Codex doesn’t recognize (commonly camelCase legacy formats likedisplayName/hidden). Switch to the snake_case field set in this article.
Reference Articles
- Official docs: Advanced Configuration | Configuration Reference
- Official built-in catalog format reference: codex-rs/models-manager/models.json
- Community guide: Codex config.toml: integrate any custom provider in 6 lines
Last updated: 2026-06-25