Skip to Content
API 参考视频生成创建视频任务

创建视频任务

提交一个视频生成任务。请求立即返回 202 Accepted,携带任务 id 与轮询地址——生成过程异步执行。轮询任务或接收 webhook,再用 查询任务状态 读取结果。

偶遇上游资源负载过高时,若 45 秒内未完成受理,任务将转为异步提交:请求照常返回 202 与任务 id(status 为 pending),后续结果可通过轮询或 webhook 获取。

POST https://api.ofox.io/v1/videos

请求参数

参数类型必填说明
modelstring✅模型 ID,如 bytedance/seedance-2.5、alibaba/wan-3.0、minimax/hailuo-3。各模型支持的取值见视频模型
promptstring✅视频文本描述
durationinteger—视频秒数
resolutionstring—480p / 720p / 1080p / 1K / 2K / 4K
aspect_ratiostring—16:9 / 9:16 / 1:1 / 4:3 / 3:4 / 3:2 / 2:3 / 21:9 / 9:21
sizestring—精确像素 WIDTHxHEIGHT(如 1280x720),替代 resolution + aspect_ratio
frame_imagesarray—帧控制(图生视频 / 首尾帧)。传入即视为 image-to-video,见下
input_referencesarray—引导 subject / 风格(参考图生视频),非精确帧锚点,见下
real_personboolean—默认 false。真人参考图设为 true,服务端会在生成前自动预处理;至少需要一张 input_references 图片,不支持 frame_images
generate_audioboolean—支持音频输出的模型默认 true
seedinteger—确定性生成种子(不保证所有 provider 支持)
callback_urlstring—终态 webhook 通知地址,必须 HTTPS(见 Webhook)
providerobject—type 指定承载供应商,options 透传 provider 特有参数。见 供应商路由

frame_images[] 元素

每个元素锚定输出的一帧,frame_type 取 first_frame 或 last_frame。

{ "type": "image_url", "image_url": { "url": "https://example.com/first.jpg" }, "frame_type": "first_frame" }

input_references[] 元素

按 type 传图片 / 音频 / 视频参考(引导 subject / 风格 / 一致性,非精确帧锚点):

{ "type": "image_url", "image_url": { "url": "https://example.com/subject.jpg" } } { "type": "audio_url", "audio_url": { "url": "https://example.com/voice.mp3" } } { "type": "video_url", "video_url": { "url": "https://example.com/ref.mp4" } }
媒体type数量上限其他约束
图片image_url≤ 9—
音频audio_url≤ 3单段 ≤ 15 秒
视频video_url≤ 1—

超出任一上限返回 400 too_many_references(见 错误码)。

frame_images 与 input_references 互斥——一个请求只能用其中一种,不能同时传。同时传返回 400 references_conflict。

real_person:真人参考图

使用流程与图片被拒后的调整建议见真人参考图。

当参考图包含可识别的真人形象时,将顶层 real_person 设为 true。Ofox 会在提交生成任务前,对 input_references 中的每张图片自动进行脱敏预处理。默认值为 false,现有请求行为不变。

{ "model": "bytedance/seedance-2.0", "prompt": "让画面中的人物走过电影感夜市", "real_person": true, "input_references": [ { "type": "image_url", "image_url": { "url": "https://example.com/person.jpg" } } ] }

real_person 只能与 input_references 中的图片配合使用,请求中至少需要一张图片。以下情况返回 400 invalid_request:

  • 同时传入 frame_images(首帧或首尾帧写法)。预处理图带有标注,作为首帧或尾帧会直接出现在成片中,请把图片改放进 input_references;
  • input_references 中没有图片。

预处理可以减少上游反深伪审核的误拒,但不会绕过内容政策,也不保证一定通过。上游仍可能拒绝任务;拒绝后不计费,可修正输入或重试。图片输入问题见real_person 图片预处理错误。

模式判定(隐式)

无 gen_mode 字段。模式由传入的输入字段隐式判定:

模式判定条件
text2video不传 frame_images 与 input_references
img2videoframe_images 含 1 个 first_frame
img2video_endframe_images 含 first_frame + last_frame
imgref2videoinput_references 仅图片
mixref2videoinput_references 内含图 / 音 / 视混合

响应

202 Accepted——任务受理,返回 status: "pending" 与 polling_url:

{ "id": "9bcf3c60-7db2-4e1a-a1b2-c3d4e5f60718", "status": "pending", "polling_url": "https://api.ofox.io/v1/videos/9bcf3c60-7db2-4e1a-a1b2-c3d4e5f60718" }

轮询 polling_url(或等待 webhook)直到任务进入终态——见 查询任务状态。

各模式的请求结构

以下片段展示各生成模式的字段结构,model 为占位符。请先在视频模型中确认目标模型支持该模式;各模型可直接运行的示例见模型用法下的系列页(Seedance、Wan 与 HappyHorse、Hailuo)。

不传 frame_images 与 input_references。

{ "model": "<模型 ID>", "prompt": "A golden retriever running on the beach at sunset", "duration": 5, "resolution": "720p", "aspect_ratio": "16:9" }

请求的发送方式与结果查询见 Video API · 快速开始。

可叠加选项

以下字段正交于生成模式——可叠加在上面任意一种请求体上。

任务进入终态时向你的地址发送一次 POST 推送,替代轮询。

{ "model": "<模型 ID>", "prompt": "...", "callback_url": "https://your-app.example/webhooks/ofox-video" }

callback_url 必须为公网 HTTPS 地址。推送体与签名见 Webhook。

最后更新于