How to Configure GLM-5.4 in Claude Code and OpenAI Codex (Official Z.ai Coding Plan Guide)
GLM-5.4 is available to all GLM Coding Plan subscribers (Lite, Pro, and Max) with a 1M-token context window (1,048,576 tokens), 128K max output, and 1.5× weekly quota compared to GLM-5.3. Per docs.z.ai, the two agents require different Z.ai protocol endpoints: Claude Code connects via the Anthropic-compatible gateway (https://api.z.ai/api/anthropic) using glm-5.4[1m] and CLAUDE_CODE_AUTO_COMPACT_WINDOW: "1000000", while Codex CLI / Codex App requires the dedicated OpenAI Responses endpoint (https://api.z.ai/api/v1) with wire_api = "responses" and a local ~/.codex/models.json catalog.
1. Protocol endpoints & GLM-5.4 specifications
Before editing config files, confirm which Z.ai endpoint matches your client. Using the wrong protocol URL is the most common cause of 404 or model-not-found errors:
| Coding Tool | Required Endpoint | Protocol / Wire Format | Model Identifier |
|---|---|---|---|
| Claude Code (and Goose) | https://api.z.ai/api/anthropic | Anthropic Messages API | glm-5.4[1m] (or glm-5.4) |
| Codex CLI / Codex App | https://api.z.ai/api/v1 | OpenAI Responses (wire_api = "responses") | glm-5.4 (via models.json) |
| Other OpenAI-compatible tools (OpenCode, Cline, Roo Code) | https://api.z.ai/api/coding/paas/v4 | OpenAI Chat Completions | glm-5.4 |
Documented GLM-5.4 highlights (docs.z.ai)
- Loop Transformer architecture: Reuses 28 layers of the GLM-5 base model across two iterations for deeper reasoning without inflating raw parameter count.
- Context & throughput: 1M-token context window (
1,048,576tokens), 128K maximum output tokens, and streaming throughput documented at up to 200 tokens/s off-peak (70–80 tokens/s at peak load). - Capabilities: Supports Thinking Mode (
low,high,maxeffort levels), Streaming Messages, Function Calling, Context Caching, Structured Output, and multimodal inputs (text, image, and audio in Codex catalog metadata). - Automated setup option: Z.ai provides an interactive companion CLI (
npx @z_ai/coding-helper) that can install and configure GLM Coding Plan credentials for both Claude Code and Codex automatically.
2. Configure GLM-5.4 (1M context) in Claude Code
Ensure Node.js 18+ (and Git for Windows on Windows) is installed, install or update Claude Code (npm install -g @anthropic-ai/claude-code or claude update), and obtain your API key from Z.ai Open Platform (Personal Coding Plan > Plan Overview or Team Coding Plan > My Plan).
Automated configuration
npx @z_ai/coding-helper
Manual configuration (~/.claude/settings.json)
Open ~/.claude/settings.json (macOS/Linux/WSL) or %USERPROFILE%\.claude\settings.json (Windows). Merge these keys into your existing env object rather than overwriting unrelated settings:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "<YOUR_ZAI_API_KEY>",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.4[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.4[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.4[1m]"
}
}
Verify model & control thinking effort
- Open a new terminal, run
claude, and execute/status. Confirm Settings source points to yoursettings.jsonand Model displaysglm-5.4[1m](orglm-5.4). - Use
/effortinside a session to switch thinking intensity. Z.ai defaults GLM-5.4 tomaxeffort; settingthinking.typetofalse/disabled/offmaps tolow(lightweight thinking rather than switching models). - If Claude Code reports that
glm-5.4[1m]does not exist, runclaude updateso the CLI recognizes the[1m]context suffix.
3. Configure GLM-5.4 in OpenAI Codex CLI & Codex App
Install Codex CLI (npm install -g @openai/codex) or the desktop Codex App, then configure both the model catalog and provider block. Unlike Chat Completions clients, Codex requires https://api.z.ai/api/v1 with wire_api = "responses".
Step A: Create ~/.codex/models.json
Create ~/.codex/models.json (on Windows: C:\Users\<YourUsername>\.codex\models.json) with the official GLM-5.4 metadata:
{
"models": [
{
"slug": "glm-5.4",
"display_name": "glm-5.4",
"description": "Z.ai's latest flagship model",
"default_reasoning_level": "max",
"supported_reasoning_levels": [
{ "effort": "low", "description": "Light reasoning" },
{ "effort": "high", "description": "Enhanced reasoning" },
{ "effort": "max", "description": "Deep reasoning" }
],
"shell_type": "shell_command",
"visibility": "list",
"supported_in_api": true,
"priority": 0,
"base_instructions": "",
"supports_reasoning_summaries": true,
"default_reasoning_summary": "none",
"support_verbosity": false,
"apply_patch_tool_type": "freeform",
"truncation_policy": { "mode": "bytes", "limit": 10000 },
"context_window": 1048576,
"max_context_window": 1048576,
"effective_context_window_percent": 95,
"supports_parallel_tool_calls": true,
"experimental_supported_tools": [],
"input_modalities": ["text", "image", "audio"]
}
]
}
Step B: Configure ~/.codex/config.toml
Create or update ~/.codex/config.toml (Windows: C:\Users\<YourUsername>\.codex\config.toml):
model_provider = "ZAI"
model = "glm-5.4"
model_reasoning_effort = "max"
model_catalog_json = "~/.codex/models.json"
[model_providers.ZAI]
name = "ZAI"
base_url = "https://api.z.ai/api/v1"
experimental_bearer_token = "<YOUR_ZAI_API_KEY>"
wire_api = "responses"
Restart all Codex windows (or open a fresh terminal) and launch codex so the updated catalog and provider take effect.
4. Quota boundaries, permissions & common failures
- Manual config not taking effect: Close all active Claude Code or Codex windows and open a new terminal. Verify JSON/TOML syntax, confirm
~/.codex/models.jsonresolves to the same home directory used by your shell (especially when mixing Windows native shells with WSL/Git Bash), and ensureexperimental_bearer_tokenorANTHROPIC_AUTH_TOKENcontains your active Coding Plan key without extra quotes. - Wrong endpoint error: Do not point Codex at
/api/coding/paas/v4or/api/anthropic; Codex specifically requireshttps://api.z.ai/api/v1withwire_api = "responses". - Quota exhaustion behavior: All officially supported tools share one Coding Plan quota (5-hour refresh cycle + 7-day weekly limit, with GLM-5.4 receiving 1.5× weekly quota vs. GLM-5.3). When the 5-hour window is exhausted, calls pause until the next reset rather than billing your pay-as-you-go balance.
- Workspace permissions & secrets: Never commit
~/.claude/settings.jsonor~/.codex/config.tomlcontaining live API keys into a repository. Review tool permissions and MCP scopes in the official docs.z.ai documentation and our MCP server security checklist before running unattended refactors. - Related setup guides: Compare DeepSeek search & fetch setup for Claude Code & Codex, tune long sessions with Claude Code idle compaction, or track limits in Claude Code vs Codex usage limit trackers.
Frequently asked questions
What endpoint does GLM-5.4 use in Claude Code vs. OpenAI Codex?
Per docs.z.ai, Claude Code uses the Anthropic-compatible endpoint https://api.z.ai/api/anthropic with model string glm-5.4[1m], whereas Codex CLI and the Codex App require the dedicated OpenAI Responses endpoint https://api.z.ai/api/v1 with wire_api = "responses" and ~/.codex/models.json.
How do I enable the 1M context window for GLM-5.4 in Claude Code?
Append the [1m] suffix (glm-5.4[1m]) to ANTHROPIC_DEFAULT_HAIKU_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL, and ANTHROPIC_DEFAULT_OPUS_MODEL in ~/.claude/settings.json and set "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000". Upgrade Claude Code with claude update if it rejects the [1m] suffix.
Can I configure GLM-5.4 automatically instead of editing JSON and TOML files?
Yes. Z.ai provides the Coding Tool Helper CLI (npx @z_ai/coding-helper) to configure your GLM Coding Plan API key and model mappings for Claude Code, Codex, and other supported coding agents.
Does using GLM-5.4 in Claude Code or Codex charge my pay-as-you-go API balance?
No. According to the Z.ai GLM Coding Plan FAQ, requests from supported coding tools consume only your Coding Plan 5-hour and weekly quotas and will not deduct from a separate account balance once exhausted.