视频
视频生成
使用 Seedance, Kling, Omni, Wan, Grok, Veo, Vidu, PixVerse 和 MiniMax,根据提示词、首帧(也可同时提供尾帧)或参考图片, 视频和音频生成视频。生成需要几分钟,先提交任务,再查询结果。
/v1/videos提交、轮询、下载
import os, time, requestsAPI = "https://api.zurelay.com/v1"HEADERS = {"Authorization": f"Bearer {os.environ['ZURELAY_API_KEY']}"}# 1. Start the videoresponse = requests.post(f"{API}/videos", headers=HEADERS, json={ "model": "seedance-2.0", "prompt": "A paper boat drifting down a rain-soaked street at night, neon reflections, slow dolly shot", "seconds": 5, "resolution": "720p", "aspect_ratio": "16:9",})response.raise_for_status() # a 4xx says what to fixjob = response.json()# 2. Poll until it's done (usually 2 to 6 minutes)while job["status"] in ("queued", "in_progress"): time.sleep(10) job = requests.get(f"{API}/videos/{job['id']}", headers=HEADERS).json()if job["status"] == "failed": raise SystemExit(job["error"]["message"])# 3. Download the MP4video = requests.get(f"{API}/videos/{job['id']}/content", headers=HEADERS)open("boat.mp4", "wb").write(video.content)所有视频模型的调用方式都一样:只需更改 model,请求的其余部分无需修改。各模型指南介绍了它们各自的优势:Seedance、Kling、Wan、Grok Imagine、Omni Flash、MiniMax H3、Veo、Vidu 和 PixVerse。
callback_url,视频生成完成后就会立即通过 POST 发送到你的服务器,并附带签名。参见回调。参数
modelstring必填- 视频模型 ID。
promptstring- 描述视频内容,最多 8,000 个字符 (Kling 最多读取 2,500, Vidu reads up to 2,000, PixVerse reads up to 2,048, MiniMax reads up to 7,000)。未提供首帧或参考图片时必填。
negative_promptstring- 描述视频中不要出现的内容,最多 2,500 个字符。Kling and PixVerse 支持此参数,其他模型会拒绝此参数。
secondsinteger- 时长,单位为整秒,须在模型支持的范围内(见表格)。默认为 5,或模型支持的最接近时长。
resolutionstring- 例如
480p、720p、1080p、2k或4k:各模型支持的值见表格。默认为 720p,或模型支持的最低分辨率。 aspect_ratiostring16:9、9:16、1:1、4:3、3:4、21:9或adaptive(沿用首帧的宽高比;提供首帧时默认使用此值)。否则默认为16:9. Kling makes 16:9, 9:16, 1:1 和 21:9; Omni and Veo make 16:9 and 9:16; Kling makes 16:9, 9:16 and 1:1; Grok, Vidu and PixVerse make 16:9, 9:16, 1:1, 4:3 and 3:4.sizestring- 用像素尺寸代替分辨率和宽高比,例如
1280x720。 generate_audioboolean- 随视频一起生成声音和语音。默认为
true。(也支持audio。) Kling and PixVerse cost 在不生成声音时费用更低。 seedinteger- 相同的 seed 和设置会生成相似的结果. Kling, Grok and Veo have no seed and ignore it.
first_framestring- 视频的首帧图片:链接或 data URL. MiniMax takes none: give the image in reference_images.
last_framestring- 视频的尾帧图片。须同时提供首帧. Seedance, Kling, Omni, Wan, Vidu and PixVerse take one.
reference_imagesarray- 用于参考角色、产品、场景或风格的图片:Seedance up to 9, Kling up to 10, Omni up to 10, Wan up to 10, Grok up to 3, MiniMax up to 9; Veo, Vidu and PixVerse take none。不能与首尾帧同时使用。
reference_videosarray- 用于参考画面风格、动作或运镜的视频,或要编辑、续接的视频:支持 MP4 或 MOV,以链接或 data URL 提供,并在提示词中用
@Video1、@Video2等引用。仅 Seedance 2.5, Seedance 2.0, Gemini Omni Flash 和 MiniMax H3 支持。参考视频每秒按标准每秒价格的一定比例计费,部分模型不收费;参见参考视频和音频。 reference_audioarray- 要使用的人声、音乐或音效: MP3 或 WAV 格式,以链接或 data URL 提供,用
@Audio1等标记引用。仅限 Seedance 2.5, Seedance 2.0 和 MiniMax H3, 不额外收费。 reference_modestring- 使用参考视频时:对某个视频执行
edit或extend, 或根据参考素材生成新视频 (reference)。默认值为auto: 模型根据提示词决定。仅限 Seedance 2.5。 callback_urlstring- 用于接收视频生成完成或失败通知的 https URL, 无需轮询。参见 回调。
从图像开始
首帧和尾帧
让静态图像动起来:视频以 first_frame 作为首帧。添加 last_frame 后,视频会以该图像作为尾帧,让你控制镜头的起点和终点. MiniMax starts 则根据参考图像生成。
{ "model": "seedance-2.0", "first_frame": "https://example.com/storefront-day.jpg", "last_frame": "https://example.com/storefront-night.jpg", "prompt": "Time passes from afternoon to night; lights come on inside the shop.", "seconds": 6, "resolution": "720p"}参考图
最多提供 10 张图像 (Seedance up to 9, Kling up to 10, Omni up to 10, Wan up to 10, Grok up to 3, MiniMax up to 9; Veo, Vidu 和 PixVerse take none),并在提示词中按顺序引用 (@Image1, @Image2…): 图中的人物、产品和场景会出现在视频中。
{ "model": "seedance-2.5", "reference_images": [ "https://example.com/chef.jpg", "https://example.com/kitchen.jpg", "https://example.com/dish.jpg" ], "prompt": "The chef from @Image1 plates the dish from @Image3 in the kitchen from @Image2, close-up, warm light.", "seconds": 8, "resolution": "720p", "aspect_ratio": "9:16"}参考视频和音频
提供视频以参考人物外观和动作、运镜或场景,提供音频以参考人声、旋律或音效。与图像一样,在提示词中按顺序引用: @Video1, @Audio1。可与参考图像混用,但不能与首帧图像同时使用。
{ "model": "seedance-2.5", "reference_images": ["https://example.com/singer.jpg"], "reference_videos": ["https://example.com/dance-moves.mp4"], "reference_audio": ["https://example.com/chorus.mp3"], "prompt": "The singer from @Image1 performs the dance from @Video1 on a rooftop at dusk, singing to @Audio1.", "seconds": 8, "resolution": "720p"}模型会读取参考视频的每一秒,因此参考时长也会计费,单价为生成视频每秒价格的一部分:生成 5 s 视频并使用 10 s 参考视频时,费用包含 5 秒生成时长和 10 秒参考时长。参考音频不额外收费。每个视频对象都会显示计费的参考时长 (reference_seconds)。
编辑和延长视频
将 reference_mode 设为 edit 可修改参考视频 (替换人物或物体、添加或移除内容、更换音乐),设为 extend 可向后续写或向前扩展视频。在提示词中说明操作: “将 @Video1 中的汽车替换为 @Image1 中的汽车”, “续写 @Video1, 让舞者离开舞台”。
- 编辑会保留视频的画幅和时长,因此不要传入
aspect_ratio和seconds。按最长参考视频的时长计费,该视频时长须为 4 至 30 秒。 - 延长视频会保留原视频的画幅;
seconds用于设置新视频的时长。 - 未设置
reference_mode时,模型会根据提示词决定操作;如果提示词被识别为编辑操作,但设置了seconds或aspect_ratio, 则可能生成失败 (失败视频不收费)。
图像要求
- PNG、JPEG 或 WebP 格式,以公开可访问的
https链接或 data URL 提供,最大 10 MB。 - 每边 300 至 6000 像素,长宽比和宽长比均不得超过 5:2. 不符合要求的 data URL 会被立即拒绝,并返回原因说明。链接会在视频生成开始时读取:如果链接内容不是可用图像,视频会生成失败并返回
invalid_image, 不收取费用。 - 同一请求中只能使用首尾帧或参考素材,不能同时使用。
- 请求采用 JSON 格式:图像以链接或 data URL 传入,不支持 multipart 上传。
视频对象
{ "id": "video_abc123", "object": "video", "model": "seedance-2.0", "status": "completed", "progress": 100, "created_at": 1790870400, "completed_at": 1790870562, "expires_at": 1793462400, "seconds": 5, "resolution": "720p", "aspect_ratio": "16:9", "size": "1280x720", "generate_audio": true, "url": "https://...signed link...", "url_expires_at": 1790956962, "cost": 1.035, "error": null}其他端点
视频计费
视频费用为每秒单价(按分辨率区分)乘以时长; 无声视频每秒便宜 Kling 和 PixVerse cost; 参考视频按其时长计费,单价为上述单价的一部分。开始生成时,会从余额中冻结相应金额;生成完成后扣费,失败则解冻。生成失败不收费。
有疑问,或发现内容缺失?联系我们的支持团队,我们会通过邮件回复,通常只需一分钟。