对话补全
curl --request POST \
--url https://aiapi.xiaoliu.fun/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
],
"style": "openai",
"stream": true
}
'import requests
url = "https://aiapi.xiaoliu.fun/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
],
"style": "openai",
"stream": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{role: '<string>', content: '<string>'}],
style: 'openai',
stream: true
})
};
fetch('https://aiapi.xiaoliu.fun/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://aiapi.xiaoliu.fun/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'role' => '<string>',
'content' => '<string>'
]
],
'style' => 'openai',
'stream' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://aiapi.xiaoliu.fun/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"style\": \"openai\",\n \"stream\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://aiapi.xiaoliu.fun/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"style\": \"openai\",\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aiapi.xiaoliu.fun/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"style\": \"openai\",\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body视频
生成视频
使用大语言模型进行对话交互
POST
/
v1
/
chat
/
completions
对话补全
curl --request POST \
--url https://aiapi.xiaoliu.fun/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
],
"style": "openai",
"stream": true
}
'import requests
url = "https://aiapi.xiaoliu.fun/v1/chat/completions"
payload = {
"model": "<string>",
"messages": [
{
"role": "<string>",
"content": "<string>"
}
],
"style": "openai",
"stream": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
messages: [{role: '<string>', content: '<string>'}],
style: 'openai',
stream: true
})
};
fetch('https://aiapi.xiaoliu.fun/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://aiapi.xiaoliu.fun/v1/chat/completions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => '<string>',
'messages' => [
[
'role' => '<string>',
'content' => '<string>'
]
],
'style' => 'openai',
'stream' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://aiapi.xiaoliu.fun/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"style\": \"openai\",\n \"stream\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://aiapi.xiaoliu.fun/v1/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"style\": \"openai\",\n \"stream\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://aiapi.xiaoliu.fun/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"messages\": [\n {\n \"role\": \"<string>\",\n \"content\": \"<string>\"\n }\n ],\n \"style\": \"openai\",\n \"stream\": true\n}"
response = http.request(request)
puts response.read_body使用 Sora 模型根据文本或对话生成视频
功能说明
使用 OpenAI 旗舰级视频生成模型 Sora 2 生成高保真、长达一分钟的视频。视频生成通常需要较长时间(120秒以上),请使用流式请求以获取生成进度。
请求参数
| 名称 | 类型 | 必选 | 说明 |
|---|---|---|---|
model | string | 是 | 模型名称,如 sora-2 或 sora-2-hd |
messages | array | 是 | 对话格式的消息列表,用于描述视频内容 |
stream | boolean | 否 | 是否启用流式响应(推荐设置为 true) |
调用示例
import openai
client = openai.OpenAI(
api_key="sk-your-api-key-here",
base_url="https://aiapi.xiaoliu.fun/v1"
)
response = client.chat.completions.create(
model="sora-2",
messages=[
{"role": "user", "content": "一只可爱的小猫在草地上奔跑"}
],
stream=True
)
for chunk in response:
if chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")
curl https://api.qhaigc.net/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-your-api-key-here" \
-d '{
"model": "sora-2",
"messages": [
{"role": "user", "content": "一只可爱的小猫在草地上奔跑"}
],
"stream": true
}'
响应流程
流式响应会实时返回任务进度,成功后提供视频下载链接:⌛️ 任务正在队列中,请耐心等待...🏃 进度:36.0%- …
✅ 视频生成成功,[点击这里](https://...) 查看视频~~~
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Response
200
成功响应 (流式)
⌘I