自動化電商影片廣告流水線:組合 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。