APIMaster.ai

GLM-5.2, GLM-5.3 and GLM-5.3-Flash in Codex: Configuration and Model Selection

Configure GLM in Codex with APIMaster. Find config.toml on Windows, macOS and Linux, set your API key, start an interactive chat and select a model.

Configure your APIMaster API key and Codex's config.toml, then run codex to chat with GLM. Use glm-5.2, glm-5.3, glm-5.3-flash. Codex connects through the Responses API at https://apimaster.ai/v1.

Before you start

Complete the environment check, install Codex following the general guide, and obtain an APIMaster API key with access to these models and sufficient balance.

codex --version

1. Open the configuration directory

Windows

Press Win + R, enter the following path and press Enter:

%USERPROFILE%\.codex

Create the folder if it does not exist. Open or create config.toml with a text editor. Make sure the filename is not config.toml.txt.

macOS / Linux

On macOS, in Finder press Command + Shift + G and enter:

~/.codex

On Linux, open the same directory with your file manager or editor. If needed, create it from the terminal:

mkdir -p ~/.codex

Open or create config.toml in this directory. If you use a custom Codex state directory, use that directory instead.

2. Configure config.toml

Both platforms use the same contents:

model = "glm-5.3"
model_provider = "apimaster"
model_reasoning_summary = "none"
model_supports_reasoning_summaries = false

[model_providers.apimaster]
name = "APIMaster"
base_url = "https://apimaster.ai/v1"
env_key = "APIMASTER_API_KEY"
wire_api = "responses"

If the file already exists, back it up and merge these settings. Replace existing top-level keys instead of duplicating them, and put them before the first [table] heading. Merge the provider section if it already exists. This changes the default provider and model for new Codex sessions.

The base URL includes /v1. Keep wire_api = "responses"; a Chat Completions endpoint alone is insufficient for this workflow. The summary settings disable optional reasoning summaries, not the model's internal thinking.

To keep your existing default provider, put this configuration in ~/.codex/glm.config.toml instead (Windows: %USERPROFILE%\.codex\glm.config.toml). Then add --profile glm to the startup commands below. Named profile files require Codex 0.134.0 or later and inherit other base settings.

3. Set your API key

Replace YOUR_APIMASTER_API_KEY with the key from APIMaster. The TOML configuration stores the environment variable's name, not the key itself.

Windows PowerShell

Run in the terminal where you will launch Codex:

$env:APIMASTER_API_KEY = 'YOUR_APIMASTER_API_KEY'

To also save it for future terminals:

[Environment]::SetEnvironmentVariable('APIMASTER_API_KEY', 'YOUR_APIMASTER_API_KEY', 'User')

Open a new terminal after saving a persistent variable, or keep using the current terminal where you ran the first command.

macOS / Linux

export APIMASTER_API_KEY='YOUR_APIMASTER_API_KEY'

This applies to the current terminal. To reuse it in new terminals, add the same export line to your shell's startup file, such as ~/.zshrc for Zsh or ~/.bashrc for interactive Bash, then open a new terminal. Keep files containing real keys private and outside shared repositories.

4. Start Codex and chat

Open a terminal in your project directory and run:

codex

After the normal first-run or project trust prompts, check that the active model is glm-5.3. In the Codex conversation, enter:

Reply with exactly OK.

A normal reply confirms the basic connection. You can then ask it to explain code, read a file or make a change. Review the usual file and command permission prompts.

5. Select another model

For these custom model IDs, choose the model explicitly when starting Codex. Run one command at a time in your terminal:

codex --model glm-5.2
codex --model glm-5.3
codex --model glm-5.3-flash

Each command opens an interactive conversation. To switch from an open session, enter /exit, then run the command for the desired model. To continue an existing saved conversation with another model, use codex resume SESSION_ID --model MODEL_ID instead of starting a new conversation.

In Codex, /model opens its model catalog and /status shows the active model. The menu does not automatically list every model in APIMaster's model marketplace. If your GLM model is absent, use --model as above. Do not assume Claude Code's /model MODEL_ID syntax works in Codex; it is not the verified custom-model selection path here.

For the optional named profile, for example:

codex --profile glm --model glm-5.3

To change the default for future starts, edit the top-level model value in the configuration you use.

Troubleshooting

Symptom Check
Missing API key / 401 Set APIMASTER_API_KEY in the terminal that starts Codex; check key validity and balance.
Still using another provider Check model_provider, the selected profile, project overrides and startup flags. Restart after editing configuration.
TOML parse error Avoid duplicate keys or tables; top-level settings must precede table headings.
404 / unsupported protocol Use https://apimaster.ai/v1 and wire_api = "responses".
Model absent from /model Use the full model ID with codex --model. The built-in catalog is not the gateway's model list.
Model metadata or model-list warning These IDs may lack Codex metadata. Check the final reply; fallback context limits are not verified model capabilities.
Reasoning/output stream warning Check the final answer and tool results. Report interrupted output with the model, CLI version, UTC time and request ID if available.

Validation and optional tool check

Recorded integration tests: 2026-09-15 UTC, Codex CLI 0.154.0, Linux. All models listed here returned the expected text and used a tool to read a local file. All three also fixed a small Python function and ran its tests; the test file was independently checked and rerun. Windows and macOS configuration instructions are provided, but those operating systems were not part of the recorded runs. These checks do not establish full feature compatibility, long-session behavior or maximum context limits.

To check file tools, create probe.txt in a temporary project containing:

FILE_PROBE_739182

Start Codex there with your chosen model, then enter:

Read probe.txt using a tool and reply with its exact contents. Do not guess.

Confirm that a file-reading tool runs and the answer matches the file. Use this after the basic conversation works.

FAQ

Does this use my ChatGPT subscription?

Requests use your APIMaster key and balance. Codex is the client; GLM is the selected model. This configuration does not make GLM an OpenAI model.

Why does Claude Code use a different URL?

Codex uses https://apimaster.ai/v1 for Responses. Claude Code uses the site root https://apimaster.ai and appends /v1/messages itself.

Related guides and sources