GLM-5.3 API

Zhipu's flagship GLM-5.3 supports 1M context, coding and agent tasks, and control over reasoning length.

POST /v1/chat/completions

GLM-5.3 via the standard OpenAI-compatible endpoint. 1M context / 128K max output. Reasoning is ALWAYS ON and returned in reasoning_content; depth is tunable via reasoning_effort.

Request parameters

ParameterTypeRequiredDescription
modelstringYes要调用的模型名, 填模型广场里的名称。
messagesarrayYes对话消息列表, 每项含 role 与 content。role 可为 system / user / assistant / tool。
streambooleanNo是否流式返回。true 时以 SSE 逐块推送, 适合需要边生成边展示的场景。
temperaturenumberNo采样温度, 越大输出越发散、越小越稳定。
max_tokensintegerNo本次回复最多生成多少 token。不传则由模型自行决定, 不会被截断。
top_pnumberNo核采样, 只在累计概率前 top_p 的候选里挑。与 temperature 选一个调即可。
toolsarrayNo可供模型调用的工具列表。模型需要时会返回 tool_calls, 由你执行后把结果以 role=tool 回填。
tool_choicestringNo控制是否/如何选用工具: auto 由模型决定, none 禁用, 也可指定某个具体工具。需与 tools 一起使用。
response_formatobjectNo指定输出格式, 如要求返回 JSON。
stoparrayNo遇到其中任一字符串就停止生成, 该字符串不包含在结果里。
nintegerNo一次返回几条候选回复。按全部候选的总用量计费。
seedintegerNo固定随机种子, 相同输入尽量复现相同输出。
frequency_penaltynumberNo按 token 已出现频次降低其再次出现的概率, 用于抑制重复。
presence_penaltynumberNo按 token 是否已出现降低其再次出现的概率, 用于鼓励换话题。
logit_biasobjectNo按 token id 调整选中概率, 可用来强推或压制特定词。
parallel_tool_callsbooleanNo是否允许模型一次返回多个工具调用。需与 tools 一起使用。
logprobsbooleanNo是否返回所选 token 的对数概率。
top_logprobsintegerNo每个位置额外返回多少个候选 token 的概率。需同时开启 logprobs。
max_completion_tokensintegerNo回复长度上限。部分较新模型用这个字段替代 max_tokens。
reasoning_effortstringNo推理强度。调高会让模型思考更久、通常更准, 同时消耗更多 token。仅推理类模型有效。 Options: minimal / low / medium / high
verbositystringNo回复详略程度。 Options: low / medium / high
modalitiesarrayNo期望的输出模态, 如仅文本或文本加音频。仅多模态模型有效。
audioobjectNo音频输出设置, 如音色与音频格式。需在 modalities 中包含音频。
predictionobjectNo预测输出。已知回复大部分内容时提供它可以加快生成。
stream_optionsobjectNo流式相关设置, 如是否在最后一帧附带用量统计。需 stream=true。
storebooleanNo是否在模型服务侧留存本次对话。
metadataobjectNo自定义键值对, 会随请求一起带上, 便于你自己归类检索。
userstringNo代表终端用户的标识, 便于你区分自己的用户来源。
prompt_cache_keystringNo提示词缓存键。相同前缀的请求带同一个键更容易命中缓存, 从而更快更省。
prompt_cache_retentionstringNo提示词缓存保留时长。

Request example

curl https://api.router.ai/v1/chat/completions \
  -H "Authorization: Bearer sk-你的令牌" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3",
    "messages": [{"role": "user", "content": "你好"}]
  }'

Endpoint reference: Create a chat completion (OpenAI-compatible)

POST /v1/messages

Call GLM-5.3 using the Anthropic-native protocol.

Request parameters

ParameterTypeRequiredDescription
modelstringYesThe model name to be called, fill in the name from the model gallery.
messagesarrayYesArray of conversation messages, each containing role and content. The role can only be user or assistant; system prompts are handled via a separate system field and not included here.
max_tokensintegerYesMaximum number of tokens to generate in this response. This is a required field under this protocol.
systemstringNoSystem prompt. Can be passed as a string or as an array to set different segments individually.
streambooleanNoWhether to stream the response. Set to true for incremental SSE streaming.
temperaturenumberNoSampling temperature; higher values result in more diverse outputs, lower values result in more stable outputs.
toolsarrayNoList of available tools for the model to use. The model will return a tool_use content block when needed, which you will then execute and refill with tool_result.
tool_choiceobjectNoControl over tool usage: whether to let the model decide, force usage, or specify a particular tool. Must be used in conjunction with tools.
stop_sequencesarrayNoStop generation upon encountering any of the following strings.
top_pnumberNoNucleus sampling, selecting candidates from the top top_p cumulative probabilities. Only one of temperature and nucleus sampling should be used.
top_kintegerNoOnly select from the top k candidates with highest probability.
thinkingobjectNoEnable extended thinking: the model will perform reasoning before generating a response. The reasoning process will be returned as a separate content block and counted toward output usage. Only available for models that support this capability.
metadataobjectNoCustom metadata for your own categorization and retrieval.

Request example

curl https://api.router.ai/v1/messages \
  -H "Authorization: Bearer sk-你的令牌" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "你好"}]
  }'

Endpoint reference: Create a message (Claude native)