GLM is one of the easiest cheap models to run with Claude Code because Z.AI ships an Anthropic-compatible endpoint — no proxy, no router, just two environment variables. Combined with the GLM Coding Plan, which starts at $18/month, it’s one of the best-value ways to keep using Claude Code without Anthropic’s bill.
This is the setup, the model lineup, and the plan details (including the usage window everyone forgets about). For the no-proxy approach in general, see anthropic-compatible endpoints.
Step 1: Get a Z.AI key or coding plan
Sign up at Z.AI. You can pay per token or subscribe to the GLM Coding Plan (from $18/month), which is designed to work with Claude Code and other coding tools. Either way you get an API key.
Step 2: Make sure Claude Code is installed
npm install -g @anthropic-ai/claude-code
Step 3: Point Claude Code at GLM
Z.AI’s Anthropic-compatible endpoint is the key. In WSL (recommended on Windows):
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-zai-key"
export ANTHROPIC_MODEL="glm-5"
claude
On native Windows PowerShell:
$env:ANTHROPIC_BASE_URL = "https://api.z.ai/api/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "your-zai-key"
$env:ANTHROPIC_MODEL = "glm-5"
claude
That’s the whole setup. Confirm the exact base URL in Z.AI’s docs, since paths can change.
Step 4: Choose the model
GLM models (availability varies by plan)
| glm-5 | Flagship; strongest (Pro plan) |
|---|---|
| glm-5-turbo | Faster, cheaper; all plans |
| glm-4.7 | Previous flagship; solid coding |
| glm-4.5-air | Lightweight; cheapest |
Set ANTHROPIC_MODEL to whichever your plan includes. glm-5-turbo is a strong, fast default if you’re not on Pro.
Pricing and the coding plan
Z.AI offers both billing models:
- GLM Coding Plan — flat subscription from $18/month, built to work with Claude Code, Cline, Kilo Code, and similar tools. Predictable, and cheapest for heavy daily use.
- Pay-per-token — standard API rates per million tokens for lighter use.
See GLM Coding Plan setup for plan specifics and GLM-4.6 vs GLM-5 vs GLM-5-Turbo to pick a model.
Verify
claude
# then: "summarize this repo and suggest one improvement"
If it reads files and answers, GLM is serving Claude Code. Switch models by changing ANTHROPIC_MODEL.
Troubleshooting
- Auth errors — token not set in the current shell, or wrong key.
- Access denied on glm-5 — your plan tier doesn’t include it; use
glm-5-turbo. - Format errors — confirm you’re on the
/anthropicendpoint, not the OpenAI one. - Hit a wall mid-session — you reached the plan’s rolling-window cap; wait for reset or check your tier.
GLM-5 + Claude Code checklist
- Z.AI key or GLM Coding Plan active
- Claude Code installed
- ANTHROPIC_BASE_URL set to Z.AI's /anthropic endpoint
- ANTHROPIC_AUTH_TOKEN and ANTHROPIC_MODEL set
- Model matches your plan tier (glm-5 needs Pro)
Wrapping up
Running GLM-5 with Claude Code needs no proxy: set ANTHROPIC_BASE_URL to Z.AI’s /anthropic endpoint, add your token, and pick a model your plan covers. The GLM Coding Plan from $18/month makes it one of the cheapest flat-rate ways to keep Claude Code, just mind the rolling usage window.
For the plan details, see GLM Coding Plan setup; to use GLM elsewhere, see GLM-5 with Codex CLI or GLM + Cline.