curl --request POST \
--url https://open.bigmodel.cn/api/paas/v4/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-5.3",
"messages": [
{
"role": "system",
"content": "你是编程助手,擅长写简洁高效的代码。"
},
{
"role": "user",
"content": "写一个 Python 函数,计算斐波那契数列第 n 项。"
}
],
"temperature": 1,
"stream": false
}
'{
"id": "<string>",
"request_id": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>",
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": "<string>"
},
"tool_calls": [
{
"function": {
"name": "<string>",
"arguments": "<string>"
},
"mcp": {
"id": "<string>",
"type": "mcp_list_tools",
"server_label": "<string>",
"error": "<string>",
"tools": [
{
"name": "<string>",
"description": "<string>",
"annotations": {},
"input_schema": {
"type": "object",
"properties": {},
"required": [
"<string>"
],
"additionalProperties": true
}
}
],
"arguments": "<string>",
"name": "<string>",
"output": {}
},
"id": "<string>",
"type": "<string>"
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123
},
"total_tokens": 123
},
"video_result": [
{
"url": "<string>",
"cover_image_url": "<string>"
}
],
"web_search": [
{
"icon": "<string>",
"title": "<string>",
"link": "<string>",
"media": "<string>",
"publish_date": "<string>",
"content": "<string>",
"refer": "<string>"
}
],
"content_filter": [
{
"role": "<string>",
"level": 123
}
]
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}对话补全
和 指定模型 对话,模型根据请求给出响应。支持多种模型,支持多模态(文本、图片、音频、视频、文件),流式和非流式输出,可配置采样,温度,最大令牌数,工具调用等。点击 Try it 按钮可快速试用。
curl --request POST \
--url https://open.bigmodel.cn/api/paas/v4/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "glm-5.3",
"messages": [
{
"role": "system",
"content": "你是编程助手,擅长写简洁高效的代码。"
},
{
"role": "user",
"content": "写一个 Python 函数,计算斐波那契数列第 n 项。"
}
],
"temperature": 1,
"stream": false
}
'{
"id": "<string>",
"request_id": "<string>",
"created": 123,
"model": "<string>",
"choices": [
{
"index": 123,
"message": {
"role": "assistant",
"content": "<string>",
"reasoning_content": "<string>",
"audio": {
"id": "<string>",
"data": "<string>",
"expires_at": "<string>"
},
"tool_calls": [
{
"function": {
"name": "<string>",
"arguments": "<string>"
},
"mcp": {
"id": "<string>",
"type": "mcp_list_tools",
"server_label": "<string>",
"error": "<string>",
"tools": [
{
"name": "<string>",
"description": "<string>",
"annotations": {},
"input_schema": {
"type": "object",
"properties": {},
"required": [
"<string>"
],
"additionalProperties": true
}
}
],
"arguments": "<string>",
"name": "<string>",
"output": {}
},
"id": "<string>",
"type": "<string>"
}
]
},
"finish_reason": "<string>"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"prompt_tokens_details": {
"cached_tokens": 123
},
"total_tokens": 123
},
"video_result": [
{
"url": "<string>",
"cover_image_url": "<string>"
}
],
"web_search": [
{
"icon": "<string>",
"title": "<string>",
"link": "<string>",
"media": "<string>",
"publish_date": "<string>",
"content": "<string>",
"refer": "<string>"
}
],
"content_filter": [
{
"role": "<string>",
"level": 123
}
]
}{
"error": {
"code": "<string>",
"message": "<string>"
}
}Body
- 文本模型
- 视觉模型
- 音频模型
普通对话模型请求,支持纯文本对话和工具调用
调用的模型代码。GLM-5.3 是最新的旗舰模型系列,提供了复杂推理、超长上下文、极致推理速度。
glm-5.3, glm-5.2, glm-5.1, glm-5-turbo, glm-5, glm-4.7, glm-4.7-flash, glm-4.7-flashx, glm-4.6, glm-4.5-air, glm-4.5-airx, glm-4.5-flash, glm-4-flash-250414, glm-4-flashx-250414 "glm-5.3"
对话消息列表,包含当前对话的完整上下文信息。每条消息都有特定的角色和内容,模型会根据这些消息生成回复。消息按时间顺序排列,支持四种角色:system(系统消息,用于设定AI的行为和角色)、user(用户消息,来自用户的输入)、assistant(助手消息,来自AI的回复)、tool(工具消息,工具调用的结果)。普通对话模型主要支持纯文本内容。注意不能只包含系统消息或助手消息。
1- 用户消息
- 系统消息
- 助手消息
- 工具消息
Show child attributes
Show child attributes
是否启用流式输出模式。默认值为 false。当设置为 false 时,模型会在生成完整响应后一次性返回所有内容,适合短文本生成和批处理场景。当设置为 true 时,模型会通过Server-Sent Events (SSE)流式返回生成的内容,用户可以实时看到文本生成过程,适合聊天对话和长文本生成场景,能提供更好的用户体验。流式输出结束时会返回 data: [DONE] 消息。
false
仅 GLM-4.5 及以上模型支持此参数配置. 控制大模型是否开启思维链。
Show child attributes
Show child attributes
控制模型的推理程度,thinking 开启时生效,默认 max,仅 GLM-5.2 及其以上模型支持。对于 GLM-5.3 GLM-5.3-FLASH 模型,仅支持 low / high / max 档位。对于 GLM-5.2 模型,传入 none 或 minimal 模型会放弃思考;传入 low medium 将映射为 high;传入 xhigh 将映射为 max。
max, xhigh, high, medium, low, minimal, none "max"
是否启用采样策略来生成文本。默认值为 true。当设置为 true 时,模型会使用 temperature、top_p 等参数进行随机采样,生成更多样化的输出;当设置为 false 时,模型总是选择概率最高的词汇,生成更确定性的输出,此时 temperature 和 top_p 参数将被忽略。对于需要一致性和可重复性的任务(如代码生成、翻译),建议设置为 false。
true
采样温度,控制输出的随机性和创造性,取值范围为 [0.0, 1.0],限两位小数。对于GLM-5.3 GLM-5.2 GLM-5.1 GLM-5 GLM-4.7 GLM-4.6系列默认值为 1.0,GLM-4.5系列默认值为 0.6,GLM-4系列默认值为 0.75。较高的值(如0.8)会使输出更随机、更具创造性,适合创意写作和头脑风暴;较低的值(如0.2)会使输出更稳定、更确定,适合事实性问答等场景。建议根据应用场景调整 top_p 或 temperature 参数,但不要同时调整两个参数。
0 <= x <= 11
核采样(nucleus sampling)参数,是temperature采样的替代方法,取值范围为 [0.01, 1.0],限两位小数。对于GLM-5.3 GLM-5.2 GLM-5.1 GLM-5 GLM-4.7 GLM-4.6 GLM-4.5系列默认值为 0.95,GLM-4系列默认值为 0.9。模型只考虑累积概率达到top_p的候选词汇。例如:0.1表示只考虑前10%概率的词汇,0.9表示考虑前90%概率的词汇。较小的值会产生更集中、更一致的输出;较大的值会增加输出的多样性。建议根据应用场景调整 top_p 或 temperature 参数,但不建议同时调整两个参数。
0.01 <= x <= 10.95
模型输出的最大令牌token数量限制。GLM-5.3 GLM-5.2 GLM-5.1 GLM-5 GLM-4.7 GLM-4.6系列最大支持128K输出长度,GLM-4.5系列最大支持96K输出长度,建议设置不小于1024。令牌是文本的基本单位,通常1个令牌约等于0.75个英文单词或1.5个中文字符。设置合适的max_tokens可以控制响应长度和成本,避免过长的输出。如果模型在达到max_tokens限制前完成回答,会自然结束;如果达到限制,输出可能被截断。
默认值和最大值等更多详见 max_tokens 文档
1 <= x <= 1310721024
- Function Call · object[]
- Retrieval · object[]
- Web Search · object[]
- MCP · object[]
Show child attributes
Show child attributes
控制模型如何选择工具。
auto 停止词列表,当模型生成的文本中遇到这些指定的字符串时会立即停止生成。格式为["stop_word1"]。
4指定模型的响应输出格式,默认为text,仅文本模型支持此字段。type 取值收敛为三种:text(普通文本输出)、json_object(JSON 格式输出)。
Show child attributes
Show child attributes
请求唯一标识符。由用户端传递,ID长度要求:最少6个字符,最多64个字符,建议使用UUID格式确保唯一性,若未提供平台将自动生成。
6 - 64终端用户的唯一标识符。ID长度要求:最少6个字符,最多128个字符,建议使用不包含敏感信息的唯一标识。
6 - 128Response
业务处理成功
任务 ID
请求 ID
请求创建时间,Unix 时间戳(秒)
模型名称
模型响应列表
Show child attributes
Show child attributes
调用结束时返回的 Token 使用统计。
Show child attributes
Show child attributes
视频生成结果。
Show child attributes
Show child attributes
返回与网页搜索相关的信息,使用WebSearchToolSchema时返回
Show child attributes
Show child attributes
返回内容安全的相关信息
Show child attributes
Show child attributes
Was this page helpful?