GLM All-Model API - Chat Completions Reference
- Call GLM series models through the OpenAI Chat Completions protocol, choosing the specific model with the
modelparameter - Synchronous processing that returns the conversation content in real time
- Text conversation: single-turn or multi-turn contextual conversation;
glm-5.3-flashadditionally supports image input - System prompt: customise the AI’s role and behaviour through a
role=systemmessage - Deep thinking:
thinking.typecontrols the chain of thought andreasoning_effortadjusts the reasoning depth; the reasoning is returned inreasoning_content - Streaming: SSE streaming responses are supported (
stream=true) - Tool calling: function calling and web search are supported (
web_search, up to 128 tools) - Structured output: JSON mode is enabled through
response_format
About streaming responses: when stream=true, results come back over Server-Sent Events, each message formatted as data: {JSON} and the stream ending with data: [DONE]. Each chunk (ChatCompletionChunk) carries id, created, model, choices and optionally usage and content_filter; inside it, choices[].delta returns incremental role / content / reasoning_content / tool_calls, and choices[].finish_reason gives the termination reason in the final chunk.
https://direct.evolink.ai, which has better support for text models and long-lived connections. https://api.evolink.ai is the primary endpoint for multimodal services and serves as a fallback address for text models.glm-5.3 and glm-5.3-flash always think and cannot be turned off; for reasoning_effort, the three levels low / high / max take effect and the remaining levels are downgraded automatically to the nearest available one (xhigh → max, medium → high, minimal / none → low, which still thinks and is billed as output). glm-5.2 can turn thinking off with thinking.type: "disabled" and supports more reasoning levels. See the thinking and reasoning_effort field descriptions for details.glm-5.3-flash, through image_url content blocks inside messages[].content[]. Sending image blocks to any other model returns an error.Authorizations
##All APIs require Bearer Token authentication##
Get API Key:
Visit API Key Management Page to get your API Key
Add to request header:
Body
Model to call:
glm-5.3, glm-5.3-flash, glm-5.2 "glm-5.3"
The list of conversation messages, containing the full context of the current conversation
Supports four roles: system, user, assistant, tool. Messages of different roles have different field structures; please select the corresponding role to view details. Must contain at least 1 message, and cannot consist solely of system or assistant messages.
1- System Message
- User Message
- Assistant Message
- Tool Message
Whether to enable streaming output mode
false: The model generates the complete response and returns it all at once (default), suitable for short text and batch processingtrue: Returns chunks in real time via Server-Sent Events (SSE), suitable for chat and long text; returnsdata: [DONE]when the stream ends
false
Controls whether to enable the chain of thought (Chain of Thought)
Controls how much the model reasons; takes effect only when thinking is on, defaulting to max
Supported values differ by model:
The glm-5.3 series always thinks, and only the three levels low / high / max genuinely take effect; the other four do not error but are downgraded automatically to the nearest available level (xhigh → max, medium → high, minimal / none → low).
The glm-5.3 series cannot turn thinking off. Sending minimal or none only drops it to the lowest level low; the model still produces thinking tokens, billed at the output rate. If you send these two levels to save money, note that this differs from glm-5.2 — on glm-5.2 they genuinely skip thinking.
For complex tasks such as programming, max is recommended.
max, xhigh, high, medium, low, minimal, none "max"
Whether to enable the sampling strategy
true(default): Usestemperature/top_pfor random sampling, producing more varied outputfalse: Always selects the highest-probability token (greedy decoding), producing more deterministic output; in this casetemperatureandtop_pare ignored
For tasks requiring consistency and reproducibility (such as code generation and translation), setting this to false is recommended
true
Sampling temperature, controlling the randomness and creativity of the output
Notes:
- Value range:
[0.0, 1.0], limited to two decimal places - Higher values (e.g. 0.8): more random and creative, suitable for creative writing
- Lower values (e.g. 0.2): more stable and deterministic, suitable for factual Q&A and code generation
- Default value:
1.0
Recommendation: Do not adjust both temperature and top_p at the same time
0 <= x <= 11
Nucleus Sampling parameter, an alternative to temperature sampling
Notes:
- Value range:
[0.01, 1.0], limited to two decimal places - The model only considers candidate tokens whose cumulative probability reaches
top_p; for example, 0.1 means only the top 10% probability tokens are considered - Smaller values produce more focused and consistent output; larger values increase diversity
- Default value:
0.95
Recommendation: Do not adjust both temperature and top_p at the same time
0.01 <= x <= 10.95
Upper limit on the number of output tokens
Note:
- The GLM series supports up to 131,072 tokens (128K) of output; setting at least
1024is recommended - When
thinkingis on, chain-of-thought tokens also count towards this limit - If generation is cut off with
length, try raising this value
1 <= x <= 1310721024
The list of tools the model may call
Note:
- Function calling (
function) and web search (web_search) are supported - Up to 128 functions
- Of these,
web_searchis billed separately per call when a search actually happens; the other tools carry no extra charge
128- Function Tool
- Web Search Tool (Web Search)
Controls how the model selects which function to call
Notes: Only takes effect when the tool type is function; defaults to and only supports auto (the model automatically decides whether to call a tool)
auto "auto"
The list of stop words
Notes:
- When the generated text encounters a specified string, generation stops immediately (the stop word itself is not included in the returned text)
- Currently only a single stop word is supported, in the format
["stop_word1"], for example["Human:"]
4Specifies the model's response output format; defaults to text
Notes:
{ "type": "json_object" }enables JSON mode, and the model returns valid JSON-formatted data, suitable for scenarios such as structured data extraction- When using JSON mode, it is recommended to explicitly request JSON output in the
systemorusermessage
Unique request identifier
Notes:
- Passed by the client, 6-64 characters long; using UUID format is recommended to ensure uniqueness
- If not provided, the platform will generate one automatically
6 - 64"req-7f3a2c1e8b9d4f0a"
Unique identifier of the end user
Notes: 6-128 characters long; using a unique identifier that does not contain sensitive information is recommended, which can help the platform monitor and detect abusive behavior
6 - 128"user-abc123456"
Response
Chat completion generated successfully
Task ID
"chatcmpl-a6613b56-c61c-94ba-9a9f-43d4cdc7d77a"
Response type
chat.completion "chat.completion"
Request ID (returned when request_id is provided in the request)
"req-7f3a2c1e8b9d4f0a"
Request creation time, Unix timestamp (seconds)
1777021417
Model name
"glm-5.3"
The list of model responses
Token usage statistics returned when the call ends
Web search-related information, returned when the web_search tool is used and a search is triggered
Content safety-related information