获取Prompt模板列表
更新时间:2025-05-20
接口描述
本接口用于获取Prompt模板列表。
鉴权说明
调用本文API,使用“基于安全认证AK/SK”进行签名计算鉴权,即使用安全认证中的Access Key ID 和 Secret Access Key进行鉴权,具体鉴权认证机制参考HTTP调用鉴权说明。
请求结构
Bash
1POST /v2/promptTemplates?Action=DescribePromptTemplates HTTP/1.1
2Host: qianfan.baidubce.com
3Authorization: authorization string
4Content-Type: application/json
5
6{
7 "marker": "",
8 "maxKeys":2,
9 "name": "",
10 "labelIds": ["pl-838e92379b93991e"],
11 "type": "Custom",
12}
请求头域
除公共头域外,无其它特殊头域。
请求参数
- Query参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
Action | string | 是 | 方法名称,固定值DescribePromptTemplates |
- Body参数
名称 | 类型 | 必填 | 描述 |
---|---|---|---|
marker | string | 否 | 标记本次查询的起始位置。首次或首页查询可不传或传空字符串,往后翻页时请传上一次查询响应体中的的nextMarker |
maxKeys | int | 否 | 本次查询包含的最大结果集数量,默认10,建议最大值不超过100 |
pageReverse | bool | 否 | 是否倒序查询,默认为false |
name | string | 否 | 输入模板名称或内容搜索 |
labelIds | List<string> | 否 | 标签ID数组,说明: (1)如果不填写该字段,表示获取所有模板 (2)数组内元素为标签ID,string类型 |
type | string | 否 | 模板类型,可选值: · System:系统预置模板 · Custom:用户创建模板 |
响应头域
除公共头域外,无其它特殊头域。
响应参数
名称 | 类型 | 描述 |
---|---|---|
requestId | string | 请求ID |
code | string | 错误码,错误时返回 |
message | string | 错误信息,请求失败时返回 |
result | object | 请求结果,请求成功时返回 |
result说明
名称 | 类型 | 说明 |
---|---|---|
pageInfo | object | 分页信息 |
items | List<object> | 模板数组 |
pageInfo说明
名称 | 类型 | 说明 |
---|---|---|
marker | string | 本次查询的起始位置标识 |
isTruncated | bool | 后面是否还有数据。 · true:表示后面还有数据 · false:表示已经是最后一页 |
nextMarker | string | 下次查询的起始位置标记,示例:"pl-dnqpsnv1sahwj604" |
maxKeys | int | 本次查询的页大小 |
items说明
名称 | 类型 | 说明 |
---|---|---|
templateId | string | Prompt模板的ID |
templateName | string | Prompt模板的名称 |
templateContent | string | 模板内容, ·(1)如果不使用框架,示例:请以{number}字数生成{province}省相关简介" ·(2)如果使用模型框架该字段值需符合框架要求,详见模板框架说明 |
negativeTemplateContent | string | 反向prompt模板内容,表示不希望大模型生成的内容,说明:只有sceneType为TextToImage,即场景类型为文生图时,返回该字段 |
negativeTemplateVariables | string | 反向prompt模板的变量,说明:只有sceneType为TextToImage,即场景类型为文生图时,返回该字段 |
labels | List<object> | 模板标签 |
type | string | 模板类型,说明: · System:系统预置模板 · Custom:用户创建模板 |
sceneType | string | 场景类型,说明: · TextToText:文生文 · TextToImage:文生图 |
labels说明
名称 | 类型 | 描述 |
---|---|---|
labelId | string | 标签ID |
labelName | string | 标签名称 |
color | string | 标签颜色,仅预置标签有该字段 |
search_info说明
名称 | 类型 | 描述 |
---|---|---|
search_results | List<object> | 搜索结果列表 |
search_results说明
名称 | 类型 | 描述 |
---|---|---|
index | int | 序号 |
url | string | 搜索结果URL |
title | string | 搜索结果标题 |
请求示例
Bash
1# 替换下列示例中的Authorization、x-bce-date
2curl -i --location 'https://qianfan.baidubce.com/v2/promptTemplates?Action=DescribePromptTemplates'\
3--header 'Authorization: bce-auth-v1/f0ee7axxxx/2023-09-19T13:42:13Z/180000/host;x-bce-date/9a8cfb8ee58a8f44a21axxxxxx4525543'\
4--header 'x-bce-date: 2023-09-19T13:37:10Z'\
5--header 'Content-Type: application/json'\
6--data '{
7 "marker": "",
8 "maxKeys":2,
9 "name": "",
10 "labelIds": ["pl-838e92379b93991e"],
11 "type": "Custom",
12}'
响应示例
JSON
1{
2 "requestID": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
3 "result": {
4 "pageInfo":{
5 "marker":"pt-5c126587e90b2b15",
6 "isTruncated":true,
7 "nextMarker":"pt-sdsfds516ca2f4d02",
8 "maxKeys": 2
9 },
10 "items": [
11 {
12 "templateId": "pt-5c126587e90b2b15",
13 "templateName": "照片写实2",
14 "templateContent": "Cherry Blossoms in Hokkaido in the {season}, Canon RF 16mm f:2.8 STM Lens, hyperrealistic photography, style of unsplash and National Geographic",
15 "negativeTemplateContent": "owres,bad anatomy,cropped,worst quality,low quality,normal quality,blurry,blurry,sketches",
16 "labels": [
17 {
18 "labelId": "pl-838e92379b93991e",
19 "labelName": "图像生成",
20 "color": "#0099E6"
21 }
22 ],
23 "type": "System",
24 "sceneType": "TextToImage"
25 },
26 {
27 "templateId": "pt-8d2916f476edb9d8",
28 "templateName": "3D角色",
29 "templateContent": "snowing winter, super cute baby pixar style white fairy bear, shiny snow-white fluffy, big bright eyes, wearing a woolly cyan hat, delicate and fine, high detailed, bright color, natural light, simple background, octane render, ultra wide angle, 8K",
30 "negativeTemplateContent": "(worst quality, low quality:1.4),signature, watermark, simple background, dated, low res, line art, flat colors",
31 "labels": [
32 {
33 "labelId": "pl-2c99e0e003a78114",
34 "labelName": "图像生成",
35 "color": "#0099E6"
36 }
37 ],
38 "type": "System",
39 "sceneType": "TextToImage"
40 }
41 ]
42 }
43}
错误码
若请求错误,服务器将返回的JSON文本包含以下参数:
名称 | 描述 |
---|---|
requestId | 请求ID |
code | 错误码 |
message | 错误描述信息,帮助理解和解决发生的错误 |
例如错误返回:
Plain Text
1{
2 "requestId":"6ba7b810-xxxxc04fd430c8",
3 "code":"AccessDenied",
4 "message":"Access denied."
5}
更多其他错误码,也可以查看错误码说明。