- 前言(必读)
- OpenAI官方库使用教程
- 聊天模型(Chat)
- 向量嵌入
- 音频模型(Audio)
- 绘画模型(Painting)
- 音乐创作(suno)
- 视频模型(Video)
- 更多接口开发中...
聊天补全
POST
https://api.rcouyi.com/v1/completions
请求参数
Header 参数
Content-Type
string
必需
示例值:
application/json
Authorization
string
令牌KEY
示例值:
Bearer sk-xxxx
Body 参数application/json
model
string
模型名称
messages
array [object {2}]
必需
role
string
角色 system | user
content
string
提问消息
temperature
integer
温度
top_p
但不是两者同时使用。top_p
integer
可选
temperature
但不是两者同时使用。max_tokens
number
最大回复
stream
boolean
流式输出
n
number
可选
presence_penalty
integer
可选
frequency_penalty
integer
可选
logit_bias
null
可选
user
string
可选
示例
{
"model": "gpt-3.5-turbo-instruct",
"temperature": 0.7,
"max_tokens": 100,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"prompt": "天气非常好",
"logprobs": 1
}
示例代码
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.rcouyi.com/v1/completions' \
--header 'Authorization: Bearer sk-xxxx' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-3.5-turbo-instruct",
"temperature": 0.7,
"max_tokens": 100,
"top_p": 1,
"frequency_penalty": 0,
"presence_penalty": 0,
"prompt": "天气非常好",
"logprobs": 1
}'
返回响应
🟢200成功
application/json
Body
id
string
必需
object
string
必需
created
integer
必需
model
string
必需
choices
array [object {4}]
必需
text
string
可选
index
integer
可选
logprobs
object
可选
finish_reason
string
可选
usage
object
必需
prompt_tokens
integer
必需
completion_tokens
integer
必需
total_tokens
integer
必需
示例
{
"id": "cmpl-A1tJLfyQgj1j2GpvhA6QcMCZKwRtw",
"object": "text_completion",
"created": 1725014307,
"model": "gpt-3.5-turbo-instruct",
"choices": [
{
"text": ",适合出门旅行\n\n\n\nYes, the weather is very good today, perfect for a trip.",
"index": 0,
"logprobs": {
"tokens": [
",",
"bytes:\\xe9\\x80",
"bytes:\\x82",
"合",
"出",
"门",
"bytes:\\xe6\\x97",
"bytes:\\x85",
"行",
"\n\n",
"\n\n",
"Yes",
",",
" the",
" weather",
" is",
" very",
" good",
" today",
",",
" perfect",
" for",
" a",
" trip",
"."
],
"token_logprobs": [
-0.8015664,
-2.9169734,
-0.0111257555,
-0.053733885,
-0.78531545,
-0.9327129,
-1.958352,
-0.000043226137,
-1.355173,
-2.9879627,
-3.235125,
-3.9541612,
-0.007757815,
-0.08989862,
-0.000045491004,
-0.0013639278,
-0.32100397,
-1.1380858,
-0.97817147,
-0.15390687,
-0.25740996,
-0.0001373897,
-1.630863,
-0.292718,
-0.38636762
],
"top_logprobs": [
{
",": -0.8015664
},
{
"我": -2.431496
},
{
"bytes:\\x82": -0.0111257555
},
{
"合": -0.053733885
},
{
"出": -0.78531545
},
{
"门": -0.9327129
},
{
"游": -1.108056
},
{
"bytes:\\x85": -0.000043226137
},
{
"游": -0.3043021
},
{
"。": -1.4599112
},
{
"\n": -2.661734
},
{
"是": -0.9270617
},
{
",": -0.007757815
},
{
" the": -0.08989862
},
{
" weather": -0.000045491004
},
{
" is": -0.0013639278
},
{
" very": -0.32100397
},
{
" nice": -0.39199966
},
{
",": -0.9151126
},
{
",": -0.15390687
},
{
" perfect": -0.25740996
},
{
" for": -0.0001373897
},
{
" going": -0.63430005
},
{
" trip": -0.292718
},
{
".": -0.38636762
}
],
"text_offset": [
5,
6,
6,
7,
8,
9,
10,
10,
11,
12,
14,
16,
19,
20,
24,
32,
35,
40,
45,
51,
52,
60,
64,
66,
71
]
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 6,
"completion_tokens": 25,
"total_tokens": 31
}
}
修改于 2024-11-12 13:06:58