跳转到主要内容
POST
/
v1
/
video
curl --request POST \
  --url https://wisdom-gate.juheapi.com/v1/video \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form 'prompt=A cat walking on the street' \
  --form model=sora-2 \
  --form seconds=4 \
  --form size=720x1280 \
  --form input_reference='@example-file'
{
"id": "video_68e688d4950481918ec389280c2f78140fcb904657674466",
"object": "video",
"created_at": 1759938772,
"status": "queued",
"completed_at": null,
"error": null,
"expires_at": null,
"model": "sora-2",
"progress": 0,
"remixed_from_video_id": null,
"seconds": "4",
"size": "720x1280"
}

概述

videos 是 OpenAI Sora 的视频生成接口,通过文本提示或可选的参考图像输入创建视频生成任务。 创建后,您需要使用 查询接口 获取生成状态。任务完成后,可以进行后续操作如 混剪下载 有关 Sora 生成接口的更多信息,请参阅 OpenAI 官方文档

支持的模型

目前支持的模型 ID:
  • sora-2(默认)
  • sora-2-pro

重要说明

异步处理视频生成需要较长时间,采用异步模式。创建任务后立即返回任务 ID,您需要使用查询接口获取生成进度和结果。
内容政策生成的视频内容必须符合 OpenAI 的使用政策。禁止生成违法、暴力、色情或侵犯版权的内容。
资源管理请及时下载生成的视频以避免资源过期。查看响应中的 expires_at 字段了解视频过期时间。

参考文档

有关 Sora 视频生成的更多详情,我们建议参阅 OpenAI 官方文档
自动生成的文档请求参数和响应格式从 OpenAPI 规范自动生成。所有参数、其类型、描述、默认值和示例都直接从 openapi.json 提取。向下滚动查看交互式 API 参考。

快速开始

基础示例:文本生成视频

curl -X POST "https://wisdom-gate.juheapi.com/v1/video" \
  -H "Authorization: Bearer $WISDOM_GATE_KEY" \
  -F "prompt=一只猫在街上走" \
  -F "model=sora-2" \
  -F "seconds=4" \
  -F "size=720x1280"

带图像参考的示例

curl -X POST "https://wisdom-gate.juheapi.com/v1/video" \
  -H "Authorization: Bearer $WISDOM_GATE_KEY" \
  -F "prompt=宁静的风景动画" \
  -F "model=sora-2" \
  -F "seconds=8" \
  -F "size=1280x720" \
  -F "input_reference=@reference_image.jpg"

最佳实践

1. 提示词优化

使用具体、详细的描述,包含场景、动作、光线等细节: 好的提示词:
一辆红色跑车在日落时分穿过蜿蜒的山路行驶的电影镜头,戏剧性的光线和朦胧的氛围,用专业相机拍摄,4K 画质
差的提示词:
汽车行驶

2. 时长控制

根据内容复杂度选择合适的时长;较短的时长通常质量更好:
  • 4 秒:最适合简单场景,生成最快
  • 8 秒:适合中等复杂度场景
  • 12 秒:适合复杂场景,生成时间较长

3. 分辨率选择

根据使用场景选择合适的分辨率,平衡质量和生成时间:
  • 720x1280(默认):竖屏格式,适合手机/社交媒体
  • 1280x720:横屏格式,标准宽屏
  • 1024x1792:高分辨率竖屏
  • 1792x1024:高分辨率横屏

4. 图像预处理

使用图像引导时,确保输入图像:
  • 清晰且构图良好
  • 文件大小合理(不要太大)
  • 格式支持(JPEG、PNG)

5. 错误处理

实现完善的重试和错误处理机制:
import requests
import time
import random

def create_video_with_retry(prompt, max_retries=3):
    url = "https://wisdom-gate.juheapi.com/v1/video"
    headers = {"Authorization": f"Bearer WISDOM_GATE_KEY"}
    data = {"prompt": prompt, "model": "sora-2"}
    
    for attempt in range(max_retries):
        try:
            response = requests.post(url, headers=headers, data=data)
            response.raise_for_status()
            return response.json()
        except requests.exceptions.RequestException as e:
            if attempt < max_retries - 1:
                wait_time = (2 ** attempt) + random.random()
                time.sleep(wait_time)
            else:
                raise

故事板模式

API 支持故事板功能,用于创建连续的多镜头视频。使用故事板模式时,提示词必须严格遵循以下格式:
Shot 1:
duration: 7.5sec
Scene: 飞机起飞。

Shot 2:
duration: 7.5sec
Scene: 飞机降落。

格式要求

  • 每个镜头以 Shot N: 开始(N 是镜头编号)
  • 使用 duration: Xsec 指定镜头时长
  • 使用 Scene: 描述镜头内容
  • 用空行分隔镜头

故事板示例

curl -X POST "https://wisdom-gate.juheapi.com/v1/video" \
  -H "Authorization: Bearer $WISDOM_GATE_KEY" \
  -F "prompt=Shot 1:
duration: 7.5sec
Scene: 飞机起飞。

Shot 2:
duration: 7.5sec
Scene: 飞机降落。" \
  -F "model=sora-2" \
  -F "size=1280x720"

常见问题

视频生成需要多长时间?

通常需要几分钟到十几分钟,取决于视频时长、分辨率和服务器负载。如果长时间无响应或失败,请联系客服。

支持哪些分辨率?

默认支持 720x1280。支持的分辨率:
  • 720x1280(默认)- 竖屏
  • 1280x720 - 横屏
  • 1024x1792 - 高分辨率竖屏
  • 1792x1024 - 高分辨率横屏
具体支持的分辨率请参阅模型文档。

生成的视频可以多长?

默认为 4 秒。最大时长取决于模型限制:
  • sora-2:支持 4、8 和 12 秒
  • sora-2-pro:支持 4、8 和 12 秒
请参阅官方文档了解最新的时长限制。

如何提高生成质量?

  1. 使用详细的提示词:包含场景、动作、光线、镜头角度和风格
  2. 选择合适的时长:较短的时长(4-8 秒)通常质量更好
  3. 提供高质量的参考图像:清晰、构图良好的图像可以引导更好的结果
  4. 使用故事板模式:对于复杂的多镜头视频,使用故事板格式

如何检查视频生成状态?

创建视频后,使用返回的 id 查询状态:
video_id = result['id']
status_url = f"https://wisdom-gate.juheapi.com/v1/video/{video_id}"
response = requests.get(status_url, headers=headers)
status = response.json()
print(f"状态: {status['status']}, 进度: {status['progress']}%")

如何下载生成的视频?

状态为 completed 后,使用内容端点:
content_url = f"https://wisdom-gate.juheapi.com/v1/video/{video_id}/content"
response = requests.get(content_url, headers=headers)
with open("generated_video.mp4", "wb") as f:
    f.write(response.content)

授权

Authorization
string
header
必填

Bearer token authentication. Include your API key in the Authorization header as 'Bearer YOUR_API_KEY'

请求体

multipart/form-data

Request body for video generation using OpenAI Sora models. Uses multipart/form-data format.

prompt
string
必填

Text prompt that describes the video to generate. For Storyboard mode, use the specific format with Shot N:, duration: Xsec, and Scene: descriptions.

示例:

"A cat walking on the street"

model
enum<string>
默认值:sora-2

The video generation model to use. Defaults to sora-2.

可用选项:
sora-2,
sora-2-pro
示例:

"sora-2"

seconds
enum<string>
默认值:15

Clip duration in seconds. Defaults to 15 seconds.

可用选项:
4,
8,
12
示例:

"15"

size
enum<string>
默认值:720x1280

Output resolution formatted as width x height. Defaults to 720x1280.

可用选项:
720x1280,
1280x720,
1024x1792,
1792x1024
示例:

"720x1280"

input_reference
file

Optional image reference that guides generation. Upload as a file in multipart/form-data format.

响应

Video generation request accepted

Response from video generation request. Returns immediately with task ID for asynchronous processing.

id
string
必填

Unique identifier for the video generation request. Use this ID to query status and retrieve the video.

示例:

"video_68e688d4950481918ec389280c2f78140fcb904657674466"

object
string
必填

Object type, always 'video'

示例:

"video"

created_at
integer
必填

Unix timestamp (in seconds) when the request was created

示例:

1759938772

status
enum<string>
必填

Current status of the video generation. Use the query interface to check status updates.

可用选项:
queued,
processing,
completed,
failed
示例:

"queued"

completed_at
integer
必填

Unix timestamp (in seconds) when the video generation completed. Null if not yet completed.

示例:

null

error
object
必填

Error information if generation failed. Null if no error.

示例:

null

expires_at
integer
必填

Unix timestamp (in seconds) when the video will expire. Download promptly to avoid expiration.

示例:

null

model
string
必填

Model used for generation

示例:

"sora-2"

progress
integer
必填

Generation progress percentage (0-100)

必填范围: 0 <= x <= 100
示例:

0

remixed_from_video_id
string
必填

ID of the video this was remixed from, if applicable

示例:

null

seconds
string
必填

Video duration in seconds

示例:

"4"

size
string
必填

Video resolution (width x height)

示例:

"720x1280"