指令智能生成PPT
更新时间:2025-10-27
概述
根据用户输入的指令,智能生成对应的PPT内容。该组件为付费功能,具体计费说明请参见使用文档。
接口定义
| URL | https://qianfan.baidubce.com/v2/tools/ai_command_ppt/command_ppt |
|---|---|
| Method | POST |
Headers
| 字段 | 值 |
|---|---|
| Authorization | Bearer {ApiKey} |
| Content-Type | application/json |
| X-Appbuilder-Request-Id | 非必填项(建议填写,方便后续链路问题排查,UUID格式) |
请求参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| query | string | 是 | 输入要生成PPT的主题内容 |
请求示例
返回PPTUrl需要把里面的\u0026替换成&就可以下载
curl --request POST \
--url https://qianfan.baidubce.com/v2/tools/ai_command_ppt/command_ppt \
--header 'authorization: Bearer xxxxx' \
--header 'content-type: application/json' \
--header 'user-agent: vscode-restclient' \
--data '{
"query":"帮我写一篇关于大模型的ppt"
}'也可通过在代码里使用的时候用json.loads,返回PPTUrl可直接下载
import requests
import json
url = "https://qianfan.baidubce.com/v2/tools/ai_command_ppt/command_ppt"
headers = {
"authorization": "Bearer xxxx",
"content-type": "application/json",
}
data = {
"query": "帮我写一篇关于大模型的ppt"
}
with requests.post(url, headers=headers, json=data, stream=True) as resp:
resp.raise_for_status()
for line in resp.iter_lines(decode_unicode=True):
if not line:
continue # 跳过空行
try:
obj = json.loads(line)
res = json.loads(obj['data']['result'])
print("收到一行:", res)
except json.JSONDecodeError:
print("非JSON行:", line)
print()
print("cover_url", res['cover_urls'])
print("ppt_url", res['ppt_url'])响应参数
正确响应
返回为流式返回,每一行是一个json字符串,定义如下
| 参数 | 类型 | 说明 |
|---|---|---|
| result_type | int | 是否结束,1为未结束,0为结束 |
| result | string | 工具输出内容,result字段为json字符串包括两个字段 title:ppt标题 result:ppt大纲(sse输出) |
| need_clear_history | bool | 风控 |
| flag | int | 风控 |
响应示例
{
"errno": 0,
"errMsg": "success",
"type": 2,
"data": {
"chat_id": 0,
"query_id": 0,
"ai_id": "",
"object": "",
"created": 0,
"sentence_id": 0,
"channel": "",
"is_end": false,
"is_truncated": false,
"result": "{\"title\":\"大模型技术发展与应用\",\"result\":\" * 模型轻量化方向\\n\"}",
"need_clear_history": false,
"flag": 0,
"thought_type": "tt_genppt_outline",
"content_type": "",
"memory_status": 0,
"source": "",
"model": "",
"query_time": 0,
"answer_time": 0,
"reasoning_content": "",
"result_type": 1,
"reasoning_cost": 0,
"hit_deep_think": 0,
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
},
"extra_info": null,
"tp": {
"plugin": {
"ChatFilePlus": {
"recommendQuestions": null
}
}
},
"plug_in_info": {
"svg_graph_chart": ""
}
},
"requestId": ""
}PPT生成成功输出示例
| 参数名 | 类型 | 说明 |
|---|---|---|
| cover_urls | list | 封面 |
| ppt_url | string | 下载链接有效期45天 |
{
"cover_urls": ["https://wenku-edit.cdn.bcebos.com/doc/92a8cb2aa900b52acfc789eb172ded630a1c9804/file/84268b4e5ab69fa9527792c97dea0516/cover_1.png?auth_key=2070861495-file-29228190-0-b9158f2ec3939c805c8ccee653cba64d\u0026t=175550149", "https://wenku-edit.cdn.bcebos.com/doc/92a8cb2aa900b52acfc789eb172ded630a1c9804/file/84268b4e5ab69fa9527792c97dea0516/cover_2.png?auth_key=2070861495-file-34726282-0-a5cdc9978c9cd6d4ee6cec06d41aa7a8\u0026t=175550149", "https://wenku-edit.cdn.bcebos.com/doc/92a8cb2aa900b52acfc789eb172ded630a1c9804/file/84268b4e5ab69fa9527792c97dea0516/cover_3.png?auth_key=2070861495-file-76679146-0-1f7bd8adad1f4e84e47f2b31d78d7bd0\u0026t=175550149"],
"ppt_url": "https://wkbjcloudbos.bdimg.com/v1/docconvert9098/e919c9f21b0cad4577e266729b9b4be1/rtcs/ppteditor/84268b4e5ab69fa9527792c97dea0516/84268b4e5ab69fa9527792c97dea0516.pptx?responseContentType=application%2Fvnd.openxmlformats-officedocument.presentationml.presentation\u0026responseCacheControl=max-age%3D3888000\u0026responseExpires=Thu%2C%2002%20Oct%202025%2015%3A18%3A17%20%2B0800\u0026authorization=bce-auth-v1%2Ffa1126e91489401fa7cc85045ce7179e%2F2025-08-18T07%3A18%3A17Z%2F311040000%2Fhost%2F679953a663bd97cbc03fc9f574480715155f476b9f1f3a021daf713db036e55a\u0026responseContentDisposition=attachment%3B%20filename%3D%22%25E9%259A%25BE%25E5%25BF%2598%25E7%259A%2584%25E4%25B8%2580%25E6%25AC%25A1%25E7%25BB%258F%25E5%258E%2586.pptx%22\u0026token=eyJ0eXAiOiJKSVQiLCJ2ZXIiOiIxLjAiLCJhbGciOiJIUzI1NiIsImV4cCI6MjA2NjU0MTQ5NywidXJpIjp0cnVlLCJwYXJhbXMiOlsicmVzcG9uc2VDb250ZW50RGlzcG9zaXRpb24iLCJyZXNwb25zZUNvbnRlbnRUeXBlIiwicmVzcG9uc2VDYWNoZUNvbnRyb2wiLCJyZXNwb25zZUV4cGlyZXMiXX0%3D.y83TZUlmycYZ548soN06HCRBTzEiFklic5Y8wTWrbD4%3D.2066541497"
}异常响应
| 字段 | 类型 | 是否必填 | 说明 |
|---|---|---|---|
| requestID | str | 是 | 请求ID |
| code | str | 否 | 0 表示成功,其他都是异常 |
| message | str | 否 | 错误消息 |
| detail | 否 | 异常详情信息 |
