GLM (Z.ai) Commands & Prompt Reference

58 commands & parameters · 8 categories · Sources: Z.AI API reference — Chat Completion, POST /paas/v4/chat/completions (docs.z.ai, GLM-5.3 generation) and 8 more · Checked

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 / SyntaxWhat it doesNotes
glm-5.3Latest flagship GLM model IDReleased 2026-08-18; takes text only, with a 1M-token context and up to 128K output tokens.
glm-5.3-flashMultimodal Flash model IDReads video, images, text and files with a 1M context at a fraction of the GLM-5.3 price.
glm-5.3-flashxFaster Flash model IDSame Flash model served at about 200 tokens per second; the Coding Plan does not offer it yet.
glm-5.2Previous flagship model IDAlso takes none or minimal to skip thinking; there low and medium act as high, and xhigh as max.
glm-4.7-flashFree text model IDLightweight GLM-4.7 edition that the pricing page lists at no charge for input and output.

Endpoints and headers (7)

Command / SyntaxWhat it doesNotes
https://api.z.ai/api/paas/v4/General API base URLPass it as base_url to the OpenAI SDK; Coding Plan subscribers use their own endpoint instead.
POST /paas/v4/chat/completionsChat completion endpointOne path for the text and the vision model lists, appended to https://api.z.ai/api.
Authorization: Bearer YOUR_API_KEYAPI key headerBearer authentication with a key made on the API Keys page; JWT token authentication is the documented alternative.
Accept-LanguageResponse language headerOptional request header; en-US,en is its default and only listed value.
https://api.z.ai/api/coding/paas/v4Coding Plan OpenAI endpointBase URL for coding tools that speak the OpenAI Chat Completions protocol on a GLM Coding Plan.
https://api.z.ai/api/anthropicCoding Plan Anthropic endpointBase URL for tools built on the Anthropic Messages protocol, such as Claude Code, on a Coding Plan.
https://api.z.ai/api/v1OpenAI Responses endpointThird Coding Plan base URL, for clients that use the OpenAI Responses protocol.

Chat completion parameters (14)

Command / SyntaxWhat it doesNotes
modelModel to callRequired; text models run from glm-5.3 to glm-4-32b-0414-128k, and vision models have a list of their own.
messagesConversation historyRequired array of system, user, assistant and tool turns; a list with only system or assistant turns is rejected.
do_sampleSampling switchSet false for greedy decoding with repeatable output; temperature and top_p are then ignored.
streamStreaming switchWith true the reply arrives as Server-Sent Events chunks, closed by a data: [DONE] line.
temperatureSampling temperatureAccepts 0.0 to 1.0; defaults to 1.0 on current models and 0.6 on the GLM-4.5 series.
top_pNucleus sampling cutoffFrom 0.01 to 1.0, default 0.95 on current models; the guide advises tuning this or temperature, not both.
max_tokensOutput token limitUp to 131072 on GLM-5.x, GLM-4.7 and GLM-4.6, which default to 65536; input tokens are not counted.
toolsCallable toolsHolds up to 128 functions; text models also accept retrieval and web_search entries here.
tool_choiceTool selection modeauto is the default and the only accepted value, and it applies to function tools.
tool_streamStream tool-call argumentsNeeds stream set to true too; GLM-4.6 and newer text models then send arguments piece by piece.
stopStop sequenceWritten as an array, though the API currently honours a single stop word.
response_formatOutput formatSet type to json_object for JSON mode and describe the wanted fields in the system message; text models only.
request_idRequest identifierOptional unique string of 6 to 64 characters; the platform creates one when it is missing.
user_idEnd-user identifierOptional ID of 6 to 128 characters per end user; keep personal data out of it.

Thinking mode (4)

Command / SyntaxWhat it doesNotes
thinking.typeThinking switchenabled by default; GLM-5.3 and GLM-5.3-Flash reject disabled, and GLM-4.7 always thinks when it is on.
reasoning_effortThinking depthlow, high or max on GLM-5.3, where max is the default; ignored unless thinking is enabled.
"reasoning_effort": "max"Deep reasoning settingThe GLM-5.3 guide recommends it for coding and other complex tasks; it matches the default.
thinking.clear_thinkingDrop earlier reasoningtrue by default; false keeps past reasoning_content for Preserved Thinking, if it is resent unedited and in order.

Message content fields (5)

Command / SyntaxWhat it doesNotes
tool_callsAssistant tool callsRepeat the model's calls in the assistant turn, each with an id, a type and arguments as a JSON string.
tool_call_idTool result linkRequired on tool turns; pairs the result in content with the call it answers.
image_urlImage content partVision models only; url takes a link or Base64 data in jpg, jpeg or png, under 5 MB per image.
video_urlVideo content partVision models only; mp4, mkv or mov up to 200 MB, two videos per request on GLM-4.6V.
fileFile content partHolds 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 / SyntaxWhat it doesNotes
web_searchBuilt-in web search toolA tools entry of this type lets the model search the web; the pricing page bills 0.01 USD per use.
search_engineSearch engine choiceRequired inside the web_search object; search_pro_jina is the only engine on offer.
countNumber of resultsBetween 1 and 50 results per search; 10 when not set.
search_domain_filterDomain whitelistRestricts results to the domains you name, written plainly like www.example.com.
search_recency_filterRecency windowoneDay, oneWeek, oneMonth, oneYear or the default noLimit.
content_sizePage summary lengthmedium returns about 400 to 600 characters per page; high returns about 2,500 for fuller context.
result_sequenceResults positionChoose before or after to place the sources relative to the reply; after is the default.
search_resultReturn the sourcesfalse by default; true adds a web_search array with title, link and date to the response.
require_searchGround reply in results
knowledge_idKnowledge base IDRequired in a retrieval tool entry; the knowledge base is set up on the Z.ai platform beforehand.
prompt_templateRetrieval prompt templateYour own template with {{ knowledge }} and {{ question }} slots; the default answers from the document first.

Image generation (9)

Command / SyntaxWhat it doesNotes
POST /paas/v4/images/generationsImage generation endpointSynchronous call on https://api.z.ai/api that returns one image per request.
modelImage model to callRequired; accepts glm-image or cogview-4-250304.
glm-imageGLM-Image model IDReleased 2026-01-14, with steadier text rendering inside pictures; defaults to hd quality at 1280x1280.
cogview-4-250304CogView-4 model IDDefaults to standard quality at 1024x1024; custom sides run 512 to 2048 px in steps of 16.
promptImage descriptionRequired text that says what the picture should show.
qualityImage qualityhd takes about 20 seconds for richer detail; standard returns in roughly 5 to 10 seconds.
sizeImage sizeWidth x height; custom glm-image sizes need sides of 1024 to 2048 px divisible by 32.
user_idEnd-user ID for abuse checksBetween 6 and 128 characters; lets the platform act on misuse traced to one of your users.
data[].urlGenerated image linkTemporary link valid for 30 days, so store the image soon after the call.

Response fields (3)

Command / SyntaxWhat it doesNotes
reasoning_contentReasoning textArrives beside content; in tool loops, add it to the assistant turn you send back so reasoning stays coherent.
finish_reasonStop reasonExplains why output ended, such as a natural stop, a tool call, the length limit or a full context window.
cached_tokensCached input tokensFound 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

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