跳转到主要内容
POST
/
v1
/
videos
视频生成(Sora)
curl --request POST \
  --url https://openp.ai/v1/videos
import requests

url = "https://openp.ai/v1/videos"

response = requests.post(url)

print(response.text)
const options = {method: 'POST'};

fetch('https://openp.ai/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://openp.ai/v1/videos",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://openp.ai/v1/videos"

req, _ := http.NewRequest("POST", url, nil)

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://openp.ai/v1/videos")
.asString();
require 'uri'
require 'net/http'

url = URI("https://openp.ai/v1/videos")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)

response = http.request(request)
puts response.read_body
通过 Sora 生成视频。采用 异步任务 流程:提交后获取任务 ID,轮询完成后下载视频。

提交任务

curl https://openp.ai/v1/videos \
  -H "Authorization: Bearer $OPENPAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sora-2",
    "prompt": "A red panda surfing on a giant wave at sunset, cinematic, 4K",
    "seconds": 8,
    "size": "1280x720"
  }'

参数

字段类型必填说明
modelstringsora-2 / sora-2-pro
promptstring视频描述
secondsinteger时长(秒),典型 5-20
sizestring分辨率,如 1280x720 / 1920x1080
aspect_ratiostring16:9 / 9:16 / 1:1
ninteger生成数量(部分支持)
input_referenceobject输入参考图或视频

响应(任务创建)

{
  "id": "video_01...",
  "object": "video.task",
  "status": "queued",
  "created_at": 1715750400,
  "model": "sora-2"
}

查询任务状态

curl https://openp.ai/v1/videos/video_01... \
  -H "Authorization: Bearer $OPENPAI_API_KEY"
{
  "id": "video_01...",
  "status": "completed",
  "video_url": "https://...mp4",
  "thumbnail_url": "https://...jpg",
  "duration": 8,
  "created_at": 1715750400,
  "completed_at": 1715750460
}
status 可能值:queued / processing / completed / failed

轮询建议

  • 初始延迟 5-10 秒后开始轮询。
  • 间隔 10-30 秒一次。
  • 通常 1-5 分钟完成。
  • 失败时 failure_reason 字段说明原因。

计费

生成秒数 + 分辨率 一笔固定扣费。 系统侧失败的任务不扣费;被上游拒绝的任务按已消耗算力扣费。