Codex can call GLM-5.3 through Z.AI’s OpenAI Responses-compatible endpoint. The provider belongs in ~/.codex/config.toml, while the API key stays in an environment variable.
GLM-5.3 is a text-only reasoning model with a 1-million-token context window. It always reasons and supports low, high, and max effort levels. The Codex client decides which provider features it can expose through a custom model.
Install Codex and create a Z.AI key
Use the current Codex Windows and WSL installation guide, then create a key in the Z.AI console for the service you intend to use.
If you have a GLM Coding Plan, follow Z.AI’s supported-tool rules. Coding Plan quota is not general application API credit.
Add the provider to config.toml
Open ~/.codex/config.toml and merge in this configuration:
model = "glm-5.3"
model_provider = "zai"
[model_providers.zai]
name = "Z.AI"
base_url = "https://api.z.ai/api/v1"
env_key = "ZAI_API_KEY"
wire_api = "responses"
Z.AI lists https://api.z.ai/api/v1 for the OpenAI Responses protocol. Do not use the Anthropic endpoint in Codex.
Export the key
In WSL or another POSIX shell:
export ZAI_API_KEY="YOUR_ZAI_API_KEY"
codex
In PowerShell:
$env:ZAI_API_KEY = "YOUR_ZAI_API_KEY"
codex
This sets the key only for the current terminal session. Use your normal secret-management method if you need it to persist. Do not put the raw key in config.toml or commit it to a repository.
Verify the provider
Start Codex in a small test repository and ask it to inspect a file before making a limited edit. If the provider is configured correctly, the request will use glm-5.3 through the zai provider.
If a request fails, check these items:
- A 401 or authentication error usually means
ZAI_API_KEYis missing from the terminal that launched Codex. - A model error usually means the model ID is misspelled. Use
glm-5.3. - A protocol or route error usually means the base URL and
wire_apido not match. Use/api/v1withresponses. - Image prompts will not work because GLM-5.3 currently accepts text only.
GLM-5.3 Codex check
- Install a current Codex CLI release
- Create a Z.AI key for the intended service
- Set the provider base URL to https://api.z.ai/api/v1
- Set wire_api to responses and model to glm-5.3
- Export ZAI_API_KEY before starting Codex
This setup keeps the provider details separate from the secret and uses Z.AI’s current Responses route. If Z.AI changes the model later, update the model name only after checking its migration notes for protocol or reasoning changes.
For a direct Anthropic-format connection, see GLM-5.3 with Claude Code. For provider configuration in general, see Codex custom providers.