生成聊天消息的自动完成
POST
/v1/chat/completions
openaichatgptai
为提供的提示和参数创建完成
请求参数
Header 参数
Authorization
string
可选
示例值:
e5x0eiy8T3BlbkFJe5TuiqVv5kRro4NT2356
Content-Type
string
可选
示例值:
application/json
Body 参数application/json
model
string
必需
messages
array [object {2}]
必需
role
string
定义角色
content
string
定义内容
temperature
integer
可选
top_p
integer
可选
n
integer
可选
stop
string
可选
max_tokens
integer
可选
presence_penalty
number
可选
frequency_penalty
number
可选
logit_bias
null
可选
user
string
可选
示例
{
"model": "gpt-3.5-turbo",
"stream": true,
"messages": [
{
"role": "system",
"content": "你是一个助手"
},
{
"role": "user",
"content": "10字介绍下鲁迅"
}
]
}
示例代码
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.aigcte.com/v1/chat/completions' \
--header 'Authorization: e5x0eiy8T3BlbkFJe5TuiqVv5kRro4NT2356' \
--header 'Content-Type: application/json' \
--data-raw '{"model":"gpt-3.5-turbo","stream":true,"messages":[{"role":"system","content":"你是一个助手"},{"role":"user","content":"10字介绍下鲁迅"}]}'
返回响应
🟢200成功
application/json
Body
id
string
必需
object
string
必需
created
integer
必需
model
string
必需
usage
object
必需
prompt_tokens
integer
必需
completion_tokens
integer
必需
total_tokens
integer
必需
choices
array [object {3}]
必需
message
object
可选
finish_reason
string
可选
index
integer
可选
示例
{
"id": "chatcmpl-7TRk1MEKW3OOVSHTFPzrHQmEn0xcE",
"object": "chat.completion",
"created": 1687252505,
"model": "gpt-4-0314",
"usage": {
"prompt_tokens": 43,
"completion_tokens": 1,
"total_tokens": 44
},
"choices": [
{
"message": {
"role": "assistant",
"content": "是"
},
"finish_reason": "stop",
"index": 0
}
]
}
修改于 2024-05-13 12:07:45