GLM5.2 API
This GLM 5.2 API guide gives developers the current endpoint choices, model IDs, provider tradeoffs, free-access caveats, and copyable request examples. If you are deciding between Z.ai direct access, OpenRouter, or local open-weight usage, start here before choosing a production route.
API facts at a glance
Which GLM 5.2 API provider should you use?
Z.ai direct
glm-5.2Official platform access, direct account support, and first-party product behavior.
Use this when you want the official GLM 5.2 API path and can manage a Z.ai account directly.
OpenRouter
z-ai/glm-5.2OpenAI-compatible apps, unified billing, provider routing, and fast model switching.
Use this when your code already talks to OpenAI-style chat completions and you want one provider layer.
HuggingFace / local
zai-org/GLM-5.2Research, local serving, and experiments where hosted API cost is not the first choice.
This is the practical free route only if you can supply the compute required to run the model.
Z.ai Chat Completions
The official OpenAI-compatible base URL is https://api.z.ai/api/paas/v4. For chat completions, call the full endpoint below with the model glm-5.2.
curl https://api.z.ai/api/paas/v4/chat/completions \
-H "Authorization: Bearer $ZAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.2",
"messages": [
{"role": "user", "content": "Plan and implement a small TypeScript API."}
]
}'OpenRouter API example
OpenRouter uses the model ID z-ai/glm-5.2and the base URL https://openrouter.ai/api/v1. It is often the simplest path when your app already supports OpenAI-compatible requests.
const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "z-ai/glm-5.2",
messages: [{ role: "user", content: "Review this migration plan." }],
reasoning: { enabled: true },
}),
});Read the OpenRouter setup guideIs there a free GLM 5.2 API?
Treat hosted GLM 5.2 API access as paid unless a provider explicitly gives you trial credit or a free tier. The open-weight route through zai-org/GLM-5.2 can be free from a licensing and download perspective, but inference still requires local hardware or rented GPU capacity. For production apps, compare provider cost, latency, quota rules, and support before choosing a route.
GLM 5.2 API FAQ
What model ID should I use?
Use glm-5.2 for direct Z.ai examples and z-ai/glm-5.2 on OpenRouter.
Where should pricing decisions happen?
Use the pricing guide for token math, then verify live provider dashboards before deploying real workloads.
When does Coding Plan matter?
Use Coding Plan for multi-file tasks where a plan can prevent mismatched imports, duplicated logic, and broken tests.