GLM (Z.ai) Commands & Prompt Reference
The Z.ai GLM API for the GLM-5.3 generation, as the docs.z.ai reference describes it; its release notes end with GLM-5.3-Flash on 2026-08-26. In scope: endpoints, model IDs, chat completion fields, thinking controls, vision content parts, the built-in web search and retrieval tools, and image generation. Video, audio, agent and tokenizer endpoints stay out. GLM-5.3 offers no way to switch thinking off through thinking.type; reasoning_effort decides how deep it goes.
All Commands
Models (5)
| Command / Syntax | What it does | Notes |
|---|---|---|
| glm-5.3 | Latest flagship GLM model ID | Released 2026-08-18; takes text only, with a 1M-token context and up to 128K output tokens. |
| glm-5.3-flash | Multimodal Flash model ID | Reads video, images, text and files with a 1M context at a fraction of the GLM-5.3 price. |
| glm-5.3-flashx | Faster Flash model ID | Same Flash model served at about 200 tokens per second; the Coding Plan does not offer it yet. |
| glm-5.2 | Previous flagship model ID | Also takes none or minimal to skip thinking; there low and medium act as high, and xhigh as max. |
| glm-4.7-flash | Free text model ID | Lightweight GLM-4.7 edition that the pricing page lists at no charge for input and output. |
Endpoints and headers (7)
| Command / Syntax | What it does | Notes |
|---|---|---|
| https://api.z.ai/api/paas/v4/ | General API base URL | Pass it as base_url to the OpenAI SDK; Coding Plan subscribers use their own endpoint instead. |
| POST /paas/v4/chat/completions | Chat completion endpoint | One path for the text and the vision model lists, appended to https://api.z.ai/api. |
| Authorization: Bearer YOUR_API_KEY | API key header | Bearer authentication with a key made on the API Keys page; JWT token authentication is the documented alternative. |
| Accept-Language | Response language header | Optional request header; en-US,en is its default and only listed value. |
| https://api.z.ai/api/coding/paas/v4 | Coding Plan OpenAI endpoint | Base URL for coding tools that speak the OpenAI Chat Completions protocol on a GLM Coding Plan. |
| https://api.z.ai/api/anthropic | Coding Plan Anthropic endpoint | Base URL for tools built on the Anthropic Messages protocol, such as Claude Code, on a Coding Plan. |
| https://api.z.ai/api/v1 | OpenAI Responses endpoint | Third Coding Plan base URL, for clients that use the OpenAI Responses protocol. |
Chat completion parameters (14)
| Command / Syntax | What it does | Notes |
|---|---|---|
| model | Model to call | Required; text models run from glm-5.3 to glm-4-32b-0414-128k, and vision models have a list of their own. |
| messages | Conversation history | Required array of system, user, assistant and tool turns; a list with only system or assistant turns is rejected. |
| do_sample | Sampling switch | Set false for greedy decoding with repeatable output; temperature and top_p are then ignored. |
| stream | Streaming switch | With true the reply arrives as Server-Sent Events chunks, closed by a data: [DONE] line. |
| temperature | Sampling temperature | Accepts 0.0 to 1.0; defaults to 1.0 on current models and 0.6 on the GLM-4.5 series. |
| top_p | Nucleus sampling cutoff | From 0.01 to 1.0, default 0.95 on current models; the guide advises tuning this or temperature, not both. |
| max_tokens | Output token limit | Up to 131072 on GLM-5.x, GLM-4.7 and GLM-4.6, which default to 65536; input tokens are not counted. |
| tools | Callable tools | Holds up to 128 functions; text models also accept retrieval and web_search entries here. |
| tool_choice | Tool selection mode | auto is the default and the only accepted value, and it applies to function tools. |
| tool_stream | Stream tool-call arguments | Needs stream set to true too; GLM-4.6 and newer text models then send arguments piece by piece. |
| stop | Stop sequence | Written as an array, though the API currently honours a single stop word. |
| response_format | Output format | Set type to json_object for JSON mode and describe the wanted fields in the system message; text models only. |
| request_id | Request identifier | Optional unique string of 6 to 64 characters; the platform creates one when it is missing. |
| user_id | End-user identifier | Optional ID of 6 to 128 characters per end user; keep personal data out of it. |
Thinking mode (4)
| Command / Syntax | What it does | Notes |
|---|---|---|
| thinking.type | Thinking switch | enabled by default; GLM-5.3 and GLM-5.3-Flash reject disabled, and GLM-4.7 always thinks when it is on. |
| reasoning_effort | Thinking depth | low, high or max on GLM-5.3, where max is the default; ignored unless thinking is enabled. |
| "reasoning_effort": "max" | Deep reasoning setting | The GLM-5.3 guide recommends it for coding and other complex tasks; it matches the default. |
| thinking.clear_thinking | Drop earlier reasoning | true by default; false keeps past reasoning_content for Preserved Thinking, if it is resent unedited and in order. |
Message content fields (5)
| Command / Syntax | What it does | Notes |
|---|---|---|
| tool_calls | Assistant tool calls | Repeat the model's calls in the assistant turn, each with an id, a type and arguments as a JSON string. |
| tool_call_id | Tool result link | Required on tool turns; pairs the result in content with the call it answers. |
| image_url | Image content part | Vision models only; url takes a link or Base64 data in jpg, jpeg or png, under 5 MB per image. |
| video_url | Video content part | Vision models only; mp4, mkv or mov up to 200 MB, two videos per request on GLM-4.6V. |
| file | File content part | Holds an uploaded file ID, a link or Base64 data up to 50 MB; never mix it with image or video parts. |
Web search and retrieval tools (11)
| Command / Syntax | What it does | Notes |
|---|---|---|
| web_search | Built-in web search tool | A tools entry of this type lets the model search the web; the pricing page bills 0.01 USD per use. |
| search_engine | Search engine choice | Required inside the web_search object; search_pro_jina is the only engine on offer. |
| count | Number of results | Between 1 and 50 results per search; 10 when not set. |
| search_domain_filter | Domain whitelist | Restricts results to the domains you name, written plainly like www.example.com. |
| search_recency_filter | Recency window | oneDay, oneWeek, oneMonth, oneYear or the default noLimit. |
| content_size | Page summary length | medium returns about 400 to 600 characters per page; high returns about 2,500 for fuller context. |
| result_sequence | Results position | Choose before or after to place the sources relative to the reply; after is the default. |
| search_result | Return the sources | false by default; true adds a web_search array with title, link and date to the response. |
| require_search | Ground reply in results | |
| knowledge_id | Knowledge base ID | Required in a retrieval tool entry; the knowledge base is set up on the Z.ai platform beforehand. |
| prompt_template | Retrieval prompt template | Your own template with {{ knowledge }} and {{ question }} slots; the default answers from the document first. |
Image generation (9)
| Command / Syntax | What it does | Notes |
|---|---|---|
| POST /paas/v4/images/generations | Image generation endpoint | Synchronous call on https://api.z.ai/api that returns one image per request. |
| model | Image model to call | Required; accepts glm-image or cogview-4-250304. |
| glm-image | GLM-Image model ID | Released 2026-01-14, with steadier text rendering inside pictures; defaults to hd quality at 1280x1280. |
| cogview-4-250304 | CogView-4 model ID | Defaults to standard quality at 1024x1024; custom sides run 512 to 2048 px in steps of 16. |
| prompt | Image description | Required text that says what the picture should show. |
| quality | Image quality | hd takes about 20 seconds for richer detail; standard returns in roughly 5 to 10 seconds. |
| size | Image size | Width x height; custom glm-image sizes need sides of 1024 to 2048 px divisible by 32. |
| user_id | End-user ID for abuse checks | Between 6 and 128 characters; lets the platform act on misuse traced to one of your users. |
| data[].url | Generated image link | Temporary link valid for 30 days, so store the image soon after the call. |
Response fields (3)
| Command / Syntax | What it does | Notes |
|---|---|---|
| reasoning_content | Reasoning text | Arrives beside content; in tool loops, add it to the assistant turn you send back so reasoning stays coherent. |
| finish_reason | Stop reason | Explains why output ended, such as a natural stop, a tool call, the length limit or a full context window. |
| cached_tokens | Cached input tokens | Found under usage.prompt_tokens_details; these prompt tokens are billed at the lower cached-input rate. |
Recipes
Our pairings of GLM request fields for everyday jobs, from greedy decoding to Preserved Thinking; the field names in each code line come from the tables.
Get repeatable answers
do_sample → false
With sampling off the model picks the most likely token at every step, and temperature and top_p no longer apply. Useful for extraction or classification, where a rerun should give the same reply.
Lighter reasoning on GLM-5.3
thinking.type → enabled, reasoning_effort → low
GLM-5.3 and GLM-5.3-Flash do not accept disabled thinking. An app that switched thinking off on an older model has to send enabled with low effort before it moves to glm-5.3, or the request fails.
Get JSON back
response_format → { "type": "json_object" }
JSON mode returns a JSON object; the structured output guide puts the expected fields and their types in the system message. It works on the text models, not the vision ones.
Stream tool arguments as they form
stream → true, tool_stream → true
Both switches are needed. Arguments then arrive in pieces under delta.tool_calls: join function.arguments per call before parsing, while reasoning_content and content stream in their own delta fields.
Keep reasoning across turns
thinking.clear_thinking → false
Preserved Thinking is on by default at the Coding Plan endpoint and off on the standard endpoint. With it on, send back every earlier reasoning_content unchanged and in its original order.
Frequently Asked Questions
Which GLM model ID should I use?
glm-5.3 for text-only work where coding quality matters most; glm-5.3-flash or glm-5.3-flashx when the input includes images, video or files, at a much lower price per token; glm-4.7-flash costs nothing.
What does do_sample do?
With do_sample true (the default) tokens are sampled, shaped by temperature or top_p. With false the model decodes greedily and both of those parameters are ignored.
Why does a request fail after switching to glm-5.3?
Usually because it still sends thinking type disabled. GLM-5.3 only runs with thinking on: send thinking.type enabled and lower reasoning_effort to low if speed matters.
Does the same API handle images?
Image input goes to the chat endpoint with a vision model and image_url parts. Creating images is a separate call, POST /paas/v4/images/generations, with glm-image or cogview-4-250304.
Sources and checks
- Z.AI API reference — Chat Completion, POST /paas/v4/chat/completions (docs.z.ai, GLM-5.3 generation) Chat request parameters, thinking fields, content parts, built-in tools, response fields
- Z.AI API reference — Generate Image, POST /paas/v4/images/generations (docs.z.ai) Image generation parameters and model codes
- Z.AI docs — GLM-5.3 model guide GLM-5.3 limits, reasoning settings, protocols
- Z.AI docs — GLM-5.3-Flash/FlashX model guide Flash model codes, inputs, recommended settings
- Z.AI docs — Core Parameters Sampling, max_tokens defaults, reasoning_effort values per model
- Z.AI docs — Pricing Free and paid model tiers, web search cost
- Z.AI docs — HTTP API Calls General endpoint and request headers
- Z.AI docs — GLM Coding Plan Quick Start Coding Plan base URLs per protocol
- Z.AI docs — New Released (release notes, latest entry GLM-5.3-Flash, 2026-08-26) Model release dates
Every row on this page was matched to a line in the documentation above on . A command or parameter that could not be found there is not listed.
1 row from the earlier version of this page was removed in that check: duplicates, and entries the documentation does not list or lists differently.
AI tools change their commands, parameters and model names between releases: the vendor's current documentation and the version you run have the last word. Found a wrong or missing entry? Tell us and it gets checked against the source. How we verify describes the process and its limits.
Related prompt references
DeepSeek (46) · Kimi (Moonshot AI) (40) · MiniMax (Hailuo) (72) · All AI prompt references