进行 Agent 问答对话(OpenAI 协议)
POST/v1/aibot/openai/chat/completions
进行 Agent 问答对话(OpenAI 协议)
Request
- application/json
Body
required
- Array [
- ]
model stringrequired
Agent ID
messages object[]required
消息
role stringrequired
历史信息角色
content stringrequired
历史信息内容
stream booleanrequired
是否流式返回
Responses
- x-stream:false
- x-stream:true
- default
Agent 对话成功时,非流失返回
Response Headers
X-Request-Id string
请求ID
- application/json
- Schema
- Example (from schema)
Schema
- Array [
- ]
id string
对话记录ID
object string
接口类型
created number
对话时间戳
model string
Agent ID
choices undefined[]
choices
index number
index
message object
role string
消息类型
content string
消息内容
finish_reasion string
对话结束标志,continue 表示对话未结束,stop 表示对话结束
usage object
token使用量
prompt_tokens number
表示prompt的tokens数,多次返回中保持不变
completion_tokens number
回答的token总数,在流式返回中,表示到目前为止所有completion的tokens总数,多次返回中持续累加
total_tokens number
表示prompt_tokens和completion_tokens之和
{
"id": "record-427d3652",
"object": "chat.completion",
"created": "1726030224",
"model": "bot-xxxx",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好"
},
"finish_reasion": "continue"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 0
}
}
Agent 对话成功时,流失返回
- application/json
- Schema
- Example (from schema)
Schema
- Array [
- ]
id string
对话记录ID
object string
接口类型
created number
对话时间戳
model string
Agent ID
choices undefined[]
choices
index number
index
delta object
role string
消息类型
content string
消息内容
finish_reasion string
对话结束标志,continue 表示对话未结束,stop 表示对话结束
usage object
token使用量
prompt_tokens number
表示prompt的tokens数,多次返回中保持不变
completion_tokens number
回答的token总数,在流式返回中,表示到目前为止所有completion的tokens总数,多次返回中持续累加
total_tokens number
表示prompt_tokens和completion_tokens之和
{
"id": "record-427d3652",
"object": "chat.completion",
"created": "1726030224",
"model": "bot-xxxx",
"choices": [
{
"index": 0,
"delta": {
"role": "assistant",
"content": "你好"
},
"finish_reasion": "continue"
}
],
"usage": {
"prompt_tokens": 10,
"completion_tokens": 20,
"total_tokens": 0
}
}
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"
}
Loading...