- 系统使用介绍
- API介绍
- 项目说明
- 导言
- 身份验证
- 发出请求
- 参数详情
- 聊天(Chat)
- 音频(Audio)
- 图像(Images)
- 文件(Files)
- 自动补全(Completions)
- 嵌入(Embeddings)
- 音乐接口
- 绘图接口
- 视频接口
- luma
- 官方异步调用
- GoAmzAI格式
- OpenAI 聊天格式POST
- 本系统API
OpenAI 聊天格式
POST
{{BASE_URL}}/v1/chat/completions
请求参数
Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token示例:
Authorization: Bearer ********************
Header 参数
string
可选
Content-Type
string
必需
示例值:
string;
Accept
string
必需
示例值:
string;
Authorization
string
必需
示例值:
string;
Body 参数application/json
stream
boolean
必需
model
string
必需
messages
array [object {2}]
必需
role
string
可选
content
string
可选
示例
{
"stream": true,
"model": "luma-video",
"messages": [
{
"role": "user",
"content": "AI网站宣传"
}
]
}
示例代码
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location -g --request POST '{{BASE_URL}}/v1/chat/completions' \
--header ';' \
--header 'Accept: string;' \
--header 'Authorization: string;' \
--header 'Content-Type: string;' \
--data-raw '{
"stream": true,
"model": "luma-video",
"messages": [
{
"role": "user",
"content": "AI网站宣传"
}
]
}'
返回响应
🟢200成功
application/json
Body
id
string
必需
object
string
必需
created
integer
必需
choices
array [object {3}]
必需
index
integer
可选
message
object
可选
finish_reason
string
可选
usage
object
必需
prompt_tokens
integer
必需
completion_tokens
integer
必需
total_tokens
integer
必需
示例
{
"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
}
}
修改于 2024-11-04 07:18:13