GLM 5.2
in Claude Code
Setup tutorial · 5x cheaper than Opus · Per-project switching · June 2026
glm-5.2claude-codevscodeopen-source
Provenance Labs · Gambit (Hermes)High Confidence
Executive Summary
GLM 5.2 is a 756B parameter open-source model you can route into Claude Code via Z.ai. 5x cheaper than Opus 4.8. Handles ~80% of knowledge work. One config file, per-project switching, works in VS Code extension.
5 Min SetupZ.ai API key + one JSON config in .claude/settings.local.json. No CLI changes.
5x CheaperInput $1.40 vs $5. Output $4.40 vs $25. Plans from $16/mo.
Per-ProjectDifferent config per folder. VS Code extension inherits automatically.
80/20 RuleGLM for most tasks. Opus for heavy reasoning. Models are engines, harness is the car.
Setup: Steps 1-3
API key, config file, verify
Step 1: z.ai → create account → pick plan ($16/$64/$144) → API Keys → copy key.
Step 2: Drop config into .claude/settings.local.json.
Step 3: Open Claude Code → verify "GLM 5.2 1M context" in header.
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-z-ai-key",
"ANTHROPIC_API_KEY": "",
"API_TIMEOUT_MS": "3000000",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.2",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.2",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.2",
"ANTHROPIC_SMALL_FAST_MODEL": "glm-5.2",
"CLAUDE_CODE_SUBAGENT_MODEL": "glm-5.2"
}
}
All model defaults → glm-5.2. Timeout 50 min. Auth via Z.ai key.
Per-Project Switching + VS Code
One config per folder, zero friction
Claude Code is a harness. The model is the engine. Switch engines by changing which folder you open.
~/projects/
glm-project/
.claude/settings.local.json ← GLM 5.2
opus-project/
(no config) ← Default Opus
- Terminal:
cd glm-project && claude → GLM. cd opus-project && claude → Opus.
- VS Code: extension reads same .claude/settings.local.json per workspace. Open workspace in glm-project → uses GLM. Open in opus-project → default Opus.
- No manual switching. The right model loads based on where you are.
When GLM 5.2 Wins
80% of your knowledge work, 5x cheaper
GLM 5.2: 3m 59s for a design task that took Opus 14m 59s. Equivalent quality. Creative, fast, cheap.
- Creative one-shot builds: "Build me an interactive HTML page" → solid, often faster than Opus
- Design work: landing pages nearly indistinguishable from Opus in side-by-side tests
- Storm research: multi-agent research with subagents and verification -- skill orchestration matters more than model
- Documentation + boilerplate: READMEs, configs, slide decks, reports
- 80% of daily tasks: anything that doesn't require deep multi-step reasoning
When Opus Is Still Necessary
The 10-20% that demands precision
GLM: 24 min vs. Opus: 5 min on complex reasoning. GLM missed duplicate record edge cases (true vs 1) that Opus caught.
- Heavy reasoning: multi-step logic with deep context. GLM can be 5x slower on these.
- Subtle edge cases: type coercion, null handling, boundary conditions
- Complex debugging: intricate logic across multiple files
- Strategic thinking: "Based on all this data, what matters and how do I apply it?"
- Rule of thumb: start with GLM. If it struggles or takes >3x longer, switch to Opus.
Benchmarks
Where GLM 5.2 stacks up against closed-source models
GLM 5.2 is competitive with Opus 4.8, GPT 5.5, and Sonnet across major benchmarks. But Nate: "Take benchmarks with a grain of salt -- feel matters more."
- Frontier SWE: GLM 5.2 beat GPT 5.5 on software engineering benchmark
- Aider coding: beats Sonnet and Opus 4.7 on multiple evals
- General knowledge: comparable to Opus 4.8 and GPT 5.5
- Bottom line: GLM is a top-tier model by benchmarks but lacks Opus-level reasoning depth on complex multi-step problems. It's real, not a toy.
Pricing: The 5x Story
Why this matters for daily workflow economics
| Model | Input/M tok | Output/M tok |
| Opus 4.8 | $5.00 | $25.00 |
| GLM 5.2 | $1.40 | $4.40 |
| Savings | 3.6x | 5.7x |
- Z.ai plans: $16/mo, $64/mo, $144/mo (yearly discount)
- Nate's recommendation: $100 Claude plan + $64 Z.ai plan. Switch per task.
- Heavy day of coding: ~5x cheaper with GLM for equivalent work
Risks & Gotchas
- Quota limits: Z.ai plans have 5-hour and weekly quotas. Peak hours consume higher multiples.
- Speed variance: GLM is unpredictable. Fast on design, slow on reasoning. Set API_TIMEOUT_MS: 3000000.
- API compatibility: Z.ai emulates Anthropic's API. Edge cases may not be fully supported.
- Subagent behavior: GLM subagents work but may differ from Opus. Test your workflows before committing.
- Not self-hosted (yet): 756B params needs serious hardware. Most users rent from Z.ai -- still a dependency.
- Fable lesson: closed-source models can be pulled overnight. Open-source = you own it. GLM 5.2 is a hedge.
Get Started
- 1
5-minute setup. z.ai account → API key → drop config into .claude/settings.local.json → test with /goal.
- 2
Set up per-project switching. glm-projects/ folder with GLM config. Main projects on default Opus. VS Code auto-detects.
- 3
Run a side-by-side. Take one real task. Run through GLM and Opus. Compare time, cost, quality. Build intuition.
- 4
Test with your skills. Verify custom skills, MCP servers, and agent teams work with GLM. Fix any breakage.
- 5
Track savings. Compare billing between GLM and Opus days. Target 3-5x cost reduction on daily knowledge work.
Sources
3 sources · 3 Tier 1
Tier 1 = Primary source (tutorial, official docs, API platform) · Tier 2 = Community resource · Tier 3 = News
Generated June 21, 2026 · DeepSeek V4 Pro · Gambit / brief-to-slides v2.0