AI Models

GLM-5.2

GLM-5.2 is Z.AI's open-weight (~753B-parameter Mixture-of-Experts) flagship, released June 2026 under the MIT License. It pairs a genuinely usable 1-million-token context window with best-in-class open agentic-coding performance — 62.1 on SWE-bench Pro and 81.0 on Terminal-Bench 2.1 — at roughly one-sixth the price of comparable frontier models.

GLM-5.2 is Z.AI’s (Zhipu AI) flagship open-weight foundation model, first rolled out to paying coding customers on June 13, 2026 and subsequently published as open weights under the permissive MIT License on Hugging Face (zai-org/GLM-5.2) and ModelScope — no usage restrictions, no regional locks. It is the direct successor to GLM-5.1 and doubles down on the same thesis: that the bottleneck for long-horizon AI agents is training distribution and inference efficiency, not raw parameter count.

Its two headline advances over GLM-5.1 are a quadrupled context window — a genuinely usable 1 million tokens — and a decisive jump in agentic-coding benchmarks, all while remaining roughly an order of magnitude cheaper to run than proprietary frontier models. Zhipu’s release was widely described in the press as another “DeepSeek moment” for Chinese open-source AI.

A note on benchmarks: Z.AI did not publish a single exhaustive, independently-audited benchmark suite at launch. The figures below are drawn from the official docs and model card and should be read as strong but self-reported until third-party evaluations settle. Where a comparison is directional, this page says so.

Architecture at a glance

GLM-5.2 is a Sparse Mixture-of-Experts (MoE) model with approximately 753 billion total parameters and roughly 40 billion active per token — the same broad footprint as GLM-5.1, but re-engineered for the 1M-token regime.

flowchart TB
    classDef default fill:#ffffff,stroke:#4338CA,stroke-width:2px,color:#0F172A
    classDef system fill:#4338CA,stroke:#4338CA,stroke-width:2px,color:#ffffff
    classDef mid fill:#EEF0F7,stroke:#6366F1,stroke-width:2px,color:#0F172A
    classDef accent fill:#0D9488,stroke:#0D9488,stroke-width:2px,color:#ffffff

    IN([Input tokens\nup to 1,000,000]):::mid --> EMB[Token + positional\nembeddings]:::default
    EMB --> ATTN[Sparse Attention\nlayers with IndexShare]:::system
    ATTN --> MOE{MoE router\ntop-k of routed experts}:::system
    MOE --> E1[Expert 1]:::default
    MOE --> E2[Expert 2]:::default
    MOE --> EN[Expert N]:::default
    MOE --> SH[Shared expert\nalways active]:::accent
    E1 --> AGG[Aggregate\n~40B active params]:::mid
    E2 --> AGG
    EN --> AGG
    SH --> AGG
    AGG --> MTP[Improved MTP head\nspeculative decoding]:::system
    MTP --> OUT([Output\nup to 128K tokens]):::accent

IndexShare — sparse attention built for 1M context. The defining architectural change in GLM-5.2 is IndexShare, which reuses the same sparse-attention indexer across every four sparse-attention layers. Because computing which positions to attend to is the expensive part of sparse attention at extreme context lengths, sharing the indexer cuts per-token FLOPs by ~2.9× at a 1M-token context — the engineering trick that makes million-token inference economically viable rather than merely possible.

Improved Multi-Token Prediction (MTP). GLM-5.2 refines the MTP head introduced in the GLM-5 line. A secondary head predicts several future tokens per forward pass, which at inference time drives speculative decoding — candidate continuations are generated in parallel and verified in bulk, raising tokens-per-second throughput without changing output quality.

Selectable thinking effort. Native reasoning (“thinking mode”) is enabled by default. GLM-5.2 exposes multiple thinking effort levels (e.g. High and Max) so callers can dial the trade-off between answer depth and latency per request — cheap, fast responses for routine calls; deep multi-step reasoning for hard agentic tasks.

What “1 million tokens” actually buys

PropertyGLM-5.1GLM-5.2
Total / active parameters~754B / ~40B~753B / ~40B
Context window200K1,000,000
Max output tokens128K128K (131,072)
AttentionMLA + DeepSeek Sparse Attention+ IndexShare (shared indexer / 4 layers)
ReasoningNative thinking (default on)Selectable thinking effort
LicenseMITMIT

A million-token window is enough to hold a mid-sized codebase, its tests, and its docs in-context at once, so the model can reason across files without a retrieval step losing the thread — the practical precondition for the multi-hour, whole-repository agentic work GLM-5.2 targets.

Agentic capabilities

GLM-5.2 is explicitly optimized for long-horizon agentic coding: decomposing a task, calling tools, reading their output, and revising its own plan across many turns. It ships first-class support for the primitives an agent harness needs:

  • Function calling / tool use — structured invocation of external tools and APIs
  • Structured output — constrained JSON generation for machine-readable responses
  • MCP integration — connect external Model Context Protocol tools and data sources
  • Context caching — reuse of long shared prefixes to cut cost and latency in multi-turn sessions
  • Streaming — incremental token delivery for responsive agent UIs
flowchart LR
    classDef default fill:#ffffff,stroke:#4338CA,stroke-width:2px,color:#0F172A
    classDef system fill:#4338CA,stroke:#4338CA,stroke-width:2px,color:#ffffff
    classDef step fill:#EEF0F7,stroke:#6366F1,stroke-width:2px,color:#0F172A
    classDef done fill:#0D9488,stroke:#0D9488,stroke-width:2px,color:#ffffff

    P[Plan\ndecompose task]:::system --> A[Act\ncall tools / write code]:::step
    A --> O[Observe\nread test + tool output]:::step
    O --> D{Goal met?}:::system
    D -- No --> R[Revise\nadjust plan]:::step
    R --> A
    D -- Yes --> F([Deliver\nverified output]):::done

To make GLM-5.2 easy to drop into this loop, Zhipu released its own agent harness, ZCode, on July 2, 2026 — a tool for developers to “build autonomous coding assistants,” positioned directly against Anthropic’s Claude Code. In the terminology of agentic AI, ZCode is a harness: the control system that lets the model function as an autonomous agent. (Zhipu seeded adoption with 5 million free tokens for new ZCode users and a 50% quota increase for existing subscribers.)

Benchmarks

Scores below are as reported by Z.AI at launch; treat cross-vendor comparisons as directional.

BenchmarkGLM-5.2GLM-5.1Notes
SWE-bench Pro62.158.4Real-world software engineering
Terminal-Bench 2.181.062.0Autonomous terminal / tool use
FrontierSWEtrails Opus 4.8 by ~1%Near-frontier on hard SWE tasks
HLE (Humanity’s Last Exam)40.5 text · 54.7 with toolsTool use materially lifts reasoning
AIME 202699.2Competition mathematics
GPQA-Diamond91.2Graduate-level science QA
Intelligence Index v4.151Ahead of MiniMax-M3 (44), DeepSeek V4 Pro (44), Kimi K2.6 (43)

On several long-horizon coding benchmarks GLM-5.2 matches or beats GPT-5.5 and Claude Opus 4.7, while on FrontierSWE it comes within roughly a single percentage point of Opus 4.8 — remarkable for an openly-licensed model.

Pricing

Through gateways such as OpenRouter, GLM-5.2 runs at approximately $1.40 per million input tokens and $4.40 per million output tokens. For comparison, GPT-5.5 sits near $5 / $30 and Claude Opus near $5 / $25 — placing GLM-5.2 at roughly one-sixth the cost of comparable frontier models for equivalent long-horizon coding work. Because the weights are MIT-licensed, teams can also self-host with no per-token fee at all.

Significance

GLM-5.2 is the clearest 2026 datapoint yet that open-weight models can reach the proprietary frontier on a specific capability domain — here, agentic software engineering — and then undercut it dramatically on price. Its bet is architectural rather than brute-force: IndexShare makes a 1M-token window affordable, selectable thinking effort makes reasoning tunable per call, and a native agent harness (ZCode) closes the gap between “capable model” and “deployable autonomous engineer.” For teams building agents, GLM-5.2’s combination of MIT licensing, long context, and low cost makes it a default candidate for the open end of the agentic AI stack.

Agentic tool-use with GLM-5.2 (OpenAI-compatible API + thinking mode)

python
# pip install openai
# GLM-5.2 exposes an OpenAI-compatible endpoint on the Z.AI platform.
from openai import OpenAI
import json

client = OpenAI(
    api_key="YOUR_ZAI_API_KEY",
    base_url="https://api.z.ai/api/paas/v4",
)

# 1) Describe the tools the model is allowed to call.
tools = [{
    "type": "function",
    "function": {
        "name": "run_tests",
        "description": "Run the project's test suite and return pass/fail output.",
        "parameters": {
            "type": "object",
            "properties": {
                "path": {"type": "string", "description": "Directory or file to test."}
            },
            "required": ["path"],
        },
    },
}]

def run_tests(path: str) -> str:
    # ...invoke pytest / your runner here and capture output...
    return "3 passed, 1 failed: test_auth.py::test_expired_token"

messages = [
    {"role": "system", "content": "You are a senior engineer. Fix failing tests."},
    {"role": "user", "content": "The auth suite is red. Diagnose and propose a patch."},
]

# 2) Agentic loop: the model plans, calls tools, reads results, and revises.
while True:
    resp = client.chat.completions.create(
        model="glm-5.2",                 # use "glm-5.2" (128K) or the 1M-context tier
        messages=messages,
        tools=tools,
        temperature=0.6,
        extra_body={
            "thinking": {"type": "enabled"},   # native reasoning is on by default
            "reasoning_effort": "high",        # trade latency for depth ("high"/"max")
        },
    )
    choice = resp.choices[0].message
    messages.append(choice)

    if not choice.tool_calls:
        print(choice.content)                  # final answer — stop the loop
        break

    # 3) Execute each requested tool call and feed results back to the model.
    for call in choice.tool_calls:
        args = json.loads(call.function.arguments)
        result = run_tests(**args)
        messages.append({
            "role": "tool",
            "tool_call_id": call.id,
            "content": result,
        })

Ready to build?

Leverage AI technologies to build your product stack

Superteams can help you build, deploy and launch AI application stacks using open source technologies — from architecture through to production.

Talk to Superteams