Buy GLM 5.2 straight from Z.ai and you pay $1.40 per million input tokens and $4.40 per million output. That is the list price most providers quote, and for the majority of workloads it is the wrong door to walk through. The same model is served for $0.42 / $1.32 through an aggregator, and there are two ways to run it for free. This guide compares every live GLM 5.2 API route as of July 13, 2026, so you can pick by real cost instead of the sticker on the official page.
GLM 5.2 is Z.ai's (Zhipu's) flagship model, released June 16, 2026: a 743B mixture-of-experts model with a 1M-token context window, trained for long-horizon coding agents, with open MIT weights. It posts top-tier scores on coding benchmarks (numbers below). Where you rent it from is the part worth getting right.
The fastest way to get a GLM 5.2 API key
Three routes, depending on what you care about:
Cheapest paid: OpenRouter. One key, OpenAI-compatible, and the lowest per-token rate we found. Sign up, add credit, use model
z-ai/glm-5.2.Free (with limits): ZenMux gives you a
z-ai/glm-5.2-freekey with just an email, no card. NVIDIA NIM has a free trial tier too.First-party: Z.ai direct. Create a key at the API console, model string is
GLM-5.2. Best if you want the source of truth or the GLM Coding Plan subscription, but read the pricing section below before you commit.
If you need a key in the next five minutes and don't want to pay, start with ZenMux. If you're shipping to production, read on.
GLM 5.2 API pricing compared
Rates verified against each provider's own page on July 13, 2026. All prices are USD per million tokens.
Provider | Input | Output | Free tier | Context | Model string |
|---|---|---|---|---|---|
$0.42 | $1.32 | No | 1M |
| |
$1.40 | $4.40 | No | 1M |
| |
$1.40 | $4.40 | No | 1M |
| |
$1.40 | $4.40 | No | 256K |
| |
$1.40 | $4.40 | Yes | 1M |
| |
trial | trial | Yes | 1M |
| |
not listed | not listed | No | 1M |
|
Three things jump out.
First, the official price is not the cheapest price. OpenRouter lists GLM 5.2 at roughly a third of Z.ai's own rate. It can do this because it routes your request across whichever upstream host is cheapest, and its prompt-caching can knock another 60–80% off list on repeated prefixes. If you're cost-sensitive, that alone is the answer. (Our OpenRouter pricing guide breaks down how the routing modes affect what you actually pay.)
Second, watch the context window. Most providers serve the full 1M-token window, but Together AI caps GLM 5.2 at 256K. If you're feeding a whole codebase into the context (the exact workload GLM 5.2 was trained for), that limit matters.
Third, caching changes the math. Fireworks charges $0.14 per million cached input tokens; Z.ai and Together charge $0.26. For agent loops that resend a large system prompt on every turn, cached-input pricing often matters more than the headline rate.
One row needs a caveat: Baseten lists no per-token price because it's a deployment platform rather than a metered endpoint. You spin up a dedicated GLM 5.2 instance and pay for the compute it runs on, which suits steady high-volume traffic but makes little sense for occasional calls. If you just want to send requests and pay per token, stick to the other six.
Free GLM 5.2 API options (and their real limits)
Two routes get you GLM 5.2 for $0:
ZenMux
glm-5.2-free— email signup, no card, OpenAI-compatible at base URLhttps://zenmux.ai/api/v1. It is rate-limited, so it's for prototyping and personal tooling, not production traffic. One catch worth repeating: pick the model namedz-ai/glm-5.2-free, not the paidz-ai/glm-5.2right next to it, or you'll be billed.NVIDIA NIM trial — a free tier capped around 40 requests per minute with output up to ~33K tokens, then you move to paid deployment. Fine for evaluation, tight for anything sustained.
Neither free tier is a way to run a serious agent all day. But both are enough to test whether GLM 5.2 fits your task before you spend anything.
The catch with buying GLM 5.2 direct from Z.ai
The official API is the obvious first stop, and for a lot of people it's the wrong one. Developers comparing providers on Reddit keep raising the same complaints about going direct: server-load throttling during busy windows, peak-hour pricing you have to schedule around, and constrained capacity that makes the "cheap" first-party rate feel expensive once you factor in retries and latency.
That doesn't mean skip Z.ai. It means match the product to the workload:
Bursty or occasional use → an aggregator like OpenRouter, where you're not exposed to a single host's capacity.
Sustained production throughput → a dedicated host such as Fireworks, whose on-demand deployments advertise no rate limits.
Heavy daily coding → the GLM Coding Plan subscription (Lite / Pro / Max / Team tiers), which bills by prompt quota instead of per token. For an agent running hours a day, a flat subscription usually wins on cost, though Z.ai doesn't publish per-tier token quotas, so check your own usage against a tier before switching.
Is GLM 5.2 worth it? Benchmarks and real cost
The model earns the attention. On Z.ai's published numbers, GLM 5.2 scores 81.0 on Terminal-Bench 2.1 and 62.1 on SWE-bench Pro, strong coding-agent results that Z.ai positions as leading among open-source models. Treat vendor benchmarks as a starting point and confirm on your own tasks. It supports two reasoning efforts, high and xhigh (xhigh is the "max" mode Z.ai recommends for coding).
The more convincing signal is what real usage costs. One developer running GLM 5.2 through an OpenCode workflow reported burning 19 million tokens for under $3 in a day. At OpenRouter-class rates, heavy agentic coding stays cheap, which is why GLM 5.2 turns up so often in budget coding setups people share on Reddit.
Against the other open-weight coders getting attention right now (DeepSeek V4 Pro and Kimi K2.7), GLM 5.2's differentiators are the full 1M context and the dedicated long-horizon coding-agent training. For a detailed model-versus-model breakdown, see our GLM 5.2 vs Opus 4.6 comparison.
Calling the GLM 5.2 API
All these routes are OpenAI-compatible, so the code barely changes between providers; only the base URL, key, and model string move. That last one is a real gotcha: the model string is not the same everywhere. It's z-ai/glm-5.2 on OpenRouter and NVIDIA, zai-org/GLM-5.2 on Together and Baseten, accounts/fireworks/models/glm-5p2 on Fireworks, and plain GLM-5.2 on Z.ai's native endpoint.
Minimal call through OpenRouter (the cheapest paid route):
from openai import OpenAI
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key="YOUR_OPENROUTER_KEY",
)
resp = client.chat.completions.create(
model="z-ai/glm-5.2",
messages=[{"role": "user", "content": "Refactor this function..."}],
)
print(resp.choices[0].message.content)
To hit Z.ai directly instead, swap the base URL to https://api.z.ai/api/paas/v4, use model GLM-5.2, and pass your key as a Bearer token.
FAQ
How much does the GLM 5.2 API cost?
List price from Z.ai is $1.40 per million input tokens and $4.40 per million output. Through OpenRouter it's $0.42 / $1.32, and prompt caching lowers effective cost further on repeated prefixes.
Is there a free GLM 5.2 API key?
Yes. ZenMux offers a rate-limited z-ai/glm-5.2-free key with only an email, and NVIDIA NIM has a free trial tier (~40 RPM). Both are fine for testing, not for production.
What's the cheapest GLM 5.2 API provider?
For metered per-token use, OpenRouter at $0.42 / $1.32 is the cheapest live rate we found, well below Z.ai's own price. For heavy daily coding, the flat-rate GLM Coding Plan subscription usually beats any per-token option.
GLM 5.2 vs DeepSeek V4 Pro: which is better for coding?
Both are top open-weight coding models. GLM 5.2's edge is its full 1M-token context and coding-agent-specific training, reflected in its Terminal-Bench and SWE-bench Pro scores. DeepSeek V4 Pro is a strong alternative worth benchmarking on your own repo before committing.
Can I download GLM 5.2? Is it open source?
Yes. GLM 5.2 ships with open MIT-licensed weights and is available on Hugging Face, so you can self-host if you have the GPUs. The API routes above exist because most people don't.
What context window does the GLM 5.2 API support?
Up to 1M tokens (1,048,576) on most providers, with max output around 131K. The exception is Together AI, which caps context at 256K.
If you want GLM 5.2 cheap and flexible, start with OpenRouter and add ZenMux's free key for prototyping. If you're running it in production, Fireworks' dedicated deployments avoid the capacity issues people hit going direct. And if GLM 5.2 is your all-day coding driver, the GLM Coding Plan subscription is almost certainly cheaper than metered calls. The one route to think twice about is the one most people reach for first, the official pay-per-token API, unless the source-of-truth and Coding Plan are what you specifically need.
