详细说明
查看介绍、核心功能、适用场景
Agent API 文档
查看完整的 API 文档
体验中心
点击立即体验
价格
- 按 Tokens 消耗后付费,5 元/百万 Tokens
- 计量范围:智能体全任务流节点产生的 Tokens 总数
用户并发权益
API 调用会受到速率限制,当前我们限制的维度是请求并发数量(在途请求任务数量)。不同等级的用户并发保障如下。| V0 | V1 | V2 | V3 |
|---|---|---|---|
| 10 | 15 | 20 | 30 |
GLM PPT
接口请求
| 传输方式 | https |
|---|---|
| 请求地址 | https://open.bigmodel.cn/api/v1/agents |
| 调用方式 | 同步调用,等待模型完成执行并返回最终结果或使用SSE调用 |
| 字符编码 | UTF-8 |
| 接口请求格式 | JSON |
| 响应格式 | JSON 或标准 Stream Event |
| 接口请求类型 | POST |
| 开发语言支持 | 任意可发起 http 请求的开发语言 |
请求参数
| 参数名称 | 类型 | 是否必填 | 参数说明 |
|---|---|---|---|
| agent_id | String | 是 | 智能体 ID:slides_glm_agent |
| messages | List<Object> | 是 | 会话消息体 |
| conversation_id | String | 否 | 会话id |
| stream | String | 是 | 目前只支持流式,必须传 true |
| └─ role | String | 是 | 用户的输入 role = user |
| └─ content | List<Object> | 是 | 会话内容 |
| └─ type | String | 是 | 目前支持内容类型,目前仅支持 text |
| └─ text | String | 是 | 具体内容,例如:“帮我生成一个关于人工智能技术发展的市场调研” |
响应参数
| 字段名称 | 字段类型 | 备注 |
|---|---|---|
| id | String | 请求唯一ID |
| agent_id | String | 当前 agent id |
| conversation_id | String | 当前对话的唯一ID |
| choices | List<Object> | 智能体响应选项 |
| └─ index | Number | 事件编号,单调递增 |
| └─ messages | List<Object> | 智能体响应消息体 |
| └─ role | String | 智能体的角色 role = assistant |
| └─ phase | String | 当前角色的状态:思考-thinking、使用工具- tool、回答-answer |
| └─ content | List<Object> | 智能体响应内容 |
| └─ type | String | 响应内容类型:文本-text、对象-object |
| └─ tag_cn | String | 标签(中文),例如:插入幻灯片 |
| └─ tag_en | String | 标签(英文),例如:Insert Page |
| └─ text | String | 如果 type = text,则这个字段以字符串格式给出具体内容 |
| └─ object | Object | 如果 type = object,则这个字段以对象格式给出具体内容 |
| └─ tool_name | String | 工具唯一标识,例如:search、insert_page |
| └─ input | String | 调用工具的输入。 例如,搜索时,此字段给出了具体的搜索词 |
| └─ output | String | 工具执行后的输出。 例如,生成幻灯片时,HTML 内容通过此字段输出 |
| └─ position | List<Number> | 如果工具涉及到 PPT 的操作,position 字段指明具体操作哪几页 slides;例如: • 当用户输入「在第二页之后插入一张幻灯片」,则 position = [3],output 是第三页幻灯片的 HTML 内容• 当用户输入「请删除第四、五、六页幻灯片」,则 position = [4, 5, 6] |
请求示例
curl --location --request POST 'https://open.bigmodel.cn/api/v1/agents' \
--header 'Authorization: {{api-key}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"agent_id": "slides_glm_agent",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "帮我生成一个游戏主机市场发展调研"
}
]
}
]
}'
响应示例
// 第一次 event
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 0,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "我需要为"
}
],
"phase": "thinking"
}
]
}
]
}
// 第二次 event
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 1,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "用户生成一个"
}
],
"phase": "thinking"
}
]
}
]
}
// 命中工具
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 2,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "object",
"object": {
"tool_name" : "search",
"input" : "搜索词"
},
"tag_cn": "搜索",
"tag_en": "Search"
}
]
"phase": "tool"
}
]
}
]
}
// 命中工具
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 3,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "object",
"object": {
"tool_name" : "search",
"output" : "搜索结果"
},
"tag_cn": "搜索",
"tag_en": "Search"
}
],
"phase": "tool"
}
]
}
],
}
// 命中工具
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 4,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "object",
"object": {
"tool_name" : "insert_page",
"input": "创建中国游戏主机市场现状与机遇页,详细介绍中..."
},
"tag_cn": "插入幻灯片",
"tag_en": "Insert Page"
}
],
"phase": "tool"
}
]
}
]
}
// 命中工具
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 5,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "object",
"object": {
"tool_name" : "insert_page",
"output" : "html doc",
"position": [1],
"title":"标题"
},
"tag_cn": "添加幻灯片",
"tag_en": "Insert Page"
}
],
"phase": "tool"
}
]
}
],
}
// 命中工具
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 5,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "object",
"object": {
"tool_name" : "remove_slides",
"position": [1,2,3]
},
"tag_cn": "删除幻灯片",
"tag_en": "Remove Pages"
}
],
"phase": "tool"
}
]
}
],
}
// assistant answer
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 6,
"messages": [
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "文案"
}
],
"phase": "answer"
}
]
}
]
}
// 最后一次 event
{
"id": "202507221412023db1a56fc77943d8",
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 123,
"finish_reason": "stop"
"messages": [
...
],
}
],
"usage": {
"prompt_tokens": 100,
"completion_tokens": 200,
"total_tokens": 300
},
// 如果 finish_reason != stop,出现 error 字段;
"error": {
"code": "1301",
"message": "系统检测到输入或生成内容可能包含不安全或敏感内容"
}
}
导出PDF
接口请求
| 传输方式 | https |
|---|---|
| 请求地址 | https://open.bigmodel.cn/api/v1/agents/conversation/ |
| 调用方式 | 同步调用,等待模型完成执行并返回最终结果或使用SSE调用 |
| 字符编码 | UTF-8 |
| 接口请求格式 | JSON |
| 响应格式 | JSON |
| 接口请求类型 | POST |
| 开发语言支持 | 任意可发起 http 请求的开发语言 |
请求参数
| 字段名称 | 字段类型 | 是否必填 | 备注 |
|---|---|---|---|
| agent_id | String | 是 | 智能体 ID,ID值:slides_glm_agent |
| conversation_id | String | 是 | 当前对话的唯一ID |
| custom_variables | Object | 否 | 自定义参数 |
| └─ include_pdf | Boolean | 否 | 是否导出 PDF 文件 |
| └─ include_html | Boolean | 否 | 是否导出 HTML 文件 |
响应参数
| 字段名称 | 字段类型 | 备注 |
|---|---|---|
| agent_id | String | 固定值:slides_glm_agent |
| conversation_id | String | 当前对话的唯一ID |
| choices | List<Object> | 智能体响应选项 |
| └─ messages | List<Object> | 智能体响应消息体 |
| └─ role | String | 智能体的角色 role = assistant |
| └─ content | List<Object> | 智能体响应内容 |
| └─ type | String | 响应内容类型:文件下载链接-file_url、图片下载链接- image_url |
| └─ tag_cn | String | 标签(中文),例如:市场调研.pdf |
| └─ tag_en | String | 标签(英文),例如:market research.pdf |
| └─ file_url | String | 如果 type = file_url,则这个字段给出文件的具体下载链接 |
| └─ image_url | String | 如果 type = image_url,则这个字段给出图片的具体下载链接 |
请求示例
{
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"custom_variables": {
"include_pdf": true
}
}
响应示例
{
"agent_id": "slides_glm_agent",
"conversation_id": "1750756263-a0e8bc1e2ee14879810025009e2ff693",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"messages": [
{
"role": "assistant",
"content": [
{
"type": "file_url",
"file_url": "https://xxx.cn",
"tag_cn": "市场调研.pdf",
"tag_en": "market research.pdf"
}
],
"phase": "answer"
}
]
}
]
}