Setup guide - Documented by GLM
Use GLM in Claude Code
Z.ai documents pointing Claude Code at its Anthropic-compatible endpoint (https://api.z.ai/api/anthropic) by setting env vars in ~/.claude/settings.json, and mapping Claude Code's Opus/Sonnet/Haiku slots to GLM-5.3 and GLM-5.3-Flash with a [1m] suffix for 1M context.
Last verified 6 steps4 official sources
Steps
- Step 1.
Install Claude Code (Z.ai's documented install command).
Terminal# Install Claude Code npm install -g @anthropic-ai/claude-code # Navigate to your project cd your-awesome-project # Complete claude - Step 2.
Get a GLM Coding Plan API key. Individual Plan users create it under Personal Coding Plan > Plan Overview (https://z.ai/manage-apikey/apikey-list). Team Plan members create it under Team Coding Plan > My Plan (https://z.ai/manage-apikey/coding-plan/team/my-plan).
- Step 3.
Option A (automated): run Z.ai's Coding Tool Helper and follow the on-screen guidance.
Terminalnpx @z_ai/coding-helper - Step 4.
Option B (manual): edit ~/.claude/settings.json and add or modify these env fields, replacing your_zai_api_key. A new window is required for changes to take effect.
JSON{ "env": { "ANTHROPIC_AUTH_TOKEN": "your_zai_api_key", "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic", "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash[1m]", "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.3[1m]", "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.3[1m]", "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000", "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1, "API_TIMEOUT_MS": "3000000" } } - Step 5.
Start Claude Code in your project. If prompted with "Do you want to use this API key," select "Yes."
Terminalcd your-project-directory claude - Step 6.
Confirm the switch: run claude, type /status, and check that Settings source shows ~/.claude/settings.json and Model shows the GLM model. Use /effort to change thinking intensity (default max).
Snippet/status
Caveats
- Z.ai's Claude Code page lists the default mapping as GLM-5.3-Flash for all three slots, while its manual config snippet maps Sonnet/Opus to glm-5.3[1m] and Haiku to glm-5.3-flash[1m]; both are on official pages.
- The [1m] suffix plus CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 enables 1M context; Z.ai says to upgrade Claude Code (claude update) if the [1m] model is reported as not existing.
- The GLM Coding Plan is limited to Z.ai's officially supported tools. Since 2026-10-16, Coding Plan keys and Standard API keys are separate and not interchangeable; a Standard key in Claude Code bills pay-as-you-go, not plan quota.
- Z.ai also offers a macOS/Linux shell script (claude_code_zai_env.sh) that writes ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL and API_TIMEOUT_MS; it is omitted here because it downloads and runs a remote script.
- Z.ai states compatibility was verified with Claude Code 2.0.14 and other versions and recommends the latest version.
More setup guides
Same tool, other providers
Related reading
- Prime Agent: A Self-Improving Coding Harness Where Everything Is PythonPrime Agent is Prime Intellect's open-source coding harness with one tool, a persistent IPython kernel. How it works, its benchmarks, and Claude Code compared.
- GLM 5.2 Outperforms Claude Code on Semgrep's IDOR Vulnerability BenchmarksGLM 5.2 vs Claude Code on Semgrep IDOR benchmarks: the open-weight model scored higher at about one-sixth the cost per finding. Setup, results and HN reactions.
- Anthropic's GLM-5.3 Cyber Report: The Numbers, the Backlash, and What Developers Should Take From ItAnthropic's GLM-5.3 cyber report: exploit numbers against Claude Mythos Preview, how its safeguards were stripped, the backlash, and the read for developers.
- GLM-5.3 Free and Cheap: Every Route and Price (October 2026)GLM-5.3 has no free hosted tier. Cheapest on October 9: Wafer via OpenRouter at $0.049/$3.39, Flash from $0.075/$0.25. Z.ai's promos ended October 7.
- Cloudflare Runs Kimi and GLM at Scale: FP8 KV Caches, INT4 Weights, and a Cache Safety NetCloudflare runs Kimi K2.6 and GLM 5.2 on Workers AI with FP8 KV caches, INT4 weights and a KV cache integrity check. What each technique buys on GPU fleets.
- Colibri: Run GLM 5.2 on a 32GB Laptop With Disk StreamingA solo developer built a 1,300-line C inference engine that runs the 744B GLM 5.2 model on consumer hardware by streaming routed experts from disk.
FAQ
How do I use GLM in Claude Code?
Z.ai documents pointing Claude Code at its Anthropic-compatible endpoint (https://api.z.ai/api/anthropic) by setting env vars in ~/.claude/settings.json, and mapping Claude Code's Opus/Sonnet/Haiku slots to GLM-5.3 and GLM-5.3-Flash with a [1m] suffix for 1M context.
Which GLM model ids work in Claude Code?
The official docs read for this guide list glm-5.3, glm-5.3[1m], glm-5.3-flash and glm-5.3-flash[1m]. Requests go to https://api.z.ai/api/anthropic.
Is this an official GLM and Claude Code setup?
GLM documents this setup in its own docs. It was last checked against 4 official pages on October 17, 2026.
Sources
Last verified against 4 official pages.
Newsletter
New models, set up the day they ship
One email per week. New model releases, the coding tools that support them and how to wire them up.