模型对话调用(Completions)
POST
/v1/chat/completions
请求参数
Header 参数
Content-Type
string
必需
示例值:
application/json
Authorization
string
必需
示例值:
Bearer {{token}}
Body 参数application/json
model
string
模型
uid
string
用户id,一个代表你的最终用户的唯一标识符
auditing
string
内容审核的场景策略
domain
string
需要使用的领域
temperature
核采样阈值
top_k
从k个中随机选择一个(非等概率)
max_tokens
回答的tokens的最大长度
stream
boolean
是否支持流式
plugins
array[string]
插件
location
object
位置
latitude
number
纬度
longitude
number
经度
messages
array [object {2}]
会话和提问
role
string
角色
content
string
文本内容
示例
{
"temperature": 0.5,
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "广州有什么东西玩,十个字内回复"
}
]
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.listenai.com/v1/chat/completions' \
--header 'Authorization: Bearer {{token}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"temperature": 0.5,
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "广州有什么东西玩,十个字内回复"
}
]
}'
返回响应
🟢200成功
application/json
Body
choices
array [object {3}]
必需
finish_reason
null
可选
index
integer
可选
message
object
可选
created
integer
必需
id
string
必需
object
string
必需
usage
object
必需
completion_tokens
integer
必需
prompt_tokens
integer
必需
question_tokens
integer
必需
total_tokens
integer
必需
示例
{
"choices": [
{
"finish_reason": null,
"index": 0,
"message": {
"content": "广州有很多值得玩的地方,比如珠江夜游、白云山、荔枝湾等。此外,广州还有丰富的美食文化和购物场所,例如北京路步行街和天河城购物中心。",
"role": "assistant"
}
}
],
"created": 1683804700,
"id": "cht000d6b4f@dx1880a94b87ab894540",
"object": "chat.completion",
"usage": {
"completion_tokens": 44,
"prompt_tokens": 8,
"question_tokens": 7,
"total_tokens": 52
}
}
修改于 2023-09-19 02:37:56