标准的openAI问答接口,参数保持同原生接口一致
正式环境
正式环境
POST
/openai/completions
请求参数
Body 参数application/json
messages
array[object (Message) {3}]
可选
index
integer
可选
role
string
可选
user。表示提交prompt的一方。
assistant。表示给出completion响应的一方,实际上就是ChatGPT本身。
system。message里role为system,是为了让ChatGPT在对话过程中设定自己的行为,
目前role为system的消息没有太大的实际作用,官方说法如下:
does not always pay strong attention to system messages. Future models will be trained to pay stronger attention to system messages.
content
string
内容
temperature
integer
可选
stream
boolean
可选
max_tokens
integer
可选
model
string
模型
user
string
用户标识
示例
{
"messages": [
{
"index": 0,
"role": "string",
"content": "string"
}
],
"temperature": 0,
"stream": true,
"max_tokens": 0,
"model": "string",
"user": "string"
}
示例代码
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.autostock.cn/v1/openai/completions' \
--header 'Content-Type: application/json' \
--data-raw '{
"messages": [
{
"index": 0,
"role": "string",
"content": "string"
}
],
"temperature": 0,
"stream": true,
"max_tokens": 0,
"model": "string",
"user": "string"
}'
返回响应
🟢200成功
application/json
Body
club.doctorxiong.api.common.CommonResponse<club.doctorxiong.api.common.response.ChatResponse>
code
integer
可选
参考
HttpResponse.Code
message
string
返回消息
traceId
string
链路ID
data
object (ChatResponse)
可选
id
string
会话id
created
integer
秒级时间戳
model
string
模型
choices
array[object (Choice) {4}]
回答
usage
object (Usage)
令牌使用量
meta
object (Object)
可选
示例
{
"code": 0,
"message": "",
"traceId": "",
"data": {
"id": "",
"created": 0,
"model": "",
"choices": [
{
"index": 0,
"finish_reason": "",
"message": {
"index": 0,
"role": "",
"content": ""
},
"delta": {
"content": ""
}
}
],
"usage": {
"completion_tokens": 0,
"prompt_tokens": 0,
"total_tokens": 0
}
},
"meta": {}
}
修改于 2024-02-04 10:02:39