Zhipu Z.ai · glm-5.2
GLM-5.2 API
Zhipu's flagship for long-horizon tasks. Its 1M context is usable in practice, it can take one task from requirements to multi-platform deployment, and thinking can be on or off. On AnyAIGC it costs about 30% less than the official price.
glm-5.2 input $0.9450 per 1M tokens, output $2.9700 per 1M tokens, cache hit $0.2362. Works with the OpenAI-compatible API and in Claude Code.
- Model ID glm-5.2
- Context 1M tokens
- Input $0.9450 / 1M
- Concurrency Unlimited
- Business Self-service invoices
A 1M-context flagship built for long tasks
Zhipu positions GLM-5.2 as a flagship for the era of long tasks. Zhipu says its 1M context is usable in practice and fits project-scale engineering context, and that it runs long tasks more reliably and follows engineering conventions more consistently.
Context grew from 200K on GLM-5.1 to 1M. The architecture keeps MoE with DSA sparse attention and adds IndexShare, where every 4 sparse attention layers share one indexer; Zhipu says this cuts per-token compute by 2.9x at 1M context. GLM-5.2 uses dynamic thinking by default, thinking can be turned off, and it is open source under the MIT license.
On AnyAIGC, glm-5.2 runs on the OpenAI-compatible /v1/chat/completions endpoint and works directly in Claude Code, with unlimited concurrency. For new projects, consider GLM-5.3 at the same price; it builds on the same base model with stronger coding.
- Context window
- 1Mtokens; GLM-5.1 had 200K
- Max output
- 128Ktokens
- Architecture
- MoE + DSAIndexShare sparse attention
- Input
- TextText only
- Thinking
- On or offDynamic thinking by default
- Weights
- OpenMIT license
What GLM-5.2 can do
- 01
Project-scale engineering
1M context fits a whole project. Zhipu reports 62.1 on SWE-bench Pro and 74.4 on FrontierSWE, for taking over and refactoring existing codebases.
- 02
Terminal coding
Zhipu reports 81.0 on Terminal Bench 2.1, and 82.7 when paired with Claude Code.
- 03
Math and reasoning
Zhipu reports 99.2 on AIME 2026, 94.4 on HMMT Nov. 2025 and 91.2 on GPQA-Diamond.
- 04
Tool calls
Zhipu reports 76.8 on MCP-Atlas (public set), with function calling, structured output and MCP support.
- 05
Thinking on or off
By default the model decides whether to think. You can turn thinking off for simple requests to get faster, shorter responses.
- 06
MIT open source
Weights are published under the MIT license on Hugging Face and ModelScope. Calling through AnyAIGC means no self-hosting.
GLM-5.2 API pricing
Pay per token at fixed rates, with no subscription or monthly fee. Input and output cost about 67.5% of Zhipu's official USD prices (about 30% off).
- Per tokenInput, output and cache priced separately
- About 30% offvs Zhipu official USD prices
- Unlimited concurrencyOn by default for every user
- USDOne balance for 300+ models
| Item | Model | AnyAIGC | Zhipu official | Savings |
|---|---|---|---|---|
| Inputper 1M tokens | glm-5.2 | $0.9450 | $1.40 | 33% |
| Outputper 1M tokens, incl. thinking | glm-5.2 | $2.9700 | $4.40 | 33% |
| Cache hitper 1M tokens | glm-5.2 | $0.2362 | $0.26 | 9% |
Prices are in USD and billed on the tokens you actually use. Output includes thinking tokens, and repeated prompt prefixes are billed at the cache-hit rate automatically. Official prices come from the Zhipu Z.ai pricing page (USD). The table shows the lowest price in the model catalog; see the AnyAIGC model catalog for live pricing.
Cost examples
Estimates for common workloads. The struck-through figure is the same usage at Zhipu official prices.
-
Review 100 PRs
Each PR: 20K input tokens + 2,000 output
$2.48
Official
$3.68 -
Analyze a 500K-token document
500K input tokens + 5,000 output
$0.487
Official
$0.722 -
1M input + 1M output
1M input tokens + 1M output tokens
$3.92
Official
$5.80
GLM-5.2 official benchmarks
Scores Zhipu published in the GLM-5.2 technical blog, compared with the previous GLM-5.1.
GLM-5.2 vs GLM-5.1 · Zhipu evals
| Benchmark | GLM-5.2 | GLM-5.1 |
|---|---|---|
| HLEGeneral reasoning | 40.5 | 31.0 |
| HLE w/ ToolsGeneral reasoning, with tools | 54.7 | 52.3 |
| AIME 2026Math | 99.2 | 95.3 |
| GPQA-DiamondScience reasoning | 91.2 | 86.2 |
| SWE-bench ProSoftware engineering | 62.1 | 58.4 |
| NL2RepoRepo from scratch | 48.9 | 42.7 |
| DeepSWESoftware engineering | 46.2 | 18.0 |
| ProgramBenchProgramming | 63.7 | 50.9 |
| Terminal Bench 2.1Terminal coding | 81.0 | 63.5 |
| FrontierSWESoftware engineering | 74.4 | 30.5 |
| MCP-AtlasTool use, public set | 76.8 | 71.8 |
| Tool-DecathlonTool use | 48.2 | 40.7 |
Source: the GLM-5.2 technical blog. Scores are Zhipu's published results. Some GLM-5.2 scores in the GLM-5.3 blog use different benchmark versions or dates, so do not mix the two sets directly.
GLM-5.2 vs GLM-5.3 vs GLM-5.3-Flash
Start new projects on GLM-5.3 at the same price. Use GLM-5.2 when thinking should be off, and GLM-5.3-Flash when budget matters most.
| Spec | GLM-5.2 | GLM-5.3 | GLM-5.3-Flash |
|---|---|---|---|
| Role | Long-horizon flagship | Latest flagship | Native multimodal, low cost |
| Context | 1M | 1M | 1M |
| Input | Text | Text | Text, images |
| Thinking | On or off | Always on | Always on |
| AnyAIGC inputper 1M tokens | $0.9450 | $0.9450 | $0.0607 |
| AnyAIGC outputper 1M tokens | $2.9700 | $2.9700 | $0.2025 |
| Cache hitper 1M tokens | $0.2362 | $0.1758 | $0.0122 |
Specs come from Zhipu Z.ai's official docs. Prices are current AnyAIGC prices; see the model catalog for live pricing. More on the GLM-5.3 API and GLM-5.3-Flash API.
Where GLM-5.2 fits
- 01 · Taking over a codebase
Understand and own an existing project
Load the whole project into 1M context to map the architecture, fill in docs and keep iterating within your engineering conventions.
- 02 · Multi-platform ports
Mini programs, H5 and native apps
One of Zhipu's recommended scenarios: take a single task from requirements all the way to multi-platform deployment.
- 03 · Paper reproduction
From paper to experiment code
Put a full paper and its reference code in context, reproduce the experiments, match the metrics and write the report.
- 04 · Quick answers
Lightweight requests with thinking off
Turn thinking off for support replies, classification and other requests that do not need deep reasoning, and get faster responses.
Connect to the GLM-5.2 API in three steps
- Sign up and add credit: create an account at anyaigc.ai. Top up from $1; your balance works across every model on the platform.
- Create an API key: create a key in the console, copy the value that starts with
sk-, and store it in theANYAIGC_API_KEYenvironment variable. - Send a request: call
POST https://anyaigc.ai/v1/chat/completionswithmodelset toglm-5.2and anAuthorization: Bearerheader. With the OpenAI SDK, just setbase_urltohttps://anyaigc.ai/v1.
curl https://anyaigc.ai/v1/chat/completions \
-H "Authorization: Bearer $ANYAIGC_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.2",
"messages": [
{"role": "user", "content": "Explain what a MoE model is in three sentences."}
]
}'
import os
from openai import OpenAI
client = OpenAI(
base_url="https://anyaigc.ai/v1",
api_key=os.environ["ANYAIGC_API_KEY"],
)
resp = client.chat.completions.create(
model="glm-5.2",
messages=[
{"role": "system", "content": "You are a senior backend engineer. Answer with runnable code."},
{"role": "user", "content": "Write an HTTP client in Go with timeouts and retries."},
],
)
msg = resp.choices[0].message
print(getattr(msg, "reasoning_content", None)) # reasoning trace, if any
print(msg.content)
print(resp.usage)
import json
import os
from openai import OpenAI
client = OpenAI(base_url="https://anyaigc.ai/v1", api_key=os.environ["ANYAIGC_API_KEY"])
tools = [{
"type": "function",
"function": {
"name": "run_tests",
"description": "Run the unit tests at a path in the repo and return the failing cases",
"parameters": {
"type": "object",
"properties": {"path": {"type": "string", "description": "Test file or directory"}},
"required": ["path"],
},
},
}]
messages = [{"role": "user", "content": "Run tests/test_api.py and tell me which cases fail."}]
resp = client.chat.completions.create(model="glm-5.2", messages=messages, tools=tools)
msg = resp.choices[0].message
# In multi-turn and tool calls, send the full assistant message (incl. reasoning_content and tool_calls) back unchanged
messages.append(msg.model_dump(exclude_none=True))
for call in msg.tool_calls or []:
args = json.loads(call.function.arguments)
result = {"path": args["path"], "failed": ["test_login_timeout"]} # replace with the real result
messages.append({"role": "tool", "tool_call_id": call.id, "content": json.dumps(result)})
final = client.chat.completions.create(model="glm-5.2", messages=messages, tools=tools)
print(final.choices[0].message.content)
import os
from openai import OpenAI
client = OpenAI(base_url="https://anyaigc.ai/v1", api_key=os.environ["ANYAIGC_API_KEY"])
stream = client.chat.completions.create(
model="glm-5.2",
messages=[{"role": "user", "content": "Explain why the sky is blue."}],
stream=True,
)
for chunk in stream:
if not chunk.choices:
continue
delta = chunk.choices[0].delta
# reasoning_content deltas (if any) arrive first, then the final answer in content
reasoning = getattr(delta, "reasoning_content", None)
if reasoning:
print(reasoning, end="", flush=True)
if delta.content:
print(delta.content, end="", flush=True)
print()
Tip: GLM-5.2 uses dynamic thinking by default. Its reasoning, if any, comes back in the reasoning_content field, and reasoning_effort sets the depth. In multi-turn chats and tool calls, send the full assistant message from the API (including reasoning_content and tool_calls) back in the next request unchanged.
See the Chat Completions reference for every parameter. Replace the model name in the docs examples with the GLM model ID you want.
Use GLM-5.2 in Claude Code
Switch Claude Code to GLM-5.2: its 1M context suits long coding sessions in large repos.
- Install Claude Code: use the official installer, for example
curl -fsSL https://claude.ai/install.sh | bashon macOS or Linux. - Add the config: edit
~/.claude/settings.json, add the env block below, and replaceANTHROPIC_AUTH_TOKENwith the key you created on AnyAIGC. - Start coding: run
claudein your project folder. Type/modelto confirm the current model isglm-5.2.
{
"env": {
"ANTHROPIC_BASE_URL": "https://anyaigc.ai",
"ANTHROPIC_AUTH_TOKEN": "sk-your-API-key",
"ANTHROPIC_MODEL": "glm-5.2",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.2",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.2",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.2",
"API_TIMEOUT_MS": "300000",
"CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS": "1"
}
}
Upgrade tip: for a higher coding success rate, replace every glm-5.2 in the config with glm-5.3. Both cost the same.
For the full walkthrough and common errors, see the Claude Code setup guide. Swap the model name in the guide for glm-5.2.
GLM-5.2 API for teams and enterprises
Teams can top up, issue invoices themselves, and work with a dedicated support and technical contact.
- Invoices
Issue them yourself
Issue an invoice in the console for the amount you actually topped up, whenever you need one.
- Dedicated support
Account and technical contacts
Work with a dedicated support contact and technical engineer for onboarding, migration and troubleshooting.
- WeChat Pay
- Alipay
- USDT
- Credit card
Why teams trust AnyAIGC
Trial credit, top-ups, refunds, data handling and billing, spelled out up front.
5M free tokens to start
New accounts get trial credit, so you can test before you top up.
Top up from $1, refundable
Top up from $1. Unused balance can be refunded with no fee.
Official channels, real models
Requests go to official model channels, never cheaper or reverse-engineered substitutes.
No retention, no training
Unless the law requires it, your prompts and outputs are not persistently stored or used for training. See the privacy policy.
Transparent billing, spend caps
See tokens and cost for every request in the console, and set a quota on each API key.
24/7 support
Contact support any time about integration, billing or incidents.
Other GLM models
One API key calls every GLM model below. Pick by task difficulty and budget.
- GLM overviewGLM-5.3, GLM-5.3-Flash and GLM-5.2 pricing compared
- LatestGLM-5.3Zhipu flagship for coding and agents, 1M context · input $0.9450 / 1M
- Low costGLM-5.3-FlashNative multimodal, 320B total / 18B active · input $0.0607 / 1M
- GLM-5.2Long-horizon flagship, thinking optional · input $0.9450 / 1M
Specs and how to choose it
Z.ai's docs describe GLM-5.2 as a flagship model built for long-horizon tasks, stressing that its 1M-token context is genuinely usable.
The vendor says it went through months of specialized training for long-horizon coding-agent scenarios, covering large-scale implementation, automated research and performance optimization.
The vendor states that GLM-5.3 uses the same base model, with its improvements coming from post-training.
This page lists Input at $0.9450, Output at $2.9700, Cache hit at $0.2362, matching the pricing table above.
Compared with glm-5.3: the vendor says GLM-5.3 improves 50% over GLM-5.2 on Z.ai Code Bench, so choose it when you need stronger coding and agent ability.
Specs come from the vendor's official documentation (docs.z.ai). The table on this page is the price, and the model catalog is authoritative for live rates.
GLM-5.2 API FAQ
How much does the GLM-5.2 API cost?
On AnyAIGC, glm-5.2 is billed per token: input $0.9450 per 1M tokens, output $2.9700 per 1M tokens, cache hit $0.2362 per 1M tokens. Zhipu's official USD prices are input $1.40, output $4.40 and cache hit $0.26, so AnyAIGC input and output cost about 67.5% of official (about 30% off). See the model catalog for live pricing.
What is the GLM-5.2 model ID, and how large is the context?
The model ID is glm-5.2. Zhipu lists a 1M-token context window and up to 128K output tokens. It accepts text input only.
Can I turn off thinking on GLM-5.2?
Yes. Zhipu says GLM-5.2 uses dynamic thinking by default, letting the model decide whether to think, and thinking can also be turned off. That is one of the main differences from GLM-5.3, which always thinks. On AnyAIGC you can set thinking depth with reasoning_effort.
What makes GLM-5.2 stand out?
Zhipu positions GLM-5.2 as a flagship for the era of long tasks. Its 1M context is usable in practice and fits project-scale engineering context. It runs long tasks more reliably, follows engineering conventions more consistently, and can take one task from requirements to multi-platform deployment. Zhipu says its IndexShare design cuts per-token compute by 2.9x at 1M context.
GLM-5.2 or GLM-5.3: which should I use?
They share the same base model and cost the same for input and output on AnyAIGC. GLM-5.3 adds scaled-up post-training; Zhipu reports 50% better coding, and its cache-hit price is lower ($0.1758 vs $0.2362). New projects should start with GLM-5.3. Stay on GLM-5.2 if you need to turn thinking off or already have it tuned in production.
Can I use GLM-5.2 in Claude Code?
Yes. In the env block of ~/.claude/settings.json, set ANTHROPIC_BASE_URL to https://anyaigc.ai, ANTHROPIC_AUTH_TOKEN to your API key, and ANTHROPIC_MODEL to glm-5.2. Then run claude. You pay per token, with no 5-hour quota window like a subscription plan.
Is GLM-5.2 open source? Can I use it commercially?
Yes. Zhipu has published the GLM-5.2 weights under the MIT license on Hugging Face (zai-org/GLM-5.2) and ModelScope. Calling the API through AnyAIGC means you do not have to host it yourself. Commercial use is governed by Zhipu AI's official terms.
Are there concurrency or rate limits?
AnyAIGC does not cap concurrency for glm-5.2, and every user gets this by default. That suits batch jobs, CI pipelines and parallel agents. Billing is per token, so there is no quota that resets on a time window like a subscription plan.
How do I get a GLM-5.2 API key?
Sign up at anyaigc.ai, add credit, and create a key in the console. The same key works for every GLM model and 300+ other models on the platform, so you do not need a separate Zhipu platform account or a GLM Coding Plan.
Can I get an invoice from AnyAIGC?
Yes. You can issue invoices yourself in the console, for the amount you actually topped up.
Which payment methods are supported?
You can top up with WeChat Pay, Alipay, USDT or a credit card. Your balance is in USD and works across every model on the platform. Invoices can be issued in the console for the amount you topped up.
Is there free trial credit for new users?
Yes. New accounts get 5 million tokens of trial credit, so you can test before deciding to top up. Top-ups start at $1.
Can I get a refund on my balance?
Yes. Unused balance can be refunded with no fee. Contact support to start a refund.
Are these the real models? Is my data safe?
Requests go to official model channels, never cheaper or reverse-engineered substitutes. Unless the law requires it, we do not persistently store your prompts or outputs or use them for training, and the console shows tokens and cost for every request.
Will my data be used for training?
No. Except where required by law, AnyAIGC does not persistently store your prompts or outputs and does not use them to train models. Requests are encrypted over HTTPS. See the AnyAIGC Privacy Policy. The model's own data policy is governed by Zhipu AI's official terms.
Run GLM-5.2 at about 30% off the official price
Sign up, create an API key, and you can use glm-5.2 in your code or Claude Code within minutes.