新建对话
更新时间:2025-04-17
POST
https://qianfan.baidubce.com/v2/app/conversation
该接口用于新建conversation_id,conversation_id的有效期为7天。超过之后可能无法使用,需要重新生成。
权限说明
调用本API,需使用API Key鉴权方式。Authorization的值为Bearer <API Key>。获取API Key流程,请查看授权。
请求参数
Headers 参数
除公共头域外,无其它特殊头域
Body 参数
app_id
string
指定需要创建对话的app_id,来源于个人空间-应用-应用ID
必选
请求结构
POST /v2/app/conversation HTTP/1.1
HOST: qianfan.baidubce.com
Authorization: Bearer <API Key>
Content-Type: application/json
{
"app_id": "c5c7bfa8-97f6-48c0-97ac-689d1f6df6be"
}
示例代码
curl
curl --location 'https://qianfan.baidubce.com/v2/app/conversation' \
--header 'Authorization: Bearer <API Key>' \
--header 'Content-Type: application/json' \
--data '{
"app_id": "85036d8f-239c-469c-b342-b62ca9d696f6"
}'
返回响应
Headers 参数
除公共头域外,无其它特殊头域
返回参数
request_id
string
request_id
必选
conversation_id
string
本轮对话id,可以用于后续调用,有效期为7天。
必选
JSON
HTTP/1.1 200 OK
{
"request_id": "355a4f4e-a6d8-4dec-b840-7075030c6d22",
"conversation_id": "2370813b-5303-4a4f-b5cc-44f571121342"
}
JSON
HTTP/1.1 401
{
"request_id": "ae2225f7-1c2e-427a-a1ad-5413b762957d",
"code": "PermissionDeniedError",
"message": "没有权限"
}