聊天接口 /v1/chat/completions
POST
/v1/chat/completionsOpenAI 对话模型接口,兼容文心一言(ernie-bot,ernie-bot-4,ernie-turbo),讯飞星火(spark-v1.5,spark-v2.0,spark-v3.0)
请求参数
Body 参数application/json
No schema defined
示例
{
"model": "ernie-bot",
"messages": [
{
"role": "user",
"content": "你好,你会干什么呢"
}
],
"max_tokens": 1000,
"stream": true
}
示例代码
返回响应
成功(200)
请求有误(400)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
id
string
必需
object
string
必需
created
integer
必需
choices
array [object {3}]
必需
index
integer
可选
message
object
消息
finish_reason
string
可选
usage
object
消耗
prompt_tokens
integer
输入 tokens
completion_tokens
integer
响应 tokens
total_tokens
integer
必需
总消耗 tokens, prompt+completion
示例
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?",
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
最后修改时间: 1 年前