---
title: "Exploring the GLM API: Models, Pricing, and Agent Builds"
dek: "A developer's tour of Zhipu's GLM API on Z.ai in 2026 — the full model lineup from free GLM-4.7-Flash to flagship GLM-5.2, per-token pricing, native function calling, thinking modes, MCP integration, and what actually changes for agent developers building on an open-weight model from China."
category: "guide"
tags: [glm, zhipu, z-ai, llm-api, function-calling, ai-agents, model-pricing, open-weight]
author: "Dave"
published: 2026-08-14T00:00:00+00:00
updated: 2026-08-14T00:00:00+00:00
url: https://keirolabs.cloud/blogs/guide/exploring-glm-api
---
GLM — short for General Language Model, built by Zhipu AI and served internationally as **Z.ai** — has quietly become one of the most interesting API stories in 2026. It is an open-weight, MoE family out of China that prices like a budget model, agents like a frontier one, and keeps shipping. GLM-4.5 arrived with a 355B-parameter / 32B-active MoE architecture tuned explicitly for agents. GLM-4.6 pushed the context window to 200K. GLM-4.7 added thinking modes built for coding loops. And by August 2026 the flagship line has moved to GLM-5.x — GLM-5.3 launched on August 14, 2026 — with two models in the lineup that are entirely **free**.
This is a hands-on exploration: the model family, the real per-token pricing, the agent-relevant features (function calling, thinking modes, MCP), and a working call you can run today.
$0GLM-4.7-Flash & 4.5-Flash (free)
$0.60GLM-4.7 / 4.6 / 4.5 input /1M
200KGLM-4.6+ context window
90.6%GLM-4.5 function-call success
84.5GLM-5.3 CyberGym (launched Aug 14)
TL;DR · the GLM API at a glance
- **Two models are free, forever:** GLM-4.7-Flash and GLM-4.5-Flash cost $0/1M tokens — the only frontier-family free API models at this quality.
- **The price floor is absurdly low:** GLM-4.7-FlashX at $0.07 in / $0.40 out per 1M; GLM-4.5-Air at $0.20 / $1.10.
- **Flagship GLM-5.2 is $1.40 / $4.40 per 1M** — mid-market pricing with frontier-family reasoning; GLM-5 is $1.00 / $3.20.
- **GLM-5.3 launched August 14, 2026** — same 743B MoE base as 5.2, all gains from post-training; no per-token pricing yet (Coding Plan + ZCode only), and it ships with real security caveats (emergent exploit reasoning, US Entity List).
- **It is an agent model by design:** native function calling (90.6% success on GLM-4.5), tool use *during* reasoning, thinking modes on GLM-4.7, and a 200K context on GLM-4.6+.
- **It plugs into your stack:** OpenAI- and Anthropic-compatible endpoints, OpenRouter listing, community MCP bridges (it can run Claude Code and Cline), plus a flat-rate GLM Coding Plan for supported tools.
- **Built-in web search tool: $0.01 per use** — a cheap grounding primitive for agent loops.
## The model family in August 2026
Z.ai's text lineup spans five generations. The pricing page (docs.z.ai, prices per 1M tokens):
| Model | Input / 1M | Output / 1M | Notes |
|---|---|---|---|
| **GLM-5.3** | n/a (Coding Plan) | n/a | Launched Aug 14 2026; 743B MoE, ~40B active |
| **GLM-5.2** | $1.40 | $4.40 | Priced flagship |
| **GLM-5.1** | $1.40 | $4.40 | Flagship sibling |
| **GLM-5** | $1.00 | $3.20 | Frontier reasoning at budget price |
| **GLM-5-Turbo** | $1.20 | $4.00 | High-throughput 5-series |
| **GLM-4.7** | $0.60 | $2.20 | Coding/agent focus, thinking modes |
| **GLM-4.7-FlashX** | $0.07 | $0.40 | Ultra-cheap high-throughput |
| **GLM-4.7-Flash** | **Free** | **Free** | Free forever, 30B-A3B |
| **GLM-4.6** | $0.60 | $2.20 | 200K context, released Sep 2025 |
| **GLM-4.5** | $0.60 | $2.20 | 355B/32B active MoE |
| **GLM-4.5-X** | $2.20 | $8.90 | Premium reasoning variant |
| **GLM-4.5-Air** | $0.20 | $1.10 | Compact, 106B/12B |
| **GLM-4.5-Flash** | **Free** | **Free** | Free forever |
Two structural facts stand out.
**Cached input is cheap.** Cached tokens cost roughly a fifth of fresh input ($0.11/1M on GLM-4.x, $0.26 on GLM-5.2), and Z.ai currently lists cached-input *storage* as free for a limited time. For agent loops that resend large contexts — a system prompt plus accumulated conversation on every tool hop — that read discount is the difference between a GLM-4.7 agent being $0.60/1M and effectively much less.
**Reasoning tokens bill as output.** GLM models think before answering, and every reasoning token is billed at the standard output rate with no separate surcharge. A model that thinks longer emits more output tokens, so verbose reasoning traces cost real money — the thinking-mode controls on GLM-4.7 exist as much to control your bill as your quality.
## GLM-5.3: the new flagship
GLM-5.3 launched on **August 14, 2026** — the same day this post went up — and it is a different kind of release for the family. It is built on the **same 743B-parameter MoE base as GLM-5.2 (~40B active per token)**: every gain over 5.2 came from post-training, not architecture. Z.ai's RL stack (IndexShare for long context, SAO for long-horizon RL, and the open-source `slime` framework) did the work.
The vendor-reported numbers are striking:
| Benchmark | GLM-5.3 | GLM-5.2 |
|---|---|---|
| CyberGym | 84.5 | 77.2 |
| ExploitBench | 54.4 | 24.4 |
| Terminal-Bench 3.0 | 28.3 | 4.6 |
| DeepSWE v1.1 | 66.9 | 46.2 |
| Agents' Last Exam (CLI) | 28.5 | 23.8 |
Two things make this release notable beyond the scores.
**No per-token pricing yet.** GLM-5.3 is not on the per-token pricing page. It is available through the **GLM Coding Plan** and the **ZCode agent** on a points-based quota, with off-peak hours at half the standard rate. If you want metered API pricing, GLM-5.2 (at $1.40/$4.40 per 1M) remains the priced flagship for now.
**It ships with real security caveats.** Z.ai reports that post-training produced **emergent exploit-chain reasoning** the company says it did not plan for — the model found 2,436 vulnerabilities across 269 projects (1,097 critical/high severity), tracked in a public Security Disclosure Ledger at cvd.z.ai. The API also no longer lets you disable the model's thinking layer. And the context around the model matters: Zhipu's parent is on the US Entity List, and the model is subject to China's National Intelligence Law. For security teams, that is a due-diligence checklist, not a footnote. Open weights are expected around August 28, 2026, after safety hardening — which will let independent researchers verify the vendor-reported benchmarks.
## Why it is built for agents
GLM's selling point is not a single benchmark; it is that the whole model family was tuned for tool use.
**Native function calling.** GLM-4.5 already scored **90.6% function-call success** in Zhipu's benchmarks, and GLM-4.6 explicitly supports tool use *during* reasoning — the model can decide, mid-chain-of-thought, to invoke web search, a calculator, or code execution. That is the difference between a chatbot with tools bolted on and a model that reasons *through* tools. Independent analyses put GLM-4.6 near Claude Sonnet 4 on multi-turn coding (48.6% win rate) and ahead of DeepSeek-V3.1-Terminus on agent and coding benchmarks.
**Thinking modes (GLM-4.7).** GLM-4.7 added three related features:
- *Interleaved Thinking* — the model thinks before every response *and* every tool call, improving instruction following in multi-step loops.
- *Preserved Thinking* — in coding-agent scenarios, reasoning blocks are retained across turns and reused instead of re-derived, which stabilizes long-horizon tasks and cuts token waste.
- *Turn-level Thinking* — per-turn control: disable thinking for lightweight requests (lower latency and cost), enable it for complex ones.
**Coding performance.** GLM-4.7 is marketed as a coding partner: SWE-bench 73.8% (+5.8 over GLM-4.6), SWE-bench Multilingual 66.7%, Terminal Bench 2.0 41%, with real gains in Claude Code, Kilo Code, Cline, and Roo Code.
**A 200K context** (from GLM-4.6 onward, up from 128K on GLM-4.5) is the practical floor for agent loops that accumulate tool results, and GLM-5.x keeps the 200K-class context.
## The free models are the headline
**GLM-4.7-Flash and GLM-4.5-Flash are free — $0/1M input and output, no quota games on the listed pricing.** GLM-4.7-Flash is a 30B-A3B model (30B total, 3B active) aimed at lightweight deployment; GLM-4.5-Flash is the older compact free tier. Both are genuinely useful for:
- Prototyping and evals where you don't want to meter cost.
- High-volume, low-complexity tasks — classification, extraction, routing.
- A free fallback model in a multi-model agent (the model your agent calls when the paid one is overkill).
The catch, such as it is: Z.ai runs infrastructure primarily in China, which shows up as latency and data-residency considerations for US/EU production workloads. For a free tier, that is a trade most people accept.
## Built-in tools and the agent stack
Two built-in tools matter for agent builders:
- **Web search: $0.01 per use.** Grounded retrieval without wiring a separate search API. For an agent that searches occasionally, this is cheaper than any dedicated search API's per-request price; for search-heavy loops, a dedicated API (see our [cheapest web search API for agents](https://keirolabs.cloud/blogs/guide/cheapest-web-search-api-for-agents-2026) guide) will beat it.
- **Vision and OCR:** GLM-4.6V at $0.30/$0.90, GLM-4.6V-Flash free, and GLM-OCR at $0.03/$0.03 per 1M — one of the cheapest OCR endpoints in the market. Image generation via CogView-4 at $0.01/image.
**MCP integration.** GLM is not natively an MCP host — MCP is a protocol, not a model feature — but the ecosystem has filled the gap. Community bridges (e.g. CCGLM-MCP) let GLM serve as the engine behind Claude Code and other MCP-based hosts, and Z.ai advertises its own GLM Coding Plan: a flat monthly subscription (Lite/Pro/Max tiers, roughly $3–$19/mo) that works inside supported coding tools like Claude Code, Cline, and OpenCode. If your usage fits a supported tool, the flat plan undercuts the per-token API dramatically — the API is for everything else.
**On OpenRouter**, GLM is listed with multi-provider routing (glm-4.6 at ~$0.43/$1.75 per 1M via third-party hosts), so you can swap model slugs without changing SDKs.
## A working call in two minutes
The Z.ai API is OpenAI-compatible, so the OpenAI SDK works with a base-URL swap. This calls the free `glm-4.7-flash` model:
```python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_Z_AI_API_KEY",
base_url="https://api.z.ai/api/paas/v4", # OpenAI-compatible endpoint
)
resp = client.chat.completions.create(
model="glm-4.7-flash", # free; swap to "glm-4.7", "glm-4.5-air", "glm-5.2"
messages=[
{"role": "system", "content": "You are a terse research agent. Call the web_search tool when you need live facts."},
{"role": "user", "content": "What changed in the web search API market in 2025?"},
],
tools=[{
"type": "function",
"function": {
"name": "web_search",
"description": "Search the live web",
"parameters": {"type": "object", "properties": {"q": {"type": "string"}}, "required": ["q"]},
},
}],
# GLM supports per-turn thinking control on 4.7+:
# "thinking": {"type": "enabled"},
)
print(resp.choices[0].message.content)
```
The same call works over curl with `POST /chat/completions` and a bearer key. For agent frameworks, GLM slots into any OpenAI-compatible tool-calling loop — function schema, `tools` array, and tool-result messages are identical to what you already send to other OpenAI-compatible providers.
## Who should use GLM — and who shouldn't
**Use it when:**
- You want frontier-ish reasoning at mid-market prices — GLM-5 at $1/$3.20 per 1M is hard to beat on price-per-benchmark-point.
- You're building an agent and want a free model for the hot path's boring steps (GLM-4.7-Flash) and a cheap reasoning model for the hard hops (GLM-4.5-Air or GLM-4.7).
- You want open weights as an escape hatch — the weights are downloadable, so you are not locked to the API.
- You need cheap OCR or vision (GLM-OCR at $0.03/$0.03, GLM-4.6V-Flash free).
**Think twice when:**
- Latency and data residency matter — Z.ai's core infrastructure is China-based.
- You need a deep ecosystem of tool integrations and third-party tooling — GLM's is young, and some of it is community-maintained.
- Your compliance posture requires a US/EU-hosted model.
- You are in a security-sensitive domain — GLM-5.3's emergent exploit-chain reasoning, the US Entity List status of Zhipu's parent, and China's National Intelligence Law are real due-diligence items, not footnotes.
## The bottom line
GLM is the most interesting budget-agent model family of 2026. The free Flash tiers eliminate the cost floor for prototyping. GLM-4.5/4.6/4.7 priced at $0.60/$2.20 per 1M with 90.6% function-call success make cheap agent loops genuinely possible. GLM-5.x gives the family a credible flagship at mid-market prices, and GLM-5.3 (launched August 14, 2026) pushes the coding and agent ceiling further — with security caveats you should read before adopting it. If your agent workload is cost-sensitive and your latency/residency bar is flexible, GLM is worth a weekend — and it will cost you nothing to start.
## FAQ
### What is the GLM API?
GLM is the open-weight LLM family from Zhipu AI, served internationally through Z.ai. It includes flagship models (GLM-5.x), agent-tuned models (GLM-4.7/4.6/4.5), and free compact models (GLM-4.7-Flash, GLM-4.5-Flash). The API is OpenAI-compatible and supports native function calling and thinking modes.
### How much does the GLM API cost?
Per 1M tokens (Aug 2026): GLM-5.2 $1.40 in / $4.40 out; GLM-5 $1.00 / $3.20; GLM-4.7 and GLM-4.6 $0.60 / $2.20; GLM-4.5-Air $0.20 / $1.10; GLM-4.7-FlashX $0.07 / $0.40. **GLM-4.7-Flash and GLM-4.5-Flash are free.** Cached input is ~a fifth of fresh input, and reasoning tokens bill at the output rate.
### Is GLM really free?
Two models are entirely free: GLM-4.7-Flash and GLM-4.5-Flash, at $0/1M input and output. They are suitable for prototyping, classification, extraction, and high-volume low-complexity tasks — and as a zero-cost fallback in agent pipelines.
### Can GLM call tools and function-call?
Yes — it is the model family's core strength. GLM-4.5 scored 90.6% function-call success, GLM-4.6 supports tool use during reasoning, and GLM-4.7 adds thinking modes (interleaved, preserved, turn-level) tuned for multi-step agent loops. It works with any OpenAI-compatible function-calling schema.
### Is GLM good for coding agents?
GLM-4.7 is marketed as a coding partner — SWE-bench 73.8%, SWE-bench Multilingual 66.7% — with real gains in Claude Code, Cline, Kilo Code, and Roo Code, and it can be wired into MCP-based hosts via community bridges. Z.ai also sells a flat-rate GLM Coding Plan for supported tools.
### What is GLM-5.3 and how much does it cost?
GLM-5.3 launched August 14, 2026 on the same 743B MoE base as GLM-5.2, with all gains from post-training. It has no per-token pricing yet — it is available through the GLM Coding Plan and ZCode agent on a points-based quota (off-peak at half rate). Vendor-reported benchmarks show large jumps on coding and agent tasks (DeepSWE v1.1 66.9, Terminal-Bench 3.0 28.3, CyberGym 84.5). It also carries real security caveats: emergent exploit-chain reasoning, a non-disableable thinking layer, and Entity List / National Intelligence Law context.
### What are the downsides of the GLM API?
Latency and data residency: Z.ai runs its core infrastructure primarily in China, which matters for US/EU production workloads. The ecosystem around it is younger than OpenAI's or Anthropic's, and some tooling is community-maintained. For most cost-sensitive agent builds, those trade-offs are acceptable — for latency-critical or regulated workloads, they may not be.