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>"
}
}对话补全
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>"
}
}Authorizations
标准的 HTTP Bearer 认证方式,在 API Keys 页面获取密钥。
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
控制模型的推理程度,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"
采样温度,控制输出的随机性和创造性,取值范围为 [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 Calls,仅限GLM-5.3 GLM-5.2 GLM-5.1 GLM-5 GLM-5-Turbo GLM-4.7 GLM-4.6系列支持此参数,默认值false。参考 工具流式输出
false
Response
业务处理成功
Was this page helpful?