1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const axios = require('axios');
const api_key = "YOUR API-KEY";
const url = "https://api.segmind.com/v1/glm-5.2";
const data = {
"messages": [
{
"role": "user",
"content" : "tell me a joke on cats"
},
{
"role": "assistant",
"content" : "here is a joke about cats..."
},
{
"role": "user",
"content" : "now a joke on dogs"
},
]
};
(async function() {
try {
const response = await axios.post(url, data, { headers: { 'x-api-key': api_key } });
console.log(response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
})();An array of objects containing the role and content
Could be "user", "assistant" or "system".
A string containing the user's query or the assistant's response.
To keep track of your credit usage, you can inspect the response headers of each API call. The x-remaining-credits property will indicate the number of remaining credits in your account. Ensure you monitor this value to avoid any disruptions in your API usage.
GLM 5.2 is the flagship open-weight large language model from Z.ai (formerly Zhipu AI), built for long-horizon agentic coding and software engineering. It is a Mixture-of-Experts (MoE) model with roughly 753 billion total parameters and about 40 billion active per token, paired with a usable 1-million-token context window and output up to 131,072 tokens. Released in mid-June 2026 under a permissive MIT license, it can be self-hosted, fine-tuned, and used commercially with no regional restrictions. On Segmind, GLM 5.2 is served through OpenRouter as a synchronous text-to-text API that takes a single prompt and returns generated text.
GLM 5.2 is strongest on coding-centric, long-context work: whole-repository refactors, cross-file bug fixes, API migrations, and multi-step agentic workflows inside tools like Claude Code, Cline, and OpenClaw. Its 1M window suits whole-codebase or whole-document analysis, and Max effort delivers reliable results on hard architecture and debugging tasks. It also performs strongly on mathematical and scientific reasoning. It is text-only, so it does not handle image or multimodal inputs.
With GLM 5.2, the prompt's job is to reduce ambiguity, not to inspire. State the goal, context, constraints, inputs, output format, and success criteria explicitly. Use High effort for fast code, summaries, and reviews; switch to Max for complex refactors and long agentic chains. Place instructions after large pasted context to take advantage of the 1M window.
Is GLM 5.2 open source? Yes. The weights are on Hugging Face (zai-org/GLM-5.2) under an MIT license with no regional restrictions.
How big is the context window? A usable 1,000,000 tokens, roughly 5x GLM 5.1, with up to 131,072 output tokens.
Does GLM 5.2 beat GPT-5.5? It edges GPT-5.5 on SWE-bench Pro (62.1 vs 58.6) and FrontierSWE, while trailing on some other tasks.
Should I use High or Max? Use High for everyday coding and reviews; use Max for hard, multi-step engineering problems.
Does it support images? No. GLM 5.2 is text-only, accepting and returning text.
Can I self-host it? Yes. The MIT license allows self-hosting, fine-tuning, and commercial deployment without royalties.