Introduction
GLM 5.2 API brings project files, engineering rules and migration requirements into a long-running text conversation. For repository refactoring, GLM 5.2 exposes high / max with max as default; compare the returned findings before choosing a lower effort for repeated runs.
| Field | Value |
|---|---|
| Input | Text |
| Output | Text |
| Required | messages |
| Optional | GLM 5.2 repository refactoring: messages, |
| Input context | 1,048,576 tokens |
| Maximum output | GLM 5.2 · 131,072 tokens (default 32,768) |
| Response | Stream the GLM 5.2 review with stream: true on /v1/chat/completions, collect chat.completion.chunk events and finish at data: [DONE]. |
| Settlement | For repository refactoring with GLM 5.2, settlement uses measured input, cached input and output tokens, reconciling the initial hold against reported usage rather than charging a flat request fee. |
Key features & highlights
Project-scale context
Z.ai positions GLM 5.2 for project-scale engineering and sustained tasks, including API migration and cross-file refactoring. Load module boundaries and existing tests before asking for a refactoring plan; require a file-by-file impact list and a way to check unchanged behaviour.
Engineering constraints
A GLM 5.2 review can compare the implementation with its API contract and identify which changes need regression checks. For repository refactoring, GLM 5.2 exposes high / max with max as default; compare the returned findings before choosing a lower effort for repeated runs.
Request parameters
| Parameter | Required | Description |
|---|---|---|
messages | Yes | This GLM 5.2 endpoint accepts text for repository refactoring; extract document text first because image, video, audio and file parts are outside its public input schema. 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 | For GLM 5.2, stop accepts one string or a one-item array, with no default; a match ends generation without returning the delimiter and may occur during reasoning before a visibl… at least 1 characters · at least 1 items · at most 1 items |
max_tokens | No | Allocate up to 131,072 output tokens for repository refactoring with GLM 5.2; the default is 32,768 and reasoning consumes this allowance too. |
temperature | No | For comparable repository refactoring trials with GLM 5.2, adjust temperature within 0–1 (default 1) and verify the findings even at 0. |
top_p | No | When testing GLM 5.2 on repository refactoring, |
tools | No | Expose at most 128 function definitions to GLM 5.2 for repository refactoring; the application executes requested calls and returns their results in tool messages. at most 128 items |
tool_choice | No | For repository refactoring, control GLM 5.2 with |
response_format | No | When GLM 5.2 returns a repository refactoring report as JSON, specify the keys through |
Pricing
Input $1.2425 / Output $4.0425 per 1 million tokens
Use cases
Plan a repository migration
Load module boundaries and existing tests before asking for a refactoring plan; require a file-by-file impact list and a way to check unchanged behaviour.
Check an API contract
A GLM 5.2 review can compare the implementation with its API contract and identify which changes need regression checks.
Connect refactoring tools
Expose at most 128 function definitions to GLM 5.2 for repository refactoring; the application executes requested calls and returns their results in tool messages. For repository refactoring, control GLM 5.2 with tool_choice set to auto, none, required or a named function object; approve consequential actions in your application.
Produce a change report
When GLM 5.2 returns a repository refactoring report as JSON, specify the keys through response_format and the instructions, then check types and required fields in your own code. Check the GLM 5.2 report against the supplied evidence before applying changes in repository refactoring.
Prompt guide & pro tips
Plan a repository migration
Load module boundaries and existing tests before asking for a refactoring plan; require a file-by-file impact list and a way to check unchanged behaviour. Keep the GLM 5.2 conversation within 256 messages and place the engineering constraints before the material to be reviewed.
Ask for a finding, not a transcript
POST https://api.spicyapi.ai/v1/chat/completions with {"model":"glm/5.2","messages":[{"role":"system","content":"Review the GLM 5.2 project migration and return JSON with keys files, tests, risks; tie every proposed change to a module boundary"},{"role":"user","content":"Repository code, module boundaries, migration requirements and existing tests"}],"
reasoning_effort":"high","max_tokens":16000,"response_format":{"type":"json_object"},"temperature":0}. Check the GLM 5.2 report against the supplied evidence before applying changes in repository refactoring.Check an API contract
A GLM 5.2 review can compare the implementation with its API contract and identify which changes need regression checks. Check the GLM 5.2 report against the supplied evidence before applying changes in repository refactoring.
GLM 5.2 API brings project files, engineering rules and migration requirements into a long-running text conversation.
Z.ai positions GLM 5.2 for project-scale engineering and sustained tasks, including API migration and cross-file refactoring.
Plan a repository migration
Load module boundaries and existing tests before asking for a refactoring plan; require a file-by-file impact list and a way to check unchanged behaviour.
For GLM 5.2, the 1,048,576-token input allowance covers the project material, instructions and tool results already included in the conversation.
Keep the GLM 5.2 conversation within 256 messages and place the engineering constraints before the material to be reviewed.
Check an API contract
A GLM 5.2 review can compare the implementation with its API contract and identify which changes need regression checks.
For repository refactoring, GLM 5.2 exposes high / max with max as default; compare the returned findings before choosing a lower effort for repeated runs.
When GLM 5.2 returns a repository refactoring report as JSON, specify the keys through response_format and the instructions, then check types and required fields in your own code.
API
POST https://api.spicyapi.ai/v1/chat/completions with {"model":"zai/glm-5.2","messages":[{"role":"system","content":"Review the GLM 5.2 project migration and return JSON with keys files, tests, risks; tie every proposed change to a module boundary"},{"role":"user","content":"Repository code, module boundaries, migration requirements and existing tests"}],"reasoning_effort":"high","max_tokens":16000,"response_format":{"type":"json_object"},"temperature":0}. Check the GLM 5.2 report against the supplied evidence before applying changes in repository refactoring.
Expose at most 128 function definitions to GLM 5.2 for repository refactoring; the application executes requested calls and returns their results in tool messages.
Allocate up to 131,072 output tokens for repository refactoring with GLM 5.2; the default is 32,768 and reasoning consumes this allowance too.
This GLM 5.2 endpoint accepts text for repository refactoring; extract document text first because image, video, audio and file parts are outside its public input schema.
Stream the GLM 5.2 review with stream: true on /v1/chat/completions, collect chat.completion.chunk events and finish at data: [DONE].
SpicyAPI adds no separate content filter to GLM 5.2, but model refusals remain possible during repository refactoring; responsibility for material rights and use of the reply stays with you.
For GLM 5.2 work on repository refactoring, you remain responsible for rights to submitted material, permitted use of the result and any necessary human review.
For repository refactoring with GLM 5.2, settlement uses measured input, cached input and output tokens, reconciling the initial hold against reported usage rather than charging a flat request fee.
Use GLM 5.2 only with authorized material and for lawful, consensual adult purposes; protect privacy and do not impersonate real people.
For GLM 5.2 work on repository refactoring, you remain responsible for rights to submitted material, permitted use of the result and any necessary human review.
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.







