Skip to main content

Moderate
zai/glm-5.2/chat

GLM 5.2 API brings project files, engineering rules and migration requirements into a long-running text conversation. 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.

Input $1.2425Output $4.0425per 1 million tokens8% below the publisher's list priceCached input $0.217Z.ai official priceInput $1.40Output $4.40

Workbench

Send a request

Quickstart

Examples use the selected endpoint’s public parameter definitions. Replace the API key and example media, then send the request from your server.

SDKs & integrations
POSThttps://api.spicyapi.ai/v1/chat/completions

API authentication

Keep the API key in the server environment variable SPICY_API_KEY. Use Bearer authentication and Content-Type: application/json for JSON requests.

Authorization: Bearer $SPICY_API_KEY
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'

Generated from this model’s input schema — the same one the API validates every request against.

Keep one Idempotency-Key for each logical request. After a network interruption, do not automatically resend with a new key; retain request_id to investigate the accepted request. Idempotency does not replay an earlier chat stream.

Input parameters

Place the model parameters directly in the JSON request body alongside model. This endpoint does not use an input wrapper.

messagesarray<object>Required

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. Keep the GLM 5.2 conversation within 256 messages and place the engineering constraints before the material to be reviewed.

Default
Not specified
Constraints
minItems:1
maxItems:256
response_formatobjectOptional

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.

Default
Not specified
tool_choicestring | objectOptional

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.

Default
Not specified
toolsarray<object>Optional

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.

Default
Not specified
Constraints
maxItems:128
top_pnumberOptional

When testing GLM 5.2 on repository refactoring, top_p ranges from 0.01 to 1 with default 0.95; vary it separately from temperature to understand the effect.

Default
0.95
Constraints
minimum:0.01
maximum:1
temperaturenumberOptional

For comparable repository refactoring trials with GLM 5.2, adjust temperature within 0–1 (default 1) and verify the findings even at 0.

Default
1
Constraints
minimum:0
maximum:1
max_tokensintegerOptional

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.

Default
32768
Constraints
minimum:1
maximum:131072
stopstring | arrayOptional

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 visible answer, while billing still follows produced tokens.

Default
Not specified
Constraints
minLength:1
minItems:1
maxItems:1
reasoning_effortstringOptional

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.

Default
"max"
Allowed values
"high""max"

Read the result

With stream set to false, the request returns the completed chat response directly. Read choices[].message; no task polling is needed. Set stream to true when your client supports Server-Sent Events.

Completed response example
{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "created": 1788652800,
  "model": "zai/glm-5.2/chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here is a concise summary of the release notes."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 32,
    "completion_tokens": 14,
    "total_tokens": 46
  }
}

The response example is illustrative. usage reports token counts; token counts and charges depend on your actual request.

SDKs & integrations

Use SpicyAPI in your app, terminal, AI assistant or visual workflow. Choose a setup guide below.

Use it in SillyTavern and roleplay apps

In SillyTavern, RisuAI, Agnai or any app with an OpenAI-compatible setting, paste the base URL below and your API key, then pick zai/glm-5.2/chat as the model. Browser calls are allowed, and sliders this model does not take are ignored instead of rejected.

Base URL: https://api.spicyapi.ai/v1
Model: zai/glm-5.2/chat

Use it in ComfyUI

Install the SpicyAPI nodes from ComfyUI Manager or with the command below, then pick zai/glm-5.2/chat in the SpicyAPI Chat node to use this model inside a ComfyUI graph.

cd ComfyUI/custom_nodes
git clone https://github.com/spicyapi-ai/comfyui-spicyapi