GLM-5.2 is Z.ai's open-weights (MIT) flagship — 744B-MoE, a 1M-token context, and benchmarks within ~1 point of Claude Opus 4.8 on FrontierSWE. Here's how to actually put it to work, starting with the routes that cost nothing and need no credit card.
Full GLM-5.2 in the browser. No key, no card, no install. Best for asking questions, drafting code, and pressure-testing the model before you wire it into anything.
Two genuinely free ways to call a GLM model from code (OpenAI SDK — zero rewrite):
- Sign up at openrouter.ai → create an API key
- Use the free model id
z-ai/glm-4.5-air:free(this is the free lightweight GLM — full GLM-5.2 on OpenRouter is paid, see below)
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENROUTER_API_KEY,
baseURL: "https://openrouter.ai/api/v1",
});
const r = await client.chat.completions.create({
model: "z-ai/glm-4.5-air:free",
messages: [{ role: "user", content: "Write quicksort in TypeScript" }],
});
console.log(r.choices[0].message.content);The free tier is rate-limited (currently ~50 requests/day) — fine for testing.
- Go to z.ai/manage-apikey/apikey-list → create an API key (new accounts get free starter credits to try GLM-5.2 directly)
- OpenAI-compatible base URL:
https://api.z.ai/api/paas/v4/· modelglm-5.2
const client = new OpenAI({
apiKey: process.env.ZAI_API_KEY,
baseURL: "https://api.z.ai/api/paas/v4/",
});
const r = await client.chat.completions.create({
model: "glm-5.2",
messages: [{ role: "user", content: "..." }],
});After the free credits, it's pay-as-you-go — about $0.95 / $3 per M tokens (in/out). You only pay for what you use; no subscription.
Straight answer: there's no free CLI for this. Running GLM-5.2 natively as your Claude Code model goes through Z.ai's GLM Coding Plan (paid — Lite starts at $18/mo, ~$12.60/mo billed yearly). It's cheap, but it's not free.
Once you have a Coding Plan key:
# 1. install Claude Code if you haven't
npm install -g @anthropic-ai/claude-code
# 2. point it at Z.ai's Anthropic-compatible endpoint
export ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
export ANTHROPIC_AUTH_TOKEN=your-zai-key
# 3. run, then set the model to GLM-5.2 (or GLM-5.2[1m] for the full 1M context)
claudeOr let Z.ai's helper auto-configure your tool:
npx @z_ai/coding-helper| GLM-5.2 | |
|---|---|
| Parameters | 744B MoE |
| Context | 1M tokens |
| License | MIT — open weights on HuggingFace |
| FrontierSWE | 74.4 (Claude Opus 4.8: 75.1) |
| SWE-bench Pro | 62.1 |
| Terminal-Bench 2.1 | 81.0 |
| API price | ~$0.95 / $3 per M tokens (in/out) |
| Genuinely free | chat.z.ai · OpenRouter z-ai/glm-4.5-air:free |
Reality check: "free GLM-5.2" means the web chat and the free API model above — no card needed. Running GLM-5.2 as your Claude Code model is the paid Coding Plan ($18/mo). Now you know exactly which door is which.
Hello