A GLM-5.4 Claude Code setup takes three moves: subscribe to Z.ai's GLM Coding Plan, point ANTHROPIC_BASE_URL at https://api.z.ai/api/anthropic, and map Claude Code's model slots to glm-5.4[1m] in ~/.claude/settings.json. In Cursor, add a custom OpenAI model with the base URL https://api.z.ai/api/coding/paas/v4 and the model name GLM-5.4 in uppercase.
Below: which model goes in which slot, why Cursor wants capitals, what a session costs in plan credits, and fixes for the common errors.
What you need before you start
GLM-5.4 is Z.ai's new flagship coding model, built on a Loop Transformer that runs a block of layers twice per token. It has a 1M-token context window and 128K max output, per the GLM-5.4 model page. Today you can only reach it through the GLM Coding Plan.
You need three things:
- A GLM Coding Plan subscription. Lite, Pro and Max all include GLM-5.4. Plans start at $18 a month, according to the Coding Plan overview.
- A Coding Plan API key. Create it under Personal Coding Plan > Plan Overview on z.ai. A pay-as-you-go API key won't work: Z.ai treats plan keys and standard keys as separate.
-
A current version of your tool. Older Claude Code builds don't recognize the
[1m]suffix.
Here's how each tool connects:
| Tool | Protocol | Base URL | Model name |
|---|---|---|---|
| Claude Code | Anthropic Messages | https://api.z.ai/api/anthropic |
glm-5.4[1m] or glm-5.4
|
| Cursor | OpenAI-compatible | https://api.z.ai/api/coding/paas/v4 |
GLM-5.4 (uppercase) |
One rule shapes everything below. Z.ai's usage policy limits the plan to officially supported tools. Claude Code and Cursor are both on that list, so you're fine in either. Don't reuse the key in your own scripts or apps.
How to use GLM-5.4 in Claude Code
Claude Code is the best-documented path. These steps assume you already have it installed (npm install -g @anthropic-ai/claude-code).
- Update Claude Code with
claude update, so the[1m]model names resolve. - Open
~/.claude/settings.json. Add or update theenvblock; don't overwrite other settings in the file. - Paste this configuration and replace the key:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_zai_coding_plan_key",
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.4[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.4[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash[1m]",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
"API_TIMEOUT_MS": "3000000"
}
}
- Open a new terminal,
cdinto your project and runclaude. If it asks "Do you want to use this API key," pick Yes. - Type
/status. The settings source should show yoursettings.json, and the model line should readglm-5.4orglm-5.4[1m].
Which model goes in which slot
Claude Code sends work to three slots. Opus and Sonnet handle your main conversation and planning. Haiku handles quick background tasks such as titles and short summaries.
Z.ai documents two mappings. Its model switching guide maps all three slots to glm-5.4[1m]. Its Claude Code setup page puts glm-5.3-flash[1m] on Haiku. Pick the Flash mapping above if you're on Lite and watching credits: GLM-5.3-Flash costs half of GLM-5.4 per input token.
The [1m] suffix turns on the full 1M-token context. Pair it with CLAUDE_CODE_AUTO_COMPACT_WINDOW set to 1000000, or Claude Code will compact your conversation long before the model needs it. API_TIMEOUT_MS comes from Z.ai's setup script and gives slow, deep-thinking answers room to finish.
Use GLM-5.4 in one project only
You don't have to switch every project at once. Claude Code reads several settings files: ~/.claude/settings.json applies everywhere, while .claude/settings.local.json inside a project applies to that project only and stays out of git. Put the env block there to trial GLM-5.4 on one repo while the rest keep your usual model.
Never put the key in a shared .claude/settings.json that you commit. Teammates would pull your key along with the config.
Set the thinking effort
GLM-5.4 thinks at max effort by default. Type /effort in a session to change it. Z.ai maps whatever Claude Code sends to three real levels:
| Claude Code sends | GLM-5.4 uses |
|---|---|
| Thinking on, adaptive, or nothing | max |
| Thinking off | low (still thinks lightly) |
| Effort low | low |
| Effort medium or high | high |
| Effort xhigh or max | max |
Z.ai recommends max for coding. Drop to high for routine edits: the model page warns that GLM-5.4 can fall into long "marathon thinking" loops, and every thinking token is an output token you pay for in credits.
How to use GLM-5.4 in Cursor
Cursor talks to GLM-5.4 through its OpenAI-compatible custom model setting. Z.ai's Cursor guide lists these steps:
- Open Cursor Settings > Models and click Add Custom Model.
- Select the OpenAI protocol.
- Paste your Coding Plan key into the OpenAI API Key field.
- Turn on Override OpenAI Base URL and enter
https://api.z.ai/api/coding/paas/v4. - Enter the model name as
GLM-5.4, in uppercase. - Save, then pick the new GLM model in the model picker for Agent or Chat.
The uppercase name is the most common snag. Z.ai's guide flags it as a requirement for Cursor, even though every other tool uses lowercase glm-5.4. If Cursor says the model doesn't exist, check the capitals before anything else.
What Cursor's custom model setting doesn't cover
Three limits come from Cursor's own API key documentation, and they matter before you commit:
- Chat models only. Your key powers Agent and Chat. Tab completion keeps using Cursor's built-in models.
- Requests pass through Cursor's servers. Cursor sends your key to its backend with each request for prompt building, and doesn't store it. Its Zero Data Retention policy doesn't apply to your own-key requests.
- Plan limits. Cursor's Plus plan doesn't allow your own API keys. On Teams and Enterprise, own-key requests can carry Cursor's token rate on top of what Z.ai charges.
Claude Code vs Cursor for GLM-5.4
Both work, but they suit different habits:
| Claude Code | Cursor | |
|---|---|---|
| Connection | Anthropic endpoint, direct from your machine | OpenAI endpoint, through Cursor's backend |
| 1M context | Yes, with [1m] and the compact window |
Depends on Cursor's context handling |
| Effort control |
/effort in session |
Cursor's own model settings |
| Covers | Every Claude Code task | Agent and Chat, not Tab |
| Setup | One JSON block | Six clicks in Settings |
Pick Claude Code if you want the full 1M-token context and the documented effort controls. Pick Cursor if you live in the editor and only need GLM-5.4 for agent runs. You can also run both from one plan: the key works in either tool, and both draw on the same credits.
If your team runs several Claude Code agents on GLM-5.4 at once, Sharkly gives you one board to assign them tasks and review what they return, with each agent running on your own machines and plan. It's free to start.
What a GLM-5.4 session costs in plan credits
GLM-5.4 has no per-token API price yet, so on the Coding Plan you spend credits:
$$\text{credits} = \frac{\text{input} \times 4.6 + \text{cached} \times 1.1 + \text{output} \times 16}{10{,}000}$$
Those multipliers come from the Coding Plan overview. GLM-5.3 costs 6.9, 1.7 and 24, so GLM-5.4 is about a third cheaper per token on the plan.
A worked example: one Claude Code turn reads 100K tokens and writes 10K.
- No cache: (100,000 × 4.6 + 10,000 × 16) / 10,000 = 62 credits.
- 90K of it cached: (10,000 × 4.6 + 90,000 × 1.1 + 10,000 × 16) / 10,000 = 30.5 credits.
Lite gives you 2,000 credits per 5-hour window and 10,000 a week. That's about 32 uncached turns or 65 cached ones per window. Long sessions on the same files hit the cache, which is one more reason to keep the context in one session instead of restarting.
Troubleshooting GLM-5.4 setup
Error 1113 "Insufficient Balance" on a paid plan. Your requests missed the plan and hit your pay-as-you-go balance. Z.ai's FAQ names the causes: a wrong base URL, an unsupported tool, or a model outside GLM-5.4, GLM-5.3 and GLM-5.3-Flash. Claude Code needs /api/anthropic; Cursor needs /api/coding/paas/v4.
Claude Code says glm-5.4[1m] doesn't exist. Run claude update and start a new session.
Settings changes don't take effect. Close every Claude Code window and open a fresh terminal. Then check the JSON for a missing or trailing comma.
Cursor can't find the model. Use GLM-5.4, not glm-5.4, and confirm the base URL override is switched on.
Let Claude Code test your API with Apidog CLI
A new model writes different code. If GLM-5.4 now edits your backend, check the endpoints it touched before you merge, and let the same agent do it with Apidog CLI, so the model writes the fix and the test in one session.
Install the CLI and the agent skill once:
npm install -g apidog-cli@latest
apidog auth login --with-token <YOUR_TOKEN>
apidog skill install
Then give Claude Code, now running on GLM-5.4, one prompt:
Use Apidog CLI on project <projectId>. List the endpoints and match them to
the routes you changed in this session. For each changed endpoint, create a
test case that checks the status code and response schema, run it against
the dev environment, and fix the code until it passes.
The agent reads the project, writes a case per changed route, and runs it:
apidog endpoint list --project <projectId>
apidog environment list --project <projectId>
apidog cli-schema get test-case-create
apidog test-case create --project <projectId> --file case.json
apidog run --test-case <caseId> --project <projectId> -e <envId> -r cli,json
Each command returns JSON with agentHints.nextSteps, so the agent knows what to run next. Add -r junit and the same run works in CI. The Apidog CLI in Claude Code guide covers the agent setup end to end, and Apidog CLI in Cursor does the same for the editor. Apidog is free for teams of up to 4 users.
For an earlier walkthrough of this setup with the previous model, see GLM-5.3-Flash in Claude Code and Cline.
FAQ
Can I use GLM-5.4 in Claude Code for free? No. GLM-5.4 needs a GLM Coding Plan subscription, which starts at $18 a month. Z.ai hasn't opened a pay-as-you-go GLM-5.4 API or released open weights as of November 24, 2026.
What's the difference between glm-5.4 and glm-5.4[1m]? Same model. The [1m] suffix tells Claude Code to use the full 1M-token context window. Set CLAUDE_CODE_AUTO_COMPACT_WINDOW to 1000000 alongside it.
Why does Cursor need GLM-5.4 in uppercase? Z.ai's Cursor guide requires the uppercase name for Cursor specifically. Other tools, including Claude Code and Cline, use lowercase glm-5.4.
Does GLM-5.4 work with Cursor Tab completion? No. Cursor's own-key models only power Agent and Chat. Tab keeps using Cursor's built-in models.
How do I switch back to Claude models? Remove the env block from your settings file, or move it to .claude/settings.local.json in the projects where you want GLM-5.4, then restart Claude Code.



Top comments (0)