⌘K

GLM-5.2

glm-5.2

GLM-5.2 is Z.AI's flagship foundation model for long-horizon engineering and agent tasks. It supports thinking mode, streaming, function calling, structured output, and MCP tool integration through an OpenAI Chat Completions-compatible API.

Authentication

authorization string required

All APIs require authentication via Bearer Token.

Get API Key:

Visit API Key Management Page to get your API Key.

Usage:

Add to request header:

Authorization: Bearer YOUR_API_KEY

Endpoint and compatibility

POST https://cloud.vtrix.ai/llm/chat/completions

This endpoint uses the OpenAI Chat Completions format: the top level contains choices and usage. It is not an asynchronous task API, so the response does not contain status, output, asset url, jobId, cost, or discount fields.

Parameters

model string required

Model ID for the request.

Value: glm-5.2


messages array required

Conversation history.

role string required

One of user, assistant, system, or tool.

content string | array required

A text string or a multimodal content array.


thinking object

Controls GLM native thinking. When omitted, the upstream may return message.reasoning_content; send {"type":"disabled"} when only the final answer is needed.

type string

enabled or disabled.

clear_thinking boolean

Clears reasoning_content from prior turns. Default: true.


reasoning_effort string

Reasoning effort when thinking is enabled. Default: max.

Options: max, xhigh, high, medium, low, minimal, none.


max_tokens integer

Maximum completion token budget, from 1 to 131072. Thinking tokens consume this budget, so reserve sufficient tokens when thinking is enabled.


temperature number

Sampling temperature. Default: 1.0; range: 0.0 to 1.0.


top_p number

Nucleus sampling parameter. Default: 0.95; range: 0.01 to 1.0.


stream boolean

Streams Server-Sent Events (SSE) when true; default: false. Stream chunks use the OpenAI Chat Completions chunk format and end with data: [DONE].


tools array

Tools available to the model, using the OpenAI function tool structure.

type string required

function.

function object required

Function definition.


tool_choice string | object

Tool selection strategy: auto, none, required, or an explicit function selection.


stop string | array

One or more stop sequences; up to four strings.


response_format object

Output-format constraint. Its type may be text or json_object.

Response format

id string

Chat Completion request ID.


object string

Always chat.completion.


created integer

Unix timestamp in seconds for response creation.


model string

Model ID that processed the request.


choices array

One or more completion choices.

index integer

Choice index.

message object

Assistant message.

role string

Always assistant.

content string | null

Final answer text.

reasoning_content string (optional)

Reasoning text when thinking is enabled; normally empty or omitted when it is disabled.

finish_reason string

Completion reason, such as stop, length, or tool_calls.


usage object

Token usage for the request.

prompt_tokens integer

Input tokens.

completion_tokens integer

Output tokens.

total_tokens integer

Sum of input and output tokens.

completion_tokens_details.reasoning_tokens integer (optional)

Tokens consumed by thinking.