Introduction
GLM 5.2 is Z.ai's long-context chat model, served here on one OpenAI-compatible endpoint at /v1/chat/completions. It reads up to 1,048,576 tokens across at most 256 messages and replies in up to 131,072, so a whole corpus goes in and a finding comes back.
Reasoning effort has two settings, high and max, with max as the default. temperature (0 to 1) and top_p are accepted, response_format returns JSON, up to 128 tools can be declared per request, message content is text only and replies stream over Server-Sent Events.
Key features & highlights
Eight tokens read for every one written
1,048,576 in and 131,072 out is roughly eight to one, and that shape tells you what the model is for: reading a quarter of tickets, a full regulation or an entire mailbox and returning a finding rather than a rewrite. When the answer has to be as long as the input, split the deliverable first.
max by default, high for the bulk
reasoning_effort starts at max and drops to high for large first passes. Both live in the same request body, so a cheap sweep over ten thousand documents and a careful second look at forty of them are one integration. max spends more of the reply budget on reasoning, which is why max_tokens defaults to 32,768 here.
JSON and tools on the same call
Set response_format to json_object and name the keys in the system message, or declare up to 128 functions and let tool_choice decide when they run. Either way your application still validates the result before it acts on it.
Request parameters
| Parameter | Required | Description |
|---|---|---|
messages | Yes | At most 256 ordered turns, text content only. Put the corpus in one user message and the question plus output format in the system message. at least 1 items · at most 256 items |
reasoning_effort | No | high or max. max is the default, as on Z.ai's own API, so a request that omits the field already gets the most careful setting; drop to high for bulk passes. |
stop | No | One sequence, as a string or a one-item array: Z.ai reads only one. The reply ends as soon as the model writes it, and the matched text is left out. at least 1 characters · at least 1 items · at most 1 items |
max_tokens | No | Caps the reply at 131,072 - an eighth of the read window. Default 32,768. |
temperature | No | 0 to 1, default 1. Hold it at 0 whenever the reply is parsed by code. |
top_p | No | 0.01 to 1, default 0.95. Adjust this or temperature, never both in the same comparison. |
tools | No | Up to 128 function definitions per request. at most 128 items |
tool_choice | No | auto, none, required, or an object naming one function. |
response_format | No | Ask for a JSON object and name every key in the system message. |
Pricing
Input $0.98 / Output $3.08 per 1 million tokens
Use cases
A quarter of support tickets in one call
Load every ticket from a release window into one request and ask which failure modes recur, with ticket IDs as evidence. Nothing is sampled away, so a pattern that appears once a week still shows up.
Regulation versus product behaviour
Put the full text of a regulation next to your data-handling documentation and ask for obligations, the controls that meet them and the gaps, each gap tied to the clause it comes from.
Backends that call your internal tools
Declare an order lookup, a refund and an entitlement check as tools in one request and let the model decide which to call. Results come back as tool-role messages, so a multi-step resolution stays in one conversation.
Prompt guide & pro tips
Load the whole corpus, not a sample
The window is usually larger than the retrieval index someone was about to build. Put the material in one user message, oldest first, and keep the system message for the question and the output format.
Ask for a finding, not a transcript
POST https://api.spicyapi.ai/v1/chat/completions with {"model": "zai/glm-5.2", "messages": [{"role": "system", "content": "Return one JSON object with keys: obligations, controls, gaps. Every gap must cite the clause it comes from."}, {"role": "user", "content": "<the regulation>\n\n<our data-handling policy>"}], "reasoning_effort": "high", "max_tokens": 16000, "response_format": {"type": "json_object"}, "temperature": 0}. temperature 0 keeps repeated runs comparable when you re-check the same corpus.
Escalate only the ambiguous rows
Re-send the handful of gaps the first pass marked uncertain, at max and with the same corpus. You pay for the long read twice, but the careful answer lands on the rows that matter. max_tokens above 131,072 fails validation, and image and file parts are rejected.
API quick start
curl --fail-with-body -sN https://api.spicyapi.ai/v1/chat/completions \
-H "Authorization: Bearer $SPICY_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "zai/glm-5.2/chat",
"messages": [
{
"role": "user",
"content": "Summarise the following release notes into three bullet points."
}
],
"stream": true
}' \
| jq --unbuffered -Rrj 'select(startswith("data: ")) | .[6:] | select(. != "[DONE]") | fromjson | if .error then "\n[error] \(.error.message)\n" else (.choices[0].delta.content? // empty) end'
See the API reference for authentication, the complete schema, polling, and error handling.







