GLM-5.2 API

zhipu/glm-5.2
GLM-5.2 is an advanced AI model with a 1M-token context window, agentic coding capabilities, long-horizon reasoning, and repo-scale analysis.
Context
1M tokens
Input
$1.82 / 1M tokens
Output
$5.72 / 1M tokens
Released
Jun 16, 2026

Overview

What Is GLM-5.2 API?

GLM-5.2 is Z.ai's latest flagship AI model, purpose-built for advanced coding, autonomous software development, and complex reasoning tasks. As the newest member of the GLM series, it introduces a massive 1 million-token context window, enabling deeper project understanding and more effective long-term task execution.

Technical Reference

Developer Z.ai (Zhipu AI)
Model ID glm-5.2
glm-5.2[1m]
Release Date June 13, 2026
Context Window (default) 202,752 tokens (~203K)
Context Window (extended) 1,000,000 tokens — use glm-5.2[1m] model ID
Max Output Tokens 131,072
Architecture (family) MoE (Mixture of Experts), 744B total parameters in GLM-5 base
Training Hardware Huawei Ascend (non-NVIDIA)
Training Algorithm Asynchronous Agent RL for long-chain stability
Thinking Modes High Max (effort switchable via /effort in Claude Code)
Modalities Text (input and output)
Languages Evaluated 9+ programming languages across 10,000+ test environments

What GLM-5.2 Actually Does Differently

The headline is the context window, but that number is only meaningful if the model can actually use it. Here's what distinguishes GLM-5.2 from both its predecessors and the wider field of coding-focused models.

One-million-token usable context

Z.ai specifically qualifies this as "usable" — not just formally accepted. The model is designed to maintain coherent understanding across the full length, which matters when you drop an entire monorepo in at once. That's a 5× jump from GLM-5.1's 200K window.

Asynchronous Agent Reinforcement Learning

A new training algorithm developed specifically for stability on long reasoning and action chains. Where models can drift or lose track of earlier context in extended agentic sessions, the async RL approach is designed to keep execution coherent over hundreds of tool calls.

Two-tier thinking modes

GLM-5.2 simplifies effort control to two modes: High and Max. Standard tasks default to High; for the most complex refactors and architecture decisions, Max unlocks deeper reasoning. Z.ai recommends Max for demanding coding work.

Agentic tool use at scale

Evaluated against 10,000+ verifiable environments and nine programming languages. Demonstrated tasks include building a Chrome extension from scratch and migrating a three-year-old legacy React project fully to TypeScript — not as assisted completion, but as autonomous execution.

Native coding agent integration

Works out of the box with Claude Code, OpenClaw, Cline, Roo Code, and Kilo Code via environment variable overrides. No custom harness required — a few lines in your config file and the model is live in your existing workflow.

API Pricing

  • Input: $1.82 per 1MTok
  • Output: $5.72 per 1MTok

Where GLM-5.2 Makes the Most Sense

Not every task benefits equally from a model built specifically for extended, autonomous engineering work. These are the scenarios where GLM-5.2's design choices pay off most visibly.

Repository-scale refactoring

With a million-token context window, you can drop an entire production codebase into a single session and ask the model to migrate it — framework by framework, dependency by dependency. Z.ai demonstrated this with a full React-to-TypeScript migration of a three-year-old legacy project, running autonomously from start to working state.

Long agentic engineering sessions

The Asynchronous Agent RL training specifically targets stability across multi-hundred-step sequences with thousands of tool calls. If your workflow involves an AI agent that runs for hours, making incremental code edits, running tests, and fixing failures in a loop, GLM-5.2 is one of the few models explicitly optimized for that pattern.

Greenfield project generation

GLM-5.2 has been demonstrated building a fully functional Chrome extension from scratch — spec to working artifact in a single autonomous session. For teams that want to prototype fast, the combination of broad context and deep code generation capability reduces the number of back-and-forth iterations needed to reach something testable.

Self-hosted or on-premise deployments

The MIT license makes GLM-5.2 one of the most permissive frontier-class coding models available. Teams with data residency requirements or budget constraints around per-token costs can run the weights on their own infrastructure using vLLM or SGLang, without any licensing friction.

‍

Uptime and performance

  • Uptime (24h): 100%
  • Uptime (7d): 89.0%
  • Availability (24h): 100%
  • Error rate (24h): 0%
  • End-to-end latency (24h median): 23.9s
  • Time to first token (24h median): 17.3s
  • Throughput (24h median): 51.9 tok/s

Measured on the AI/ML API gateway across live traffic. Figures are medians unless stated. Last updated 2026-10-12.

Use cases

GLM-5.2 is documented as suited for long-horizon autonomous coding and engineering tasks, including completing a full development workflow from requirements to multi-platform deployment in one task.

It is also suited for cross-file, multi-step, long-chain software work such as testing module decoupling, interface migration, directory cleanup, SDK adaptation, and cross-language refactoring.

The model is documented for mobile app development scenarios, where it can cover client architecture, streaming messages, long connections, local state management, keyboard behavior, scrolling logic, system notifications, permissions, and background recovery.

It is also documented for small-program development, including page subdivision, custom components, page stack management, request wrapping, authentication state maintenance, lifecycle management, and handling abnormal states.

How to use GLM-5.2 API

Install any OpenAI-compatible SDK, point it at api.aimlapi.com/v1, and set the model to zhipu/glm-5.2.
import requests

r = requests.post(
    "https://api.aimlapi.com/v1/chat/completions",
    headers={"Authorization": "Bearer " + AIMLAPI_KEY},
    json={
      "model": "zhipu/glm-5.2",
      "messages": [
        {
          "role": "user",
          "content": "Hello!"
        }
      ]
    },
)
print(r.json())
const r = await fetch("https://api.aimlapi.com/v1/chat/completions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.AIMLAPI_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "zhipu/glm-5.2",
    "messages": [
      {
        "role": "user",
        "content": "Hello!"
      }
    ]
  }),
});
console.log(await r.json());
curl -X POST https://api.aimlapi.com/v1/chat/completions \
  -H "Authorization: Bearer $AIMLAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"zhipu/glm-5.2","messages":[{"role":"user","content":"Hello!"}]}'

OpenAI-compatible — swap the base URL and it works with your existing SDK.

GLM-5.2 API Pricing

TypePrice
Input
$1.82 / 1M tokens
Output
$5.72 / 1M tokens
Cached input
$0.338 / 1M tokens

GLM-5.2 Benchmarks

BenchmarkScoreWhat it measuresSourceRetrieved
Intelligence
34
Composite score across standardised reasoning, knowledge and problem-solving evaluations, measured independently by Artificial AnalysisSourceSeptember 12, 2026
Coding
68.8
Composite score across standardised coding evaluations, measured independently by Artificial AnalysisSourceSeptember 12, 2026

GLM-5.2 vs other models

ModelInputOutputContextBest for
GLM-5.2
This page
$1.82 / 1M tokens
$5.72 / 1M tokens
1M tokens
Coding + agents
$6.5 / 1M tokens
$39 / 1M tokens
1M tokens
Reasoning + agents
$2.6 / 1M tokens
$13 / 1M tokens
1M tokens
Balanced coding + agents
$3.9 / 1M tokens
$19.5 / 1M tokens
1M tokens
Long-context, multimodal & agentic workflows
$1.95 / 1M tokens
$11.7 / 1M tokens
1M tokens
Reasoning + agents

Frequently asked questions

GLM-5.2 has a 1,000,000 tokens context window and can return up to 131,072 tokens.

GLM-5.2 takes text as input and returns text.

Use zhipu/glm-5.2 as the model id. Requests go to https://api.aimlapi.com/v1/chat/completions.

GLM-5.2 became available on June 16, 2026.

GLM-5.2 is priced at input $1.82 / 1M tokens, output $5.72 / 1M tokens, cached input $0.338 / 1M tokens.

Yes, GLM-5.2 can stream responses as they are generated.

GLM-5.2 was built by Zhipu AI.

Start building with GLM-5.2

Get API Key
1000+ models, one API.