新接入建議使用 影片生成 與統一
/ai/v1/videos 協定。本頁 /v1/videos 相容介面及模型適配仍可使用。呼叫前請查詢 模型 Schema 介面,依回傳的 path 選擇協定並讀取該項的 request.schema,不要依賴陣列位置。目前模型清單
| 供應商 | 模型 ID |
|---|---|
| OpenAI | sora-2, sora-2-pro |
veo-3.1-lite-generate-preview, veo-3.0-generate-preview, veo-3.1-fast-generate-preview, veo-3.1-generate-preview, veo-2.0-generate-001 | |
| Qwen / Wan 3.0 | wan3.0-video, wan3.0-video-prime |
| Qwen / Happyhorse 1.1 | happyhorse-1.1-i2v, happyhorse-1.1-r2v, happyhorse-1.1-t2v |
| Qwen / Happyhorse 1.0 | happyhorse-1.0-i2v, happyhorse-1.0-r2v, happyhorse-1.0-t2v, happyhorse-1.0-video-edit |
| Qwen / Wan 2.7 | wan2.7-i2v, wan2.7-r2v, wan2.7-t2v, wan2.7-videoedit |
| Qwen / Wan 2.6 | wan2.6-i2v, wan2.6-t2v, wan2.2-i2v-plus, wan2.5-i2v-preview, wan2.5-t2v-preview |
| ByteDance | doubao-seedance-2-5-260628, doubao-seedance-2-0-260128, doubao-seedance-2-0-fast-260128, doubao-seedance-2-0-mini-260615, doubao-seedance-1-5-pro-251215, doubao-seedance-1-0-pro-250528, doubao-seedance-1-0-pro-fast-251015 |
| MiniMax | minimax-h3 |
| Kling | kling-v3-omni, kling-video-o1 |
本清單表示模型目前已上線,不代表所有模型共用相同輸入欄位。請依模型 Schema 回傳的
path 選擇端點,再讀取該項的 request.schema。API 詳細說明
請求標頭
Authorization: Bearer $AIHUBMIX_API_KEY
Content-Type: application/json
建立影片生成任務
POST /v1/videos
請求主體
| 參數 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 模型名稱,如 wan2.6-t2v、sora-2 |
prompt | string | 是 | 影片描述文字 |
seconds | string | 否 | 影片時長(秒),統一使用字串類型,如 "5"、"8"(見各模型詳解) |
size | string | 否 | 解析度,格式 寬x高,如 1920x1080(各模型支援值不同) |
input_reference | string/object | 否 | 參考圖片(圖生影片),支援 URL 或 base64 |
不同模型的回應格式略有差異,但都包含id(video_id)和status欄位。以status判斷任務進度即可。
回應範例(通義萬相/Veo/即夢AI)
{
"id": "eyJtb2RlbCI6IndhbjI...",
"object": "video",
"created": 1772460274,
"model": "wan2.6-t2v",
"status": "in_progress",
"prompt": "A cat watching the rain on a windowsill",
"duration": 5,
"width": 1920,
"height": 1080,
"url": null,
"error": null
}
{
"id": "eyJtb2RlbCI6InNvcmEtMi...",
"object": "video",
"created_at": 1772451930,
"status": "queued",
"model": "sora-2",
"progress": 0,
"prompt": "A cinematic drone shot over mountains",
"seconds": "8",
"size": "1280x720"
}
通用狀態值說明
| 狀態 | 說明 |
|---|---|
queued | 排隊中(Sora 特有) |
in_progress | 生成中 |
completed | 生成完成,可以下載 |
failed | 生成失敗 |
查詢影片狀態
GET /v1/videos/{video_id}
回應範例(生成完成 - 通義萬相)
{
"id": "eyJtb2RlbCI6IndhbjI...",
"object": "video",
"status": "completed",
"model": "wan2.5-t2v-preview",
"duration": 5,
"width": 1920,
"height": 1080,
"url": "https://aihubmix.com/v1/videos/eyJtb2RlbCI6IndhbjI.../content",
"error": null
}
回應範例(生成完成 - Sora)
{
"id": "eyJtb2RlbCI6InNvcmEtMi...",
"object": "video",
"created_at": 1772451930,
"status": "completed",
"completed_at": 1772452114,
"expires_at": 1772538330,
"model": "sora-2",
"progress": 100,
"prompt": "A cinematic drone shot over mountains",
"seconds": "8",
"size": "1280x720"
}
所有模型均透過status == "completed"判斷完成狀態,然後呼叫/content介面下載。
下載影片內容
GET /v1/videos/{video_id}/content
completed 後,呼叫此介面下載 MP4 影片檔案。
回應: 直接回傳影片二進位串流(Content-Type: video/mp4)。
curl https://aihubmix.com/v1/videos/{video_id}/content \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
--output my_video.mp4
注意:影片下載連結通常有 24 小時有效期,請及時下載儲存。
刪除影片任務
此介面用於刪除已建立的影片任務。DELETE /v1/videos/{video_id}
各模型參數詳解
OpenAI Sora
| 參數 | 支援值 |
|---|---|
| 模型 | sora-2、sora-2-pro |
| 時長 (seconds) | "4"(預設)、"8"、"12" |
| 解析度 (size) | 720x1280(預設)、1280x720、1024x1792、1792x1024 |
| 圖生影片 | 支援,透過 input_reference 傳入圖片 |
提示:所有模型的範例seconds參數統一使用字串類型傳入(如"8")。
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "A cinematic drone shot soaring over a misty mountain range at sunrise, golden light filtering through the clouds",
"seconds": "8",
"size": "1280x720"
}'
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2-pro",
"prompt": "A person walking through a neon-lit city street at night, rain reflecting on the pavement, cinematic lighting",
"seconds": "12",
"size": "720x1280"
}'
Google Veo
| 參數 | 支援值 |
|---|---|
| 模型 | veo-3.1-generate-preview(推薦)、veo-3.1-fast-generate-preview(快速)、veo-3.0-generate-preview、veo-2.0-generate-001 |
| 時長 (seconds) | Veo 3/3.1:"4"、"6"、"8";Veo 2:"5"~"8"(預設 "8") |
| 解析度 (size) | 720p(預設)、1080p、4k(4K 僅 Veo 3+),或像素格式如 1280x720、1920x1080 |
| 寬高比 | 16:9(預設)、9:16 |
| 圖生影片(Veo 3.1) | 首幀:first_frame(或相容欄位 input_reference);尾幀:last_frame;參考圖:reference_images(陣列,最多 3 張)。圖片支援公網 URL、base64 dataURL、{"mime_type": "...", "data": "..."} 物件。時長:首幀/首尾幀支援 "4"/"6"/"8";使用參考圖時 Google 固定輸出 8 秒 |
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-generate-preview",
"prompt": "A tranquil Japanese garden, cherry blossom petals slowly drifting down, koi swimming in the pond, with the melodious sound of wind chimes in the background",
"seconds": "8",
"size": "1280x720"
}'
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-fast-generate-preview",
"prompt": "Ocean waves crashing on rocky cliffs at sunset, seagulls flying overhead",
"seconds": "8",
"size": "1280x720"
}'
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-generate-preview",
"prompt": "The camera slowly pushes in from a valley at dawn, transitioning naturally into sunset",
"seconds": "8",
"size": "1280x720",
"first_frame": "https://example.com/first.jpg",
"last_frame": "https://example.com/last.jpg"
}'
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-generate-preview",
"prompt": "The character from the reference images walks through a forest, cinematic shot",
"seconds": "8",
"size": "1280x720",
"reference_images": [
"https://example.com/ref1.jpg",
"https://example.com/ref2.jpg"
]
}'
圖片欄位說明:
- 首幀優先級:
first_frame>input_reference(OpenAI 相容單幀)。 first_frame/last_frame/reference_images每個元素均支援:公網 URL、base64 dataURL(data:image/png;base64,...)、或{"mime_type":"image/png","data":"<base64>"}物件。- 也相容 OpenRouter 風格的
frame_images(元素帶frame_type: first_frame | last_frame)與input_references別名。 - 參考圖最多 3 張,超出返回 400。
提示:Veo 支援原生音訊生成,可在 prompt 中描述音效,如「背景傳來鳥鳴聲」、「鋼琴旋律」。
通義萬相
| 參數 | 支援值 |
|---|---|
| 圖生影片模型 | wan2.6-i2v(推薦)、wan2.5-i2v-preview、wan2.2-i2v-plus |
| 時長 (seconds) | 因模型而異(見下方說明),預設 "5" |
| 解析度 (size) | 見下方表格,x 和 * 分隔符均可(如 1920x1080 或 1920*1080) |
| 圖生影片 | 透過 input_reference 傳入圖片 URL 或 base64 |
| 模型 | seconds 可選值 | 預設值 |
|---|---|---|
wan2.6-t2v / wan2.6-i2v | "2"~"15"(任意整數值) | "5" |
wan2.5-t2v-preview / wan2.5-i2v-preview | "5" 或 "10" | "5" |
| 清晰度 | 可選解析度 |
|---|---|
| 480P | 832x480、480x832、624x624 |
| 720P | 1280x720(預設)、720x1280、960x960、1088x832(4:3)、832x1088(3:4) |
| 1080P | 1920x1080、1080x1920、1440x1440、1632x1248(4:3)、1248x1632(3:4) |
注意:wan2.6 僅支援 720P 和 1080P;wan2.5 支援 480P、720P、1080P;wan2.2 僅支援 480P 和 1080P。範例
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.6-t2v",
"prompt": "A winding stream flows through an autumn forest, golden fallen leaves drifting on the water surface, sunlight casting dappled light and shadow through the leaves",
"seconds": "5",
"size": "1920x1080"
}'
curl -X POST https://aihubmix.com/v1/videos \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "wan2.6-i2v",
"prompt": "The character in the frame slowly turns their head and smiles, the camera slowly pushes in",
"seconds": "5",
"size": "1280x720",
"input_reference": "https://example.com/my-image.jpg"
}'
提示:wan2.5 及以上版本預設生成有聲影片(自動配音),中文 prompt 效果更佳。
豆包 Seedance
| 參數 | 支援值 |
|---|---|
| 模型 | doubao-seedance-2-0-260128、doubao-seedance-2-0-fast-260128 |
| 解析度 (resolution) | "480p"、"720p"(預設) |
| 時長 (duration) | 整數,範圍 4~15,或 -1(模型自動決定) |
| 寬高比 (ratio) | "adaptive"(預設,自動適配)、"16:9"、"9:16"、"1:1"、"4:3"、"3:4"、"21:9" |
| 有聲影片 (generate_audio) | 預設 true;設為 false 生成無聲影片 |
| 浮水印 (watermark) | 預設 false |
| 多模態參考 | 支援圖片、影片、音訊 |
extra_body.content 支援的引用類型
| 類型 | type 值 | role 值 | 說明 |
|---|---|---|---|
| 參考圖片 | image_url | reference_image | 畫面/風格參考圖片 |
| 參考影片 | video_url | reference_video | 運鏡/構圖參考影片 |
| 參考音訊 | audio_url | reference_audio | 背景音樂音訊檔案 |
Seedance 2.0 / 2.0 Fast
curl -X POST "https://aihubmix.com/v1/videos" \
-H "Authorization: Bearer $AIHUBMIX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedance-2-0-260128",
"prompt": "Create a first-person fruit tea commercial. Follow the framing of the reference video, use the reference audio as background music, begin with the first reference image, and end with the second reference image. Show an apple being picked, cut, shaken with ice and tea, then present the finished drink to the camera. Use a female voiceover.",
"extra_body": {
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic1.jpg"
},
"role": "reference_image"
},
{
"type": "image_url",
"image_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_image/r2v_tea_pic2.jpg"
},
"role": "reference_image"
},
{
"type": "video_url",
"video_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_video/r2v_tea_video1.mp4"
},
"role": "reference_video"
},
{
"type": "audio_url",
"audio_url": {
"url": "https://ark-project.tos-cn-beijing.volces.com/doc_audio/r2v_tea_audio1.mp3"
},
"role": "reference_audio"
}
],
"ratio": "16:9",
"duration": 11,
"watermark": false
}
}'
Kling
| 供應商 | 模型 ID |
|---|---|
| Kling | kling-v3-omni, kling-video-o1 |
本清單表示模型目前已上線,不代表所有模型共用相同輸入欄位。請依模型 Schema 回傳的
path 選擇端點,再讀取該項的 request.schema。完整呼叫範例
import requests
import time
API_KEY = "AIHUBMIX_API_KEY"
BASE_URL = "https://aihubmix.com"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# 第一步:建立影片生成任務
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=HEADERS,
json={
"model": "wan2.6-t2v",
"prompt": "A desert under a starry sky, a meteor streaking across the night sky, the glow of a distant campfire flickering in the breeze",
"seconds": "5",
"size": "1920x1080"
}
)
result = response.json()
video_id = result["id"]
print(f"任務已建立,video_id: {video_id}")
# 第二步:輪詢查詢狀態
while True:
status_response = requests.get(
f"{BASE_URL}/v1/videos/{video_id}",
headers=HEADERS
)
status_data = status_response.json()
current_status = status_data["status"]
print(f"目前狀態: {current_status}")
if current_status == "completed":
print("影片生成完成!")
break
elif current_status == "failed":
error_msg = status_data.get("error", {})
if isinstance(error_msg, dict):
error_msg = error_msg.get("message", "未知錯誤")
print(f"生成失敗: {error_msg}")
break
time.sleep(15) # 每 15 秒查詢一次
# 第三步:下載影片
video_response = requests.get(
f"{BASE_URL}/v1/videos/{video_id}/content",
headers=HEADERS
)
with open("output.mp4", "wb") as f:
f.write(video_response.content)
print(f"影片已儲存為 output.mp4({len(video_response.content) / 1024 / 1024:.1f} MB)")
import requests
import time
API_KEY = "AIHUBMIX_API_KEY"
BASE_URL = "https://aihubmix.com"
HEADERS = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# 建立影片生成任務
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=HEADERS,
json={
"model": "sora-2",
"prompt": "A cinematic shot of a futuristic city at sunset, flying cars in the background",
"seconds": "8", # 可選 "4"/"8"/"12"
"size": "1280x720" # 支援 1280x720, 720x1280, 1024x1792, 1792x1024
}
)
result = response.json()
video_id = result["id"]
print(f"任務已建立,video_id: {video_id}")
# Sora 狀態輪詢(可能出現 queued -> in_progress -> completed)
while True:
status_response = requests.get(
f"{BASE_URL}/v1/videos/{video_id}",
headers=HEADERS
)
status_data = status_response.json()
current_status = status_data["status"]
progress = status_data.get("progress", "")
print(f"狀態: {current_status}, 進度: {progress}%")
if current_status == "completed":
print("影片生成完成!")
break
elif current_status == "failed":
print(f"生成失敗: {status_data.get('error')}")
break
time.sleep(15)
# 下載影片
video_response = requests.get(
f"{BASE_URL}/v1/videos/{video_id}/content",
headers=HEADERS
)
with open("sora_output.mp4", "wb") as f:
f.write(video_response.content)
print("影片已儲存為 sora_output.mp4")
const API_KEY = "your_aihubmix_api_key";
const BASE_URL = "https://aihubmix.com";
async function generateVideo() {
// 第一步:建立任務(以 Veo 3.1 為例)
const createResponse = await fetch(`${BASE_URL}/v1/videos`, {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
model: "veo-3.1-generate-preview",
prompt: "A desert under a starry sky, with a meteor streaking across the night.",
seconds: "8",
size: "1280x720"
})
});
const { id: videoId } = await createResponse.json();
console.log(`任務已建立: ${videoId}`);
// 第二步:輪詢狀態
let status = "in_progress";
while (status !== "completed" && status !== "failed") {
await new Promise(resolve => setTimeout(resolve, 15000));
const statusResponse = await fetch(`${BASE_URL}/v1/videos/${videoId}`, {
headers: { "Authorization": `Bearer ${API_KEY}` }
});
const result = await statusResponse.json();
status = result.status;
console.log(`目前狀態: ${status}`);
}
if (status === "completed") {
// 第三步:下載影片
const videoResponse = await fetch(`${BASE_URL}/v1/videos/${videoId}/content`, {
headers: { "Authorization": `Bearer ${API_KEY}` }
});
const fs = require("fs");
const buffer = Buffer.from(await videoResponse.arrayBuffer());
fs.writeFileSync("output.mp4", buffer);
console.log("影片已儲存為 output.mp4");
}
}
generateVideo();
FAQ
影片生成需要多長時間?
影片生成通常需要 1-5 分鐘,具體時間取決於模型、解析度和時長。建議設定 15 秒的輪詢間隔。input_reference 參數怎麼用?
input_reference 用於圖生影片場景,支援三種傳入方式:
// 方式一:直接傳入圖片 URL
"input_reference": "https://example.com/image.jpg"
// 方式二:傳入 base64 編碼的圖片(物件格式)
"input_reference": {
"mime_type": "image/jpeg",
"data": "<BASE64_ENCODED_IMAGE>"
}
// 方式三:傳入 data URL
"input_reference": "data:image/jpeg;base64,<BASE64_ENCODED_IMAGE>"
影片下載連結有效期是多久?
生成的影片下載連結通常有 24 小時 有效期,請及時下載儲存。各模型seconds 參數有什麼區別?
| 模型 | 可選值 | 預設值 |
|---|---|---|
Sora (sora-2 / sora-2-pro) | "4", "8", "12" | "4" |
Veo 3/3.1 (veo-3.1-generate-preview 等) | "4", "6", "8" | "8" |
Veo 2 (veo-2.0-generate-001) | "5"~"8" | "8" |
通義萬相 wan2.6 | "2"~"15" | "5" |
通義萬相 wan2.5 | "5", "10" | "5" |
通義萬相 wan2.2 | "5"(固定) | "5" |
豆包 Seedance (doubao-seedance-2-0-*) | 整數 duration4~15 或 -1 | 5 |
seconds 參數統一使用字串類型傳入(如 "8"),API 會自動處理。
不同模型size 參數格式有什麼區別?
| 模型 | 支援的 size 值 |
|---|---|
| Sora | 1280x720720x12801024x17921792x1024 |
| Veo | 像素格式1280x720 等)或解析度標籤720p1080p4k) |
| 通義萬相 | 像素格式x 和 * 均可(如 1920x1080 或 1920*1080) |
| 即夢 AI | 寬高比格式16:99:16 等)或像素格式 |
| 豆包 Seedance | 寬高比格式("adaptive"、"16:9"、"9:16" 等) |
| 可靈 Kling | 不使用 size,改用 mode(std/pro/4k 控制清晰度)+ aspect_ratio(16:9/9:16/1:1 控制畫幅) |
seconds 和 duration 有什麼區別?
兩者含義相同,均表示影片時長。API 同時支援這兩個參數名(Sora 除外,Sora 只接受 seconds)。推薦統一使用 seconds。
如何撰寫更好的 prompt?
- 描述具體場景:包含主體、動作、環境、光線、氛圍
- 指定鏡頭語言:如「特寫」、「航拍」、「推鏡頭」、「慢動作」
- 描述風格:如「電影感」、「紀錄片風格」、「動畫風格」
- 中文模型用中文 prompt 效果更好:通義萬相針對中文最佳化
- Veo 支援音訊描述:可在 prompt 中描述聲音,如「鳥鳴聲」、「鋼琴旋律」
任務失敗怎麼處理?
當status 為 failed 時,回應中的 error 欄位會包含錯誤資訊:
{
"status": "failed",
"error": {
"message": "Video generation failed due to content policy violation",
"type": "video_generation_error"
}
}