跳到主要内容

进行 Agent 问答对话

POST 

https://env-xxxx.api.tcloudbasegateway.com/v1/aibot/bots/:botId/send-message

进行 Agent 问答对话

Request

Path Parameters

    botId stringrequired

    Agent ID

    Example: bot-xxx

Body

required
    msg stringrequired

    用户发送信息

    history object[]

    历史对话信息

  • Array [
  • role stringrequired

    历史信息角色

    content stringrequired

    历史信息内容

  • ]
  • searchEnable boolean

    是否启用联网查询,当且仅当 Agent 配置的 searchEnable 与本字段都为 true 时,才开启联网搜索

    files string[]

    文件相关对话所需字段,可以将文件上传到云存储中,使用文件的云存储链接 cloud://xxx.xxx 或者使用可访问的文件公网链接 https://xxxx.xxxx

    conversationId string

    会话ID, 开启多会话功能之后生效,标记本次对话所属的会话,可以从 conversation 相关接口中获取 ID

Responses

Agent 对话成功时返回, 返回格式为 SSE 格式

Response Headers
  • X-Request-Id string

    请求ID

Schema
    created number

    对话时间戳

    record_id string

    对话记录ID

    model string

    大模型类型

    version string

    大模型版本

    type string

    回复类型: text: 主要回答内容,thinking: 思考过程,search: 查询结果,knowledge: 知识库

    role string

    对话角色,响应中固定为 assistant

    content string

    对话内容

    finish_reason string

    对话结束标志,continue 表示对话未结束,stop 表示对话结束

    reasoning_content string

    深度思考内容(仅deepseek-r1是不为空字符串)

    usage object

    token使用量

    promptTokens number

    表示prompt的tokens数,多次返回中保持不变

    completionTokens number

    回答的token总数,在流式返回中,表示到目前为止所有 completion 的 tokens 总数,多次返回中持续累加

    totalTokens number

    表示 promptTokens 和 completionTokens 之和

    knowledge_base string[]

    对话中使用到的知识库

    search_info object

    搜索结果信息,需要开启联网查询

    search_results undefined[]

    搜索引文信息

  • Array [
  • index string

    搜索引文序号

    title string

    搜索引文标题

    url string

    搜索引文链接

  • ]

Authorization: http

name: JWTAuthtype: httpscheme: bearerdescription: 环境 ID 所对应的 token,使用登录鉴权(v2)获取
curl -L 'https://env-xxxx.api.tcloudbasegateway.com/v1/aibot/bots/:botId/send-message' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <TOKEN>' \
-d '{
"msg": "你好",
"history": [
{
"role": "user",
"content": "这是一条对话信息"
}
],
"searchEnable": true,
"files": [
"cloud://xxx.xxxx"
],
"conversationId": "conversation-xxx"
}'
Request Collapse all
Base URL
https://env-xxxx.api.tcloudbasegateway.com
Auth
Parameters
— pathrequired
Body required
{
"msg": "你好",
"history": [
{
"role": "user",
"content": "这是一条对话信息"
}
],
"searchEnable": true,
"files": [
"cloud://xxx.xxxx"
],
"conversationId": "conversation-xxx"
}
ResponseClear

Click the Send API Request button above and see the response here!