MAGI-2 API
Sand AI 推出的 MAGI-2——生成 4 到 30 秒的 1080p 影片,聲音與畫面一同生成,可從文字提示詞、首幀,或最多 10 張參考圖片、5 段影片和 5 段音訊出發。
sand-ai/magi-2/text-to-video 根據提示詞生成片段,sand-ai/magi-2/image-to-video 以首幀為起點生成動畫,可選尾幀,sand-ai/magi-2/reference-to-video 則用你的圖片、影片和音訊建構場景。每個片段皆為 1080p、25 fps,長度 4 到 30 秒,提供六種長寬比,並內含對白、音效和環境音。
概覽
關於 MAGI-2 API
MAGI-2 的功能、它在 Sand AI 模型陣容中的定位,以及團隊選用它的原因。
MAGI-2 是來自 Sand AI 的影片生成模型,可透過 WaveSpeedAI REST API 使用。Sand AI 推出的 MAGI-2——生成 4 到 30 秒的 1080p 影片,聲音與畫面一同生成,可從文字提示詞、首幀,或最多 10 張參考圖片、5 段影片和 5 段音訊出發。
sand-ai/magi-2/text-to-video 根據提示詞生成片段,sand-ai/magi-2/image-to-video 以首幀為起點生成動畫,可選尾幀,sand-ai/magi-2/reference-to-video 則用你的圖片、影片和音訊建構場景。每個片段皆為 1080p、25 fps,長度 4 到 30 秒,提供六種長寬比,並內含對白、音效和環境音。
WaveSpeedAI 上的 MAGI-2 系列提供 3 個 REST 端點,涵蓋 Reference-To-Video, Image-To-Video, Text-To-Video 等工作流程。每個變體都有各自的定價、參數選項與範例輸出 — 請挑選符合您輸入模態與生產限制的版本,或使用同一組 API 金鑰呼叫多個變體,組合成多步驟的處理流程。
使用您呼叫其他 1,000+ 個 WaveSpeedAI AI 模型時相同的 API 金鑰、帳單帳戶與速率限制額度來執行 MAGI-2。無需另外設定供應商、無需各家 SDK、無需處理各家不同的速率限制 — 一次整合,涵蓋從文字轉圖片、文字轉影片,到音訊合成、3D 生成、放大與編輯的所有功能。
規格
MAGI-2 API 功能與上線狀態
開發者在選擇 API 前會查詢的模型專屬資訊:可用性、預期輸出長度、參考素材支援,以及目前可用的替代方案。
模式
文字 / 圖片 / 參考
圖片轉影片接受首幀和可選的尾幀。
解析度
1080p,25 fps
六種長寬比:16:9、9:16、1:1、4:3、3:4、21:9。
長度
4-30 秒
每次請求自選;預設 5 秒。
音訊
與影片一同生成
對白、音效、環境音和音樂;可以關閉。
端點
所有 MAGI-2 API 端點
WaveSpeedAI 目前提供 3 個 MAGI-2 端點 — 請選擇符合您工作流程的變體。
/filters:quality(82)/media/images/b9ad31d5-ece5-4a20-ae40-df7f1372b1c3.webp)
Magi 2 Reference To Video
MAGI-2 Reference-to-Video by Sand AI makes a 1080p video of 4 to 30 seconds with sound from up to 10 reference images, 5 videos and 5 audio clips. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
/filters:quality(82)/media/images/f51cdf22-c2bc-4579-88b0-e200526123d6.webp)
Magi 2 Image To Video
MAGI-2 Image-to-Video by Sand AI animates a first frame, with an optional last frame, into a 1080p video of 4 to 30 seconds with generated sound. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
/filters:quality(82)/media/images/b5d38231-6d61-4c15-85d3-83b63fac1be9.webp)
Magi 2 Text To Video
MAGI-2 Text-to-Video by Sand AI turns a prompt into a 1080p video of 4 to 30 seconds with generated sound, in six aspect ratios. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
範例
看看 MAGI-2 的實際效果
由 MAGI-2 API 生成的真實輸出。將滑鼠移到任一影片上即可預覽,點擊可開啟完整尺寸檢視器。
使用方式
如何使用 MAGI-2 API
從註冊到完成生成,只要四個步驟。完整的 Python、Node.js 與 cURL 範例請見下方的 API 區段。
- 01
取得 API 金鑰
註冊 WaveSpeedAI 帳號,並從控制台複製您的 API 金鑰。新帳號會獲贈免費入門點數 — 足以在開始計費前執行數十次 Playground。
- 02
提交 prediction
將您的輸入以 JSON 格式 POST 到 https://api.wavespeed.ai/api/v3/sand-ai/magi-2/text-to-video。端點會立即回傳 prediction id — 生成是非同步進行的,因此推論期間您不需要保持連線。
- 03
輪詢完成狀態
GET https://api.wavespeed.ai/api/v3/predictions/{request_id}/result。狀態為 completed 時回傳輸出;狀態為 failed、cancelled、timeout 或 deleted 時停止並回報錯誤;其他狀態則持續輪詢。
- 04
讀取輸出網址
當狀態為 "completed" 時,從 data.outputs[0] 讀取網址。該網址指向 WaveSpeedAI CDN 上您生成的媒體 — 依您呼叫的 MAGI-2 變體,可能是圖片、影片、音訊或 3D 檔案。
應用情境
您可以用 MAGI-2 打造什麼
開發者與創作者使用 MAGI-2 API 的常見工作流程。
完整的 30 秒場景
每次請求可在 4 到 30 秒之間任選長度,完整的場景、產品短片或故事段落一次生成為一段連貫的片段,不必拼接多個短片段。
聲音一次生成
對白、音效、環境音和音樂與畫面一同生成。把台詞放在提示詞的引號中,或關閉 generate_audio 以取得無聲片段。
讓靜態圖動起來
sand-ai/magi-2/image-to-video 以你的圖片為起點,並可結束於另一張圖片,適合產品展示、人像動畫和場景轉場。不指定長寬比時,影片會沿用你的圖片的形狀。
以參考素材建構的場景
sand-ai/magi-2/reference-to-video 可組合最多 10 張圖片、5 段影片和 5 段音訊;在提示詞中以 @image_1、@image_2 等引用它們,說明哪個是角色、哪個是場景。
直式、方形或超寬
可選 16:9、9:16、1:1、4:3、3:4 或 21:9,配合不同平台,從直式短影音到電影感超寬畫面都能涵蓋。
技巧
MAGI-2 提示詞技巧
讓 MAGI-2 產出更好結果的實用建議 — 整理自在實際生產流程中,影片模型通用的有效做法。
- 01
寫明主體、動作、場景與鏡頭
說明畫面中是誰或什麼、發生了什麼、在哪裡,以及鏡頭如何運動,例如緩慢推進或手持跟拍。較長的片段請描述場景從開始到結束如何發展。
- 02
把聲音寫進提示詞
聲音與畫面一同生成:把對白放在引號中,並寫明你想聽到的環境音、音效或音樂。如果你要使用自己的音軌,請將 generate_audio 設為 false。
- 03
使用目標形狀的首幀
在 sand-ai/magi-2/image-to-video 上,首幀會從中心裁切為所選長寬比。不填 aspect_ratio 則使用最接近你圖片的比例,或直接提供已是目標形狀的圖片,這樣就不會裁掉任何內容。
- 04
說明每個參考的用途
在 sand-ai/magi-2/reference-to-video 上,依提供順序以 @image_1、@image_2 ... 引用圖片,例如 @image_1 中的貓走過 @image_2 中的街道。
- 05
先短後長
先用 5 秒試一條提示詞,再把滿意的版本以你需要的完整長度重新生成,最長 30 秒。
定價
MAGI-2 API 定價
依輸出計費。最終費用會依您在各變體 Playground 中設定的參數(解析度、時長、輸出數量、參考素材)而調整。
| 端點 | 類型 | 起始價格 |
|---|---|---|
| sand-ai/ | reference-to-video | $0.08 |
| sand-ai/ | image-to-video | $0.08 |
| sand-ai/ | text-to-video | $0.08 |
API
呼叫 MAGI-2 API
請到 wavespeed.ai/accesskey 註冊取得 API 金鑰,然後透過 REST 提交 prediction。Playground 會為任何輸入組合產生可直接貼上的範例。
POSThttps://api.wavespeed.ai/api/v3/sand-ai/magi-2/text-to-video
# 1. Submit the prediction.
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
-X POST "https://api.wavespeed.ai/api/v3/sand-ai/magi-2/text-to-video" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $WAVESPEED_API_KEY" \
-d '{
"prompt": "A cinematic shot of a city at sunset, soft golden light",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": true
}')
TASK=$(printf '%s' "$SUBMIT_RESPONSE" | jq 'if has("data") then .data else . end')
PREDICTION_ID=$(printf '%s' "$TASK" | jq -r '.id')
if [ -z "$PREDICTION_ID" ] || [ "$PREDICTION_ID" = "null" ]; then
printf 'Submission response did not contain a prediction id
' >&2
exit 1
fi
RESULT_URL="https://api.wavespeed.ai/api/v3/predictions/$PREDICTION_ID/result"
# 2. Poll until the prediction finishes.
while true; do
RESPONSE=$(curl --silent --show-error --fail-with-body "$RESULT_URL" \
-H "Authorization: Bearer $WAVESPEED_API_KEY")
RESULT=$(printf '%s' "$RESPONSE" | jq 'if has("data") then .data else . end')
STATUS=$(printf '%s' "$RESULT" | jq -r '.status')
case "$STATUS" in
completed) printf '%s\n' "$RESULT" | jq '.outputs'; break ;;
failed|cancelled|timeout|deleted) printf '%s\n' "$RESULT" | jq . >&2; exit 1 ;;
*) sleep 2 ;;
esac
doneconst submitUrl = "https://api.wavespeed.ai/api/v3/sand-ai/magi-2/text-to-video";
const apiKey = process.env.WAVESPEED_API_KEY;
if (!apiKey) throw new Error('Set WAVESPEED_API_KEY');
async function requestJson(url, options = {}) {
const response = await fetch(url, options);
if (!response.ok) throw new Error(await response.text());
return response.json();
}
// 1. Submit the prediction.
const body = await requestJson(submitUrl, {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"prompt": "A cinematic shot of a city at sunset, soft golden light",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": true
}),
});
const task = body.data ?? body;
const resultUrl = `https://api.wavespeed.ai/api/v3/predictions/${task.id}/result`;
// 2. Poll until the prediction finishes.
while (true) {
const resultBody = await requestJson(resultUrl, {
headers: { "Authorization": `Bearer ${apiKey}` },
});
const result = resultBody.data ?? resultBody;
if (result.status === "completed") {
console.log(result.outputs);
break;
}
if (["failed", "cancelled", "timeout", "deleted"].includes(result.status)) throw new Error(JSON.stringify(result));
await new Promise(resolve => setTimeout(resolve, 2000));
}import json
import os
import time
from urllib.request import Request, urlopen
api_key = os.environ["WAVESPEED_API_KEY"]
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
payload = {
"prompt": "A cinematic shot of a city at sunset, soft golden light",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": True
}
def request_json(url, data=None):
request = Request(url, data=data, headers=headers, method="POST" if data else "GET")
with urlopen(request) as response:
return json.load(response)
# 1. Submit the prediction.
body = request_json("https://api.wavespeed.ai/api/v3/sand-ai/magi-2/text-to-video", json.dumps(payload).encode())
task = body.get("data", body)
result_url = f"https://api.wavespeed.ai/api/v3/predictions/{task['id']}/result"
# 2. Poll until the prediction finishes.
while True:
result_body = request_json(result_url)
result = result_body.get("data", result_body)
status = result.get("status")
if status == "completed":
print(result.get("outputs", []))
break
if status in {"failed", "cancelled", "timeout", "deleted"}:
raise RuntimeError(result)
time.sleep(2)比較
MAGI-2 與其他選擇比較
在 WaveSpeedAI 上,何時該選擇 MAGI-2 而非類似的模型。
MAGI-2 vs Kling 4.0
Kling 4.0 支援 3 到 30 秒,提供 720p、1080p 和 4K 輸出、HDR、關鍵幀、影片編輯和影片延長。MAGI-2 是專注 1080p 的模型,每個片段都內含聲音,並支援更多長寬比,包括 4:3 和 3:4。
MAGI-2 vs Grok Imagine Video 1.5
Grok Imagine Video 1.5 生成最高 1080p 的風格化短片,最多接受七張參考圖片。MAGI-2 最長可達 30 秒,還接受參考影片和參考音訊。
MAGI-2 vs MAGI-1
MAGI-1 是 Sand AI 先前推出的開放模型,用於電影感圖片轉影片。MAGI-2 是它的後繼者,新增文字轉影片、參考轉影片、聲音生成,以及最長 30 秒的 1080p 片段。
常見問題
MAGI-2 API — 常見問題
定價、授權、整合 — 關於在 WaveSpeedAI 上執行 MAGI-2 的常見問題。
什麼是 MAGI-2 API?
MAGI-2 是 Sand AI 的影片生成模型,在 WaveSpeedAI 上以 REST API 提供。Sand AI 推出的 MAGI-2——生成 4 到 30 秒的 1080p 影片,聲音與畫面一同生成,可從文字提示詞、首幀,或最多 10 張參考圖片、5 段影片和 5 段音訊出發。您可以透過程式呼叫,也可以在上方連結的 Playground 試用。
如何呼叫 MAGI-2 API?
註冊 WaveSpeedAI 帳號,從 /accesskey 複製您的 API 金鑰,然後將您的輸入以 JSON 格式 POST 到 https://api.wavespeed.ai/api/v3/sand-ai/magi-2/text-to-video。端點會回傳 prediction id。請從約每 2 秒輪詢一次結果端點開始,長時間任務可拉長間隔,並在任何終止狀態時停止。上方提供適用於生產環境的 Python / Node.js / cURL 範例。
MAGI-2 API 的費用是多少?
MAGI-2 $0.08 起。實際費用會依您設定的參數(解析度、時長、輸出數量、參考素材)而調整。Playground 中「生成」按鈕旁的即時費用預覽會顯示您目前輸入的確切價格。
有哪些 MAGI-2 變體可用?
WaveSpeedAI 提供 3 個已上線的 MAGI-2 端點:sand-ai/magi-2/reference-to-video, sand-ai/magi-2/image-to-video, sand-ai/magi-2/text-to-video。每個變體都有各自的 Playground 頁面與定價。
MAGI-2 的輸出可以商用嗎?
商業使用權依 Sand AI 的模型授權而定。多數 Sand AI 模型允許商用輸出;請參閱各模型 Playground 頁面中的授權摘要,以及 WaveSpeedAI 的服務條款了解平台層級的條件。
為什麼要在 WaveSpeedAI 上使用 MAGI-2,而不是直接使用?
一組 API 金鑰、一個帳單帳戶,即可使用 MAGI-2 以及來自其他供應商的 1,000+ 個 AI 模型。無需設定各家 SDK、無需處理各自獨立的速率限制、無需為每個供應商重寫整合程式碼。價格通常與 Sand AI 的直接 API 相當或更低。
提供者
關於 Sand AI
MAGI-2 背後的團隊,以及 Sand AI 在 WaveSpeedAI 上的完整模型陣容。
Sand AI 是一家影片生成研究公司,也是 MAGI 系列模型的開發者。MAGI-1 以開放模型形式推出,用於電影感圖片轉影片;MAGI-2 新增 1080p 的文字轉影片和參考轉影片、最長 30 秒的片段,以及與畫面一同生成的聲音。在 WaveSpeedAI 上,MAGI-2 模型以 REST 端點形式提供,只需一組 API 金鑰,按用量計費。
在 WaveSpeedAI 上開始使用 MAGI-2 打造應用
註冊即贈免費入門點數。一組 API 金鑰,涵蓋來自 Sand AI 與所有其他供應商的 1,000+ 個 AI 模型。