进行 Agent 问答对话
POSThttps://env-xxxx.api.tcloudbasegateway.com/v1/aibot/bots/:botId/send-message
进行 Agent 问答对话
Request
Path Parameters
botId stringrequired
Agent ID
Example: bot-xxx
- application/json
Body
required
msg stringrequired
用户发送信息
history object[]
searchEnable boolean
是否启用联网查询,当且仅当 Agent 配置的 searchEnable 与本字段都为 true 时,才开启联网搜索
files string[]
文件相关对话所需字段,可以将文件上传到云存储中,使用文件的云存储链接 cloud://xxx.xxx 或者使用可访问的文件公网链接 https://xxxx.xxxx
conversationId string
会话ID, 开启多会话功能之后生效,标记本次对话所属的会话,可以从 conversation 相关接口中获取 ID
Responses
- 200
- default
Agent 对话成功时返回, 返回格式为 SSE 格式
Response Headers
- application/json
- Schema
- Example (from schema)
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
knowledge_base string[]
对话中使用到的知识库
search_info object
{
"created": "1726030224",
"record_id": "record-427d3652",
"model": "hunyuan",
"version": "202407241700",
"type": "assistant",
"role": "assistant",
"content": "你好",
"finish_reason": "continue",
"reasoning_content": "",
"usage": {
"promptTokens": 10,
"completionTokens": 20,
"totalTokens": 30
},
"knowledge_base": [
""
],
"search_info": {
"search_results": [
{
"index": "【1】",
"title": "标题",
"url": "链接"
}
]
}
}
Agent 对话失败时返回
- application/json
- Schema
- Example (from schema)
Schema
code string
错误代码
message string
错误信息
requestId string
请求ID
{
"code": "INVALID_CREDENTIALS",
"message": "Credentials are invalid",
"requestId": "6360ba4b-f672-434b-9dee-35686a5589a4"
}
Authorization: http
name: JWTAuthtype: httpscheme: bearerdescription: 环境 ID 所对应的 token,使用登录鉴权(v2)获取
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- powershell
- CURL
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"
}'
ResponseClear