curl --request GET \
--url 'https://console.mixroute.io/v1/video/generations/download?id=video_xxx' \
--header 'Authorization: Bearer sk-xxxxxxxxxx'
{
"success": true,
"generation_id": "video_xxx",
"task_id": "video_xxx",
"format": "mp4",
"size": 15728640,
"base64": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDE...",
"data_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDE..."
}
下載已完成的影片檔案資料
curl --request GET \
--url 'https://console.mixroute.io/v1/video/generations/download?id=video_xxx' \
--header 'Authorization: Bearer sk-xxxxxxxxxx'
{
"success": true,
"generation_id": "video_xxx",
"task_id": "video_xxx",
"format": "mp4",
"size": 15728640,
"base64": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDE...",
"data_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDE..."
}
Bearer sk-xxxxxxxxxx
task_idcurl -X GET "https://console.mixroute.io/v1/video/generations/download?id=video_69095b4ce0048190893a01510c0c98b0" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
{
"success": true,
"generation_id": "video_69095b4ce0048190893a01510c0c98b0",
"task_id": "video_69095b4ce0048190893a01510c0c98b0",
"format": "mp4",
"size": 15728640,
"base64": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB...",
"data_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB..."
}
| 欄位 | 類型 | 說明 |
|---|---|---|
success | boolean | 請求是否成功 |
generation_id | string | 生成 ID(與 videoId 相同) |
task_id | string | 任務 ID |
format | string | 影片格式(固定為 "mp4") |
size | number | 影片檔案大小(位元組) |
base64 | string | Base64 編碼的影片資料 |
data_url | string | Data URL 格式的影片資料,可直接用於前端 <video> 標籤 |
data_url 欄位可以直接用於 HTML <video> 標籤:
<video src="data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAAB..." controls></video>
// 從回應中取得 base64 資料
const response = await fetch('https://console.mixroute.io/v1/video/generations/download?id=video_xxx', {
headers: {
'Authorization': 'Bearer sk-xxxxxxxxxx'
}
});
const data = await response.json();
// 將 base64 轉換為 Blob
const binaryString = atob(data.base64);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
const blob = new Blob([bytes], { type: 'video/mp4' });
// 建立下載連結
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'video.mp4';
a.click();
URL.revokeObjectURL(url);
import requests
import base64
def download_video(video_id, api_key):
"""下載影片並儲存為檔案"""
url = f"https://console.mixroute.io/v1/video/generations/download?id={video_id}"
headers = {"Authorization": f"Bearer {api_key}"}
response = requests.get(url, headers=headers)
data = response.json()
if data.get("success"):
# 解碼 base64 資料
video_data = base64.b64decode(data["base64"])
# 儲存為檔案
with open("video.mp4", "wb") as f:
f.write(video_data)
print(f"✅ 影片已儲存:video.mp4(大小:{data['size']} 位元組)")
return True
else:
print("❌ 下載失敗")
return False
curl -X POST "https://console.mixroute.io/v1/video/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "sora-2",
"prompt": "一隻可愛的小貓在花園裡玩耍",
"seconds": "4",
"size": "720x1280"
}'
{
"task_id": "video_69095b4ce0048190893a01510c0c98b0",
"status": "submitted",
"format": "mp4"
}
curl -X GET "https://console.mixroute.io/v1/video/generations/video_69095b4ce0048190893a01510c0c98b0" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
succeeded 時,繼續下一步。
curl -X GET "https://console.mixroute.io/v1/video/generations/download?id=video_69095b4ce0048190893a01510c0c98b0" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
curl --request GET \
--url 'https://console.mixroute.io/v1/video/generations/download?id=video_xxx' \
--header 'Authorization: Bearer sk-xxxxxxxxxx'
{
"success": true,
"generation_id": "video_xxx",
"task_id": "video_xxx",
"format": "mp4",
"size": 15728640,
"base64": "AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDE...",
"data_url": "data:video/mp4;base64,AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDE..."
}