自动化电商视频广告流水线:组合 Seedance 与 MiniMax API
当每一次模型调用都落在已文档化的时长、分辨率和图片输入窗口内时,商品图生视频流水线很适合放在 ToAPIs 上。本教程围绕一张已暂存的商品 URL,串联官方 seedance-2-5、MiniMax-H3 和 MiniMax-Hailuo-2.3 ID。它不会发明每条广告 1.20 美元的单价、15 秒的 Hailuo 成片、Shopify 抓取 API,或视频请求上的 ElevenLabs 字段。
规划稿还较宽松地使用了 seedance-2、minimax-h3 和 gpt-image-2。今天应调用的官方名称是 seedance-2-5(若你需要 4–15 秒的 Seedance 2 家族,也可以用 seedance-2)、MiniMax-H3,以及可选图生图清理用的 gpt-image-2。URL 与 Base64 的合同见视频 API 中的精确首帧控制,完成信号见消除视频生成超时。
1. TL;DR 与性能概览
- 一次暂存 URL,多个官方 ID。 用
POST /v1/uploads/images上传商品静帧(或传入公开 HTTP(S) URL)。然后在 Seedance 与 MiniMax-H3 上用image_with_roles提交首帧任务,在 Hailuo 2.3 上使用image_urls。 - 遵守各模型的时长窗口。 15 秒竖屏广告对
seedance-2-5(4–30 秒)和MiniMax-H3(4–15 秒)是合法范围。MiniMax-Hailuo-2.3只有 6 或 10 秒(1080P→ 6 秒)。拼接更短片段是客户端步骤。 - 组合家族是为了已文档化的差异,而不是未发布的创意排名:长度、分辨率、
generate_audio、Hailuo 镜头指令,以及页面要求的图片字段。 - 价格取自 2026-12-01 目录,以 credits 为主,美元只按 1 credit ≈ $0.005 估算。做预算前请先核对账户目录。
2. 官方 ID,以及为什么一条流水线里会出现两个家族
| 官方 ID | 本流水线使用的模式 | 时长 | 分辨率 | 图片字段 | 其他已文档化特征 |
|---|---|---|---|---|---|
seedance-2-5 | 首帧图生视频 | 4–30 秒,或 -1 | 480p、720p、1080p、4k | image_with_roles 的 first_frame;使用 aspect_ratio: "adaptive" | generate_audio 默认 true;仅公开 HTTP(S) URL |
seedance-2-5-flash | 更快的首帧预览 | 4–30 秒,或 -1 | 仅 480p 或 720p | 同样的角色;最多 10 张图 | 较低成本的预览分支;不支持 1080p / 4k |
MiniMax-H3 | 首帧图生视频 | 4–15 秒 | 2K 或 768p | image_with_roles 的 first_frame | 首尾帧模式会忽略具体宽高比并使用 adaptive |
MiniMax-Hailuo-2.3 | 首帧图生视频 | 6 或 10 秒;1080P 只允许 6 秒 | 768P 或 1080P | image_urls(一张起始帧) | 15 种镜头指令,例如 [Push in];提示词最多 2000 字符 |
MiniMax-Hailuo-2.3-Fast | 仅首帧图生视频 | 同样的 6 / 10 秒窗口 | 768P 或 1080P | 必须提供 image_urls | 不支持文生视频;适合作为更便宜的变体分支 |
MiniMax-H3-Max-Turbo 正被模型提供方弃用,且不支持参考媒体;官方文档建议需要更轻量 H3 家族 ID 的新集成使用 MiniMax-H3-Lite。本流水线在需要 2K 首帧路径时直接使用 MiniMax-H3。
可选清理使用 POST /v1/images/generations 上的 gpt-image-2,字段为 reference_images(或兼容的 image_urls)。这是已文档化的图生图,不是 ToAPIs 的 inpainting API。这些字段同样不接受 Base64。
第三方步骤——从 Shopify 拉取商品图、用 ElevenLabs 加旁白,或烧录字幕——都保持在带外。它们不是 ToAPIs 请求字段。
3. 生产实现:暂存、分支、有界等待

图 1. 已文档化的流水线:暂存商品 URL,可选清理,分支到官方 Seedance 与 MiniMax ID,只有在需要更长成片时才在客户端拼接。
下面的程序上传一张商品图,可选择运行 gpt-image-2,然后启动三个已文档化的视频任务:15 秒的 seedance-2-5 1080p 9:16 片段、8 秒的 MiniMax-H3 2K 首帧片段,以及带镜头指令的 6 秒 MiniMax-Hailuo-2.3 1080P 片段。每个任务都按官方 5 / 10 / 600 的边界轮询。
import os
import random
import time
import requests
API_KEY = os.environ["TOAPIS_API_KEY"]
BASE_URL = os.environ.get("TOAPIS_BASE_URL", "https://toapis.com") # 或 https://toapis.cn
def upload_image(path: str) -> str:
with open(path, "rb") as fh:
resp = requests.post(
f"{BASE_URL}/v1/uploads/images",
headers={"Authorization": f"Bearer {API_KEY}"},
files={"file": fh},
timeout=60,
)
resp.raise_for_status()
body = resp.json()
if not body.get("success"):
raise RuntimeError(body)
return body["data"]["url"]
def optional_cleanup(image_url: str, prompt: str) -> str:
"""已文档化的 gpt-image-2 图生图。不是 inpainting 蒙版 API。"""
resp = requests.post(
f"{BASE_URL}/v1/images/generations",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json={
"model": "gpt-image-2",
"prompt": prompt,
"size": "9:16",
"resolution": "2k",
"reference_images": [image_url],
},
timeout=30,
)
resp.raise_for_status()
task_id = resp.json().get("id") or resp.json().get("task_id")
return poll_task(f"{BASE_URL}/v1/images/generations/{task_id}")["url"]
def submit_video(payload: dict) -> str:
resp = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json=payload,
timeout=30,
)
resp.raise_for_status()
body = resp.json()
task_id = body.get("id") or body.get("task_id")
if not task_id:
raise RuntimeError(body)
return task_id
def poll_task(url: str, max_wait: int = 600) -> dict:
start = time.time()
interval = 10
time.sleep(5)
while time.time() - start < max_wait:
resp = requests.get(url, headers={"Authorization": f"Bearer {API_KEY}"}, timeout=30)
if resp.status_code == 429:
retry_after = int(resp.headers.get("Retry-After", interval))
time.sleep(retry_after + random.uniform(0, 1))
interval = min(interval * 2, 120)
continue
resp.raise_for_status()
data = resp.json()
status = data.get("status")
if status == "completed":
item = (data.get("result") or {}).get("data") or []
if not item or not item[0].get("url"):
raise RuntimeError(data)
return {"url": item[0]["url"], "expires_at": data.get("expires_at")}
if status == "failed":
err = data.get("error") or {}
raise RuntimeError(err.get("message") or data)
time.sleep(interval + random.uniform(0, 1))
raise TimeoutError(f"still running after {max_wait}s: {url}")
def poll_video(task_id: str) -> dict:
return poll_task(f"{BASE_URL}/v1/videos/generations/{task_id}")
if __name__ == "__main__":
product_url = upload_image("product-hero.jpg")
# 可选:注释掉下面两行即可直接使用原始静帧。
# product_url = optional_cleanup(
# product_url,
# "Keep the product identical. Replace the cluttered background with a clean studio sweep.",
# )
jobs = {
"seedance_15s": submit_video(
{
"model": "seedance-2-5",
"prompt": "The product stands on a clean studio sweep. Slow pedestal up, soft daylight, no new logos.",
"duration": 15,
"resolution": "1080p",
"aspect_ratio": "adaptive",
"generate_audio": True,
"image_with_roles": [{"url": product_url, "role": "first_frame"}],
}
),
"h3_8s": submit_video(
{
"model": "MiniMax-H3",
"prompt": "The same product holds the frame as the camera slowly orbits, consistent identity, studio lighting.",
"duration": 8,
"resolution": "2K",
"image_with_roles": [{"url": product_url, "role": "first_frame"}],
}
),
"hailuo_6s": submit_video(
{
"model": "MiniMax-Hailuo-2.3",
"prompt": "The product turns toward the camera [Push in], then holds [Static shot]",
"image_urls": [product_url],
"duration": 6,
"resolution": "1080P",
}
),
}
for name, task_id in jobs.items():
result = poll_video(task_id)
print(name, result["url"], "expires_at=", result["expires_at"])
15 秒 Seedance 分支的精简 cURL 提交:
curl --request POST \
--url https://toapis.com/v1/videos/generations \
--header "Authorization: Bearer $TOAPIS_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"model": "seedance-2-5",
"prompt": "The product stands on a clean studio sweep. Slow pedestal up, soft daylight, no new logos.",
"duration": 15,
"resolution": "1080p",
"aspect_ratio": "adaptive",
"generate_audio": true,
"image_with_roles": [{"url": "https://files.toapis.com/uploads/example.jpg", "role": "first_frame"}]
}'
如果需要比某模型官方窗口更长的成片,请用 FFmpeg 等本地工具拼接已下载的 MP4。该步骤不是 ToAPIs 参数,也不会改变各生成请求被允许返回的内容。
若要用推送完成代替紧密轮询循环,请先配置 Task Webhooks,并把轮询器留作兜底,详见 Webhook 教程。
4. 错误处理与状态矩阵
| 情况 | 官方行为 | 流水线应对 |
|---|---|---|
| 在生成请求体中发送 Base64 或本地路径 | Seedance、MiniMax、Wan 和 GPT Image 2 页面均拒绝 | 先上传;复用 data.url |
同时发送 image_urls 与 image_with_roles | 在 Seedance 与 MiniMax-H3 上会不明确 | 只发送文档推荐的字段 |
Hailuo 使用 duration: 15 或 1080P + duration: 10 | 超出已文档化的 6 / 10 秒窗口(1080P 仅限 6 秒) | 改用 6 或 10,或把 15 秒任务交给 seedance-2-5 / MiniMax-H3 |
| Hailuo Fast 没有图片 | Fast 仅支持图生视频 | 始终传入 image_urls |
MiniMax-H3 使用 resolution: "4k" | H3 页面不支持(仅 2K / 768p) | 改用 2K,或把 4k 分支切到 seedance-2-5 |
轮询 queued / in_progress | 非终态 | 继续官方 10 秒循环 |
轮询 completed | result.data[0].url | 在 expires_at 之前下载(官方保留 30 天) |
轮询 failed | error.message | 只让该分支失败;不要假定其他 ID 也失败 |
400 webhook_not_configured | 未配置 Token 却发送了 callback_url | 先配置 Token,或省略该字段 |
5. 定价与 FinOps ROI
快照日期:2026-12-01。来源:公开 定价页(1 credit ≈ $0.005)。未认证的 GET /api/v1/pricing 返回 401。这些数字是规划算术,不是报价,更不是规划稿里“人工 UGC 每条 150 美元降到 AI 广告每条 1.20 美元”的单位经济。
| 步骤 | 官方 ID | 目录单价(2026-12-01) | 测算示例(仅估算) |
|---|---|---|---|
| 可选清理 | gpt-image-2 | $0.015 / 次(约 3 credits) | 一张静帧 ≈ $0.015 |
| 15 秒竖屏广告 | seedance-2-5 | $2.90 / 100 万 usage.total_tokens;按秒数字只是预算估算 | 按已完成任务结算后的 usage.total_tokens 计费,而不是规划稿 $0.030–$0.038 / 秒的基线 |
| 8 秒 2K 首帧 | MiniMax-H3 | $0.064 / 秒(约 12.8 credits / 秒) | 8 × $0.064 ≈ $0.512(约 102 credits) |
| 6 秒 1080P 首帧 | MiniMax-Hailuo-2.3 | $0.194 / 次(约 38.8 credits) | 一条 ≈ $0.194 |
| 更便宜的图生视频变体 | MiniMax-Hailuo-2.3-Fast | $0.136 / 次(约 27.2 credits) | 一条 ≈ $0.136 |
因此,一组「一条 15 秒 Seedance + 一条 8 秒 H3 + 一条 6 秒 Hailuo」的 已知 MiniMax 小计约为 $0.706(约 141 credits),再加上 seedance-2-5 按 token 结算的部分,若运行清理再加 $0.015。十个变体意味着十组这样的组合(或其中一部分分支),官方页面并未写隐藏的批量折扣。在按 SKU 放大之前,请先在 Billing Center 核对实时价格。
6. 常见问题
前言中的 FAQ 已覆盖 15 秒窗口、为何出现两个家族、变体计价、GPT Image 2 清理以及异步等待。再补充两条流水线说明:
- 音频。
seedance-2-5文档化了generate_audio(默认 true)。Hailuo 与 MiniMax-H3 生成页面没有列出同一个布尔字段;Hailuo 改为在提示词中提供镜头指令。添加第三方旁白属于带外步骤。 - Wan 作为额外分支。
wan2.6官方接受 5、10 或 15 秒,分辨率为 720p / 1080p,使用image_urls;wan3.0-video接受 2–30 秒,使用image_with_roles。如果你已经在用 Wan,它们也是合法的首帧 ID;本文聚焦排期中的 Seedance + MiniMax 组合。参见 Wan 2.6 图生视频流水线 与 阿里云 Wan 3 视频 API 快速入门。
7. 行动清单
- 用
POST /v1/uploads/images或公开 HTTP(S) URL 暂存商品静帧。不要在生成请求中发送 Base64。 - 按所需成片选择官方 ID:最长 30 秒且需要 1080p/4k 时用
seedance-2-5,最长 15 秒且需要 2K 时用MiniMax-H3,6 或 10 秒时用MiniMax-Hailuo-2.3。 - 在 Seedance 和 H3 上使用
image_with_roles/first_frame,在 Hailuo 上使用image_urls。Seedance 首帧任务把aspect_ratio设为adaptive。 - 把 Shopify 导入、ElevenLabs 旁白、字幕以及 FFmpeg 拼接视为客户端或第三方步骤。
- 异步提交各分支;用 Task Webhooks 加上官方 5 / 10 / 600 轮询器等待。
- 按注明日期的目录以 credits 做预算,并在按 SKU 放大之前核对账户价目。
2026-12-01 抓取的官方来源:Seedance 2.5 生成、MiniMax H3 生成、Hailuo 2.3 生成、GPT Image 2 生成、Upload Image、Get Video Task Status,以及 toapis.com/pricing。