GLM 5.2
GLM 5.2 is Z.ai's flagship open-weight model for long-horizon coding and agentic engineering, released June 16, 2026. A 1.0M tokens context window carries project-level engineering state, and selectable reasoning effort tunes depth per request.
import { streamText } from 'ai'
const result = streamText({ model: 'zai/glm-5.2', prompt: 'Why is the sky blue?'})Playground
Try out GLM 5.2 by Z.ai. Usage is billed to your team at API rates. Free users (those who haven't made a payment) get $5 of credits every 30 days.
Ask GLM 5.2 anything to try it out.
Providers
Route requests across multiple providers. Copy a provider slug to set your preference. Visit the docs for more info. Using a provider means you agree to their terms, listed under Legal.
| Provider |
|---|
P50 throughput on live AI Gateway traffic, in tokens per second (TPS). Visit the docs for more info.
P50 time to first token (TTFT) on live AI Gateway traffic, in milliseconds. View the docs for more info.
Direct request success rate on AI Gateway and per-provider. Visit the docs for more info.
More models by Z.ai
| Model |
|---|
About GLM 5.2
GLM 5.2 was released June 16, 2026 as Z.ai's flagship model for long-horizon tasks, with weights published under the MIT License. GLM 5.2 succeeds GLM-5.1 and extends the context window to 1.0M tokens, up from 200K on GLM-5.1, so a single task can hold an entire project's code, history, and instructions.
The architecture is Mixture-of-Experts, activating roughly 40B parameters per token. An IndexShare sparse-attention design reuses the same indexer across every four sparse attention layers, cutting per-token compute by roughly 2.9 times at full context length. You control depth per request: toggle thinking on or off, and set a reasoning effort level up to max to trade latency and token budget for stronger results on hard problems.
The focus is agentic software engineering: codebase takeover, long-horizon refactoring, end-to-end feature work, and research reproduction. GLM 5.2 scores 81.0 on Terminal-Bench 2.1 and 62.1 on SWE-bench Pro in Z.ai's published evaluations, ahead of GLM-5.1 on both. Treat the numbers as vendor-reported until independent results accumulate.
Through AI Gateway, you call GLM 5.2 with a single API key using the AI SDK, the Chat Completions API, the Responses API, the Messages API, or other API formats. Built-in observability, provider routing, and failover come standard, and GLM 5.2 supports tool calling, structured output, streaming, and implicit caching.
What To Consider When Choosing a Provider
- Configuration: Reasoning effort is the main dial. Higher effort improves results on hard, multi-step problems but consumes more tokens and time. Start at a moderate setting, then raise it only for tasks that need deep deliberation.
- Configuration: A 1.0M tokens window invites large prompts, and large prompts cost tokens on every request. Structure long-running agents to reuse stable context so implicit caching keeps repeat reads cheap, and watch spend in AI Gateway's observability tools.
- Configuration: Published benchmark numbers come from Z.ai's own evaluations. Run GLM 5.2 on your own tasks before standardizing on it, and keep code review in the loop for anything headed to production. If per-step latency dominates your workload,
glm-5.2-fastserves the same weights on faster infrastructure. - Zero Data Retention: AI Gateway supports Zero Data Retention for this model via direct gateway requests (BYOK is not included). To configure this, check the documentation.
- Authentication: AI Gateway authenticates requests using an API key or OIDC token. You do not need to manage provider credentials directly.
When to Use GLM 5.2
Best For
- Long-Horizon Coding Agents: Multi-step engineering tasks that require planning, editing, testing, and iterating without losing the thread
- Project-Scale Refactors: Whole-repository context held in a single window instead of chunked retrieval
- Codebase Takeover: Onboarding onto an unfamiliar project by loading its code and history at once
- Adjustable Reasoning Depth: One model covering both quick edits and deep deliberation via effort settings
- Agentic Tool Use: Reliable function calling and structured output across long tool-call chains
Consider Alternatives When
- Latency-Sensitive Loops:
glm-5.2-fastserves the same weights on faster infrastructure for interactive agents - High-Volume Lightweight Tasks: GLM-5-Turbo handles extraction and classification at lower per-token cost
- Vision or GUI Input: GLM-5V-Turbo adds screenshot and image understanding to the GLM-5 generation
- Simple Short Prompts: GLM-4.7-Flash keeps costs down when project-scale context is unnecessary
Conclusion
GLM 5.2 makes long-horizon, project-scale engineering practical with open weights, a 1.0M tokens context window, and tunable reasoning effort. Route GLM 5.2 through AI Gateway to get unified access, observability, and provider failover, and pair it with glm-5.2-fast when response speed outweighs per-token cost.