This document describes how to call the Z.AI model inference service on Alibaba Cloud Model Studio.
Service activation
- Go to the Model Studio console, search for ZHIPU/GLM, find the Z.AI GLM-series text model card, and click Activate Now.
- In the dialog box, confirm the activation and authorization.
Quick start
ZHIPU/GLM-5.3 is the latest model in the GLM series and supports a 1M context. Run the following code to quickly call the ZHIPU/GLM-5.3 model in thinking mode.
You must have obtained an API Key and configured the API Key as an environment variable. If you call the model using an SDK, you must also install the SDK.
- OpenAI compatibility
enable_thinking parameter is not a standard OpenAI parameter. In the OpenAI Python SDK, you pass it in the extra_body. In the Node.js SDK, you pass it as a top-level parameter.- Python
- Node.js
- HTTP
Sample code
Response
Streaming tool call
The ZHIPU/GLM-5.3、ZHIPU/GLM-5.2、 models support the tool_stream parameter. This parameter is a boolean that defaults to false and works only when stream is true. When enabled, the arguments of the tool_call parameter from Function calling are returned incrementally as a stream.
The stream and tool_stream parameters work together as follows:
stream | tool_stream | How |
|---|---|---|
true | true |
|
true | false (default) |
|
false | true/false |
|
- OpenAI-compatible
- Python
- Node.js
- curl
Sample code
Thinking control (thinking.type and reasoning_effort)
ZHIPU/GLM-5.3 always runs in thinking mode and does not support disabling thinking. Keep thinking.type set to enabled (or keep enable_thinking set to true), and use reasoning_effort to control the reasoning depth.
Parameter | Description | Supported values |
|---|---|---|
| Controls whether thinking is enabled. The default value is |
|
| Controls the reasoning depth of the model. If this parameter is not specified, the default value is |
|
Clear historical reasoning (clear_thinking)
The clear_thinking parameter controls whether the reasoning_content (reasoning process) from previous turns is passed to the model as context in multi-turn conversations. Only GLM series models support this parameter.
true: Ignores thereasoning_contentfrom previous turns and uses only non-reasoning content, such as visible text, tool calls, and tool results, as context. This reduces context length and cost.false(default): Retains thereasoning_contentfrom previous turns and provides it to the model along with the context. To enable Preserved Thinking, you must pass the historicalreasoning_contentthrough in messages completely, unmodified, and in its original order. Omitting, truncating, rewriting, or reordering it degrades the effect or prevents it from taking effect.
assistant messages carry reasoning_content. When clear_thinking=true, historical reasoning content is not counted toward the context, so prompt_tokens is lower than with false (the default). The actual value depends on the length of the historical reasoning_content.
- OpenAI-compatible
Other features
| Model | Multi-turn conversation | Function calling | Structured output | Internet search | Prefix completion | Context caching | Reasoning effort control |
|---|---|---|---|---|---|---|---|
| ZHIPU/GLM-5.3 | Supported | Supported | Supported | Not supported | Supported | Supported | Supportedreasoning_effort |
| ZHIPU/GLM-5.2 | Supported | Supported | SupportedNon-thinking mode only | Not supported | Supported | Supported | Supportedreasoning_effort |
- The minimum number of cached tokens is 512, compared to 1024 for Model Studio.
Default parameter values
Model | enable_thinking | temperature | top_p | top_k | repetition_penalty |
|---|---|---|---|---|---|
ZHIPU/GLM-5.3 | true (cannot be disabled) | 1.0 | 0.95 | - | - |
ZHIPU/GLM-5.2 | true | 1.0 | 0.95 | - | - |
Model list and billing
The GLM series models are hybrid reasoning models from Z.AI. They are designed for intelligent agents and offer two modes: thinking and non-thinking. ZHIPU/GLM-5.3 supports only thinking mode.
For model context length and pricing information, see the Model Studio consoleModel Studio console.
Billing is based on the input and output tokens of the model.
In thinking mode, the chain of thought is billed based on output tokens.
Error codes
If an error occurs, see Error codes to resolve the issue.
The following are service error codes unique to Z.AI. HTTP error codes are the same as the general error codes for Model Studio. See the link above.
Error category | Error code | Error message |
|---|---|---|
Basic error | 500 | Internal error |
Authentication error | 1000 | Authentication failed |
1001 | The Authentication parameter was not received in the header. Authentication cannot be performed. | |
1002 | The Authentication Token is invalid. Make sure that the Authentication Token is passed correctly. | |
1003 | The Authentication Token has expired. Regenerate or obtain a new one. | |
1004 | Authentication Token verification failed. | |
1100 | Account read/write | |
Account error | 1110 | Your account is inactive. Check your account information. |
1111 | Your account does not exist. | |
1112 | Your account is locked. Contact customer service to unlock it. | |
1113 | Your account has an overdue balance. Top up your account and try again. | |
1120 | Cannot access your account. Try again later. | |
1121 | Account locked due to a policy violation. | |
API call error | 1200 | API call error |
1210 | Invalid API call parameters. Check the documentation. | |
1211 | The model does not exist. Check the model code. | |
1212 | The current model does not support the | |
1213 | The | |
1214 | The | |
1215 |
| |
1220 | You do not have permission to access | |
1221 | The API | |
1222 | The API | |
1230 | API call process error. | |
1231 | You already have a request: | |
1234 | Network error. Error ID: | |
1261 | Prompt is too long. | |
API policy block error | 1300 | The API call was blocked by a policy. |
1301 | The system detected potentially unsafe or sensitive content in the input or output. Avoid using prompts that might generate sensitive content. Thank you for your cooperation. | |
1302 | The concurrency for this API is too high. Reduce the concurrency, or contact customer service to increase the limit. | |
1303 | The request rate for this API is too high. Reduce the request rate, or contact customer service to increase the limit. | |
1304 | The daily call limit for this API has been reached. To increase the limit, contact customer service. | |
1305 | The traffic limit for this API has been reached. | |
1308 | The usage limit of | |
1309 | Your GLM Coding Plan has expired and is unavailable. To restore service, renew your plan at https://bigmodel.cn/claude-code. | |
1310 | The weekly/monthly usage limit has been reached. Your limit will be reset at | |
1311 | Your current subscription plan does not include access to | |
1312 | This model is experiencing high traffic. Try again later, or switch to another model such as | |
1313 | Your account usage violates the fair use policy, and your request rate has been limited. For more information, see the "Terms and Agreements - Subscription and Auto-renewal Agreement". To restore full access, go to Personal Center > Programming Plan Overview and apply to lift the restriction. |