OpenAI 视频接口
curl --request POST \
--url 'https://api.example.com/{{llmApiOrigin}}/v1/videos' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"seconds": "<string>",
"size": "<string>",
"input_reference": "<string>"
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/v1/videos"
payload = {
"model": "<string>",
"prompt": "<string>",
"seconds": "<string>",
"size": "<string>",
"input_reference": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
seconds: '<string>',
size: '<string>',
input_reference: '<string>'
})
};
fetch('https://api.example.com/{{llmApiOrigin}}/v1/videos', 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://api.example.com/{{llmApiOrigin}}/v1/videos",
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>',
'prompt' => '<string>',
'seconds' => '<string>',
'size' => '<string>',
'input_reference' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://api.example.com/{{llmApiOrigin}}/v1/videos"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"seconds\": \"<string>\",\n \"size\": \"<string>\",\n \"input_reference\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://api.example.com/{{llmApiOrigin}}/v1/videos")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"seconds\": \"<string>\",\n \"size\": \"<string>\",\n \"input_reference\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/v1/videos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"seconds\": \"<string>\",\n \"size\": \"<string>\",\n \"input_reference\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body视频系列
OpenAI 视频接口
OpenAI 兼容格式的视频接口(提交 / 查询 / Remix)
POST
{llmApiOrigin}
/
v1
/
videos
OpenAI 视频接口
curl --request POST \
--url 'https://api.example.com/{{llmApiOrigin}}/v1/videos' \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"prompt": "<string>",
"seconds": "<string>",
"size": "<string>",
"input_reference": "<string>"
}
'import requests
url = "https://api.example.com/{{llmApiOrigin}}/v1/videos"
payload = {
"model": "<string>",
"prompt": "<string>",
"seconds": "<string>",
"size": "<string>",
"input_reference": "<string>"
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: '<string>',
prompt: '<string>',
seconds: '<string>',
size: '<string>',
input_reference: '<string>'
})
};
fetch('https://api.example.com/{{llmApiOrigin}}/v1/videos', 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://api.example.com/{{llmApiOrigin}}/v1/videos",
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>',
'prompt' => '<string>',
'seconds' => '<string>',
'size' => '<string>',
'input_reference' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"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://api.example.com/{{llmApiOrigin}}/v1/videos"
payload := strings.NewReader("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"seconds\": \"<string>\",\n \"size\": \"<string>\",\n \"input_reference\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
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://api.example.com/{{llmApiOrigin}}/v1/videos")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"seconds\": \"<string>\",\n \"size\": \"<string>\",\n \"input_reference\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/v1/videos")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"<string>\",\n \"prompt\": \"<string>\",\n \"seconds\": \"<string>\",\n \"size\": \"<string>\",\n \"input_reference\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body简介
OpenAI 视频接口与 OpenAI 官方/v1/videos API 对齐,返回标准的视频对象(object: "video")格式,适合已经接入 OpenAI Videos API 的客户端。当前主要面向 Sora 2 系列模型,并支持 Remix(基于已有视频重新生成)。
服务端同时提供查询、Remix 与内容代理接口:
| 方法 | 路径 | 说明 |
|---|---|---|
POST | /v1/videos | 提交视频生成任务 |
GET | /v1/videos/{task_id} | 查询任务状态与结果 |
POST | /v1/videos/{video_id}/remix | 基于已有视频生成新视频(Remix) |
GET | /v1/videos/{task_id}/content | 获取视频文件本体(见视频内容获取) |
认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxx提交任务
POSThttps://api.shengmoai.com/v1/videos
支持 application/json 与 multipart/form-data 两种请求体。JSON 方式:
curl -X POST "https://api.shengmoai.com/v1/videos" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "一只可爱的小猫在花园里玩耍,阳光明媚",
"seconds": "4",
"size": "720x1280"
}'
curl -X POST "https://api.shengmoai.com/v1/videos" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-F "model=sora-2" \
-F "prompt=小猫在花园里追逐蝴蝶" \
-F "seconds=4" \
-F "size=720x1280" \
-F "image=@cat.png"
请求参数
string
必填
模型标识,如
sora-2string
视频生成提示词,描述画面动作与场景
string
默认值:"\"4\""
时长(秒),Sora 2 支持
4、8、12string
默认值:"720x1280"
分辨率:
720x1280(竖屏)、1280x720(横屏)string
参考图片(URL 或 Base64),用于图生视频;multipart 上传时字段名也是
input_reference提交响应
提交成功后返回视频对象,结构如下:{
"id": "video_69095b4ce0048190893a01510c0c98b0",
"task_id": "video_69095b4ce0048190893a01510c0c98b0",
"object": "video",
"model": "sora-2",
"status": "queued",
"progress": 0,
"created_at": 1782642668,
"expires_at": 1782729068,
"seconds": "4",
"size": "720x1280"
}
| 字段 | 类型 | 说明 |
|---|---|---|
id | string | 任务 ID(与 task_id 相同,task_ 前缀) |
object | string | 固定为 "video" |
model | string | 模型标识 |
status | string | 任务状态:queued → in_progress → completed / failed |
progress | number | 生成进度(0-100) |
created_at | integer | 创建时间戳 |
completed_at | integer | 完成时间戳(完成时出现) |
expires_at | integer | 资源过期时间戳 |
seconds | string | 时长(秒) |
size | string | 分辨率 |
remixed_from_video_id | string | Remix 任务中的源视频 ID |
error | object | 失败时的 {message, code} |
Remix
基于已有视频重新生成,可作为”视频生视频”使用:curl -X POST "https://api.shengmoai.com/v1/videos/video_69095b3b.../remix" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "把夜晚改为白天场景,添加蓝天白云"
}'
prompt 必填),响应同样是视频任务对象,成功后的查询结果里会带 remixed_from_video_id。
查询任务
GET/v1/videos/{task_id}
curl -X GET "https://api.shengmoai.com/v1/videos/video_69095b3b1000191be4e40" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
object: "video"),status 取值:
| 状态 | 说明 | 建议操作 |
|---|---|---|
queued | 已排队 | 继续轮询 |
in_progress | 生成中 | 继续轮询 |
completed | 已完成 | 获取视频 |
failed | 失败 | 查看 error.message |
completed 或 failed。
获取视频
视频内容通过GET /v1/videos/{task_id}/content 获取,返回视频文件本体(video/mp4),详见 视频内容获取。
相关接口
视频内容获取
GET /v1/videos/{task_id}/content 获取视频文件视频生成总览
异步流程与入口选择
