MAGI-2 API 文档
Sand.aiMAGI-2 API 是 apimodels.app 上调用 Sand.ai 音视频模型 MAGI-2 的接口:一个 API Key、一个视频接口,把提示词、首尾帧或最多 20 个参考素材,变成 4–30 秒、1080p、25 fps、自带声音的视频。模型名就是 magi-2,模式按你传的字段自动选。按请求的秒数计费,每秒 $0.10,声音包含在内,生成失败或没通过审核的不扣费。
最后更新:2026-11-26
价格
MAGI-2 只有 1080p 一档,价格只看你请求的秒数:每秒 $0.10。开不开声音都是这个价。
| 时长 | 价格(1080p,含声音) |
|---|---|
| 4 s | $0.40 |
| 5 秒(默认) | $0.50 |
| 10 s | $1.00 |
| 30 s | $3.00 |
- 按 duration 计费,4–30 之间任意整秒,总价 = 秒数 × $0.10。
- 生成失败或被内容审核拦下的任务不扣费。参数不合法的请求在建任务前就返回 400,也不扣费。
- 成片文件保留 30 天后自动删除,请及时下载或转存。
四种输入方式:按字段自动选
MAGI-2 没有单独的图生视频或参考生视频模型名,model 一直是 magi-2。带了首帧就是图生视频(再带尾帧就是首尾帧),带了参考素材就是参考生视频,都没有就是文生视频。首尾帧和参考素材不能放在同一个请求里,混用会返回 400。
| 模式 | 怎么触发 | 说明 |
|---|---|---|
| 文生视频 | 只有 prompt | prompt 必填 |
| 图生视频(首帧) | first_frame_url | 视频从这张图开场;prompt 可选 |
| 首尾帧 | first_frame_url + last_frame_url | 模型补出两张图之间的运动;prompt 可选 |
| 参考生视频 | reference_image_urls / reference_video_urls / reference_audio_urls | 最多 10 张图、5 段视频、5 段音频,至少一项;prompt 可选 |
创建任务与轮询
POST /v1/video/generations 是异步接口:创建后返回 taskId,再轮询 GET /v1/video/generations?task_id= 直到 state 为 completed,成片在 data.resultUrls[0];也可以传 callback_url,任务结束时我们回调你的地址。
curl -X POST https://api.apimodels.app/v1/video/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2",
"prompt": "A street violinist plays under a railway bridge at dusk. A passing train rumbles overhead; she looks up and says, \"Right on time.\" Slow dolly in, warm sodium lights.",
"duration": 10,
"aspect_ratio": "16:9"
}'
# Response: a task is created
# { "code": 200, "msg": "success", "data": { "taskId": "clxxx", "state": "pending" } }
# Poll every 10-20 s until state is "completed" (or "failed")
curl "https://api.apimodels.app/v1/video/generations?task_id=TASK_ID" \
-H "Authorization: Bearer YOUR_API_KEY"
# { "code": 200, "data": { "state": "completed",
# "resultUrls": ["https://r2.apimodels.app/videos/clxxx.mp4"] } }- state 只有三个值:pending(排队或生成中)、completed(成功)、failed(失败,不扣费,不会再变)。
- MAGI-2 出片按分钟算,不是按秒:我们 2026-11-25 实测一条 4 秒文生视频,提交后 194 秒完成,成片 1920×1080、25 fps,H.264 画面加 AAC 立体声。这只是一次实测,不是基准测试。高峰时任务要先排队再开始渲染,建议每 10–20 秒查一次,或者直接用 callback_url。
三种请求示例
每个示例都能直接复制,把 YOUR_API_KEY 和素材链接换成你自己的。
1. 文生视频(台词写在引号里)
curl -X POST https://api.apimodels.app/v1/video/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2",
"prompt": "A street violinist plays under a railway bridge at dusk. A passing train rumbles overhead; she looks up and says, \"Right on time.\" Slow dolly in, warm sodium lights.",
"duration": 10,
"aspect_ratio": "16:9"
}'2. 首尾帧
curl -X POST https://api.apimodels.app/v1/video/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2",
"prompt": "The flower bud on the windowsill opens petal by petal as morning light moves across the room; soft birdsong outside.",
"first_frame_url": "https://your-domain.com/bud.jpg",
"last_frame_url": "https://your-domain.com/bloom.jpg",
"duration": 6,
"aspect_ratio": "1:1"
}'3. 参考生视频(图 + 视频 + 音频)
curl -X POST https://api.apimodels.app/v1/video/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2",
"prompt": "The woman from the reference images walks through the night market holding the red umbrella, matching the camera move of the reference video, to the rhythm of the reference track.",
"reference_image_urls": [
"https://your-domain.com/character-front.jpg",
"https://your-domain.com/red-umbrella.png"
],
"reference_video_urls": ["https://your-domain.com/camera-move.mp4"],
"reference_audio_urls": ["https://your-domain.com/beat.mp3"],
"duration": 12,
"aspect_ratio": "9:16",
"seed": 42
}'请求参数
MAGI-2 的请求体只认下面这些字段;它不支持的开关(watermark、negative_prompt 等)会返回 400,不会被悄悄忽略。
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | "magi-2" |
| prompt | 文生视频必填 | string | 最长 15,000 个字符。写清主体、动作、运镜和想听到的声音,台词放进引号里。带首帧或参考素材时可以不写 |
| duration | 否 | integer | 4–30 的整数秒,默认 5。按这个秒数计费 |
| aspect_ratio | 否 | string | 21:9、16:9、4:3、1:1、3:4、9:16,默认 16:9 |
| resolution | 否 | string | 只有 "1080p",可以不传 |
| generate_audio | 否 | boolean | 默认 true,对白、音效和音乐跟画面一起生成;false 出无声视频,价格不变 |
| seed | 否 | integer | 0–4294967295;-1 或不传就是随机 |
| first_frame_url | 否 | string | 首帧:https 链接或 base64 data URI。也收 image / image_url |
| last_frame_url | 否 | string | 尾帧,必须和 first_frame_url 一起传 |
| reference_image_urls | 否 | string[] | 最多 10 张参考图(人物、产品、场景或风格),https 链接或 base64 data URI |
| reference_video_urls | 否 | string[] | 最多 5 段参考视频,只收 https 链接;每段 2–30 秒,合计不超过 30 秒 |
| reference_audio_urls | 否 | string[] | 最多 5 段参考音频,只收 https 链接;每段 2–30 秒,合计不超过 30 秒 |
| callback_url | 否 | string | 任务结束时回调的地址;不传就轮询 GET 查询 |
错误与失败
参数不合法的请求在建任务前就返回 400,不扣钱;下面是 MAGI-2 最常见的几条原文。
| 状态 | 什么时候 | 返回的 msg |
|---|---|---|
| 400 | 时长不是 4–30 的整数 | duration must be a whole number of seconds from 4 to 30 |
| 400 | 画幅不在六种之内 | aspect_ratio must be one of 21:9, 16:9, 4:3, 1:1, 3:4, 9:16 |
| 400 | 首尾帧和参考素材混用 | first / last frame cannot be combined with reference images, videos or audio |
| 400 | 只传了尾帧 | last_frame_url requires first_frame_url |
| 400 | 素材用了 http 链接 | first_frame_url must use https links |
| 400 | 参考视频或音频太短、太长 | each reference video must be 2–30 seconds long |
| 400 | 文生视频没写提示词 | prompt is required |
| 401 | API Key 缺失或无效 | — |
| 402 | 余额不够付这一条 | — |
| state: failed | 内容审核没过,或生成失败 | 不扣费,改一下输入再试 |
限制
- 只出 1080p、25 fps;没有 720p、2K、4K。时长只能是 4–30 的整数秒。
- 首尾帧和参考素材不能混用;参考视频和参考音频只收 https 链接,图片可以传 base64。
- 一条要几分钟,高峰时还要排队。要一分钟内拿到结果、要 4 秒以下的片子,或者要 720p / 2K / 4K,请换别的视频模型。
- 不保证每次都成功:内容审核或生成失败都可能让任务失败,失败不扣费。
- Sand.ai 自己列出的短板:极高速运动、中远景 2D 动画里的局部小动作、层次复杂的声场。
参考资料
2026-11-26 核对;价格是本站价格,模型能力以 Sand.ai 自己的说法为准。
相关
常见问题
MAGI-2 API 怎么调用?
向 https://api.apimodels.app/v1/video/generations 发 POST,model 填 "magi-2",带上提示词和时长(4–30 整数秒,默认 5),用的就是 apimodels.app 上调其他模型的那个 API Key。返回 taskId 后轮询 GET /v1/video/generations?task_id=…,state 变成 "completed" 时成片在 data.resultUrls[0];也可以传 callback_url 等回调。加 first_frame_url 是图生视频,加 reference_image_urls 是参考生视频,模式跟着字段走。
MAGI-2 API 多少钱?
1080p 每请求秒 $0.10,声音包含在内:4 秒 $0.40,5 秒 $0.50,10 秒 $1.00,30 秒 $3.00。用 generate_audio: false 关掉声音,价格不变。生成失败或被审核拦下的不扣费;参数不合法的请求在建任务前就返回 400。
MAGI-2 API 能图生视频、首尾帧吗?
能。传 first_frame_url,视频从这张图开场;再传 last_frame_url,模型补出两张图之间的运动。帧可以是 https 链接,也可以是 base64 data URI。last_frame_url 必须和 first_frame_url 一起传,首尾帧也不能和参考素材放在同一个请求里(会返回 400)。
MAGI-2 最多能带多少参考图、参考视频和参考音频?
reference_image_urls 最多 10 张图,reference_video_urls 最多 5 段视频,reference_audio_urls 最多 5 段音频,至少要有一项。每段视频或音频 2–30 秒,同一类合计不超过 30 秒。视频和音频只收 https 链接,图片也可以传 base64。
MAGI-2 生成一条视频要多久?
按几分钟来预估。我们 2026-11-25 实测一条 4 秒文生视频,提交后 194 秒拿到成片,1920×1080、25 fps,带 AAC 立体声;这只是一次实测,不是基准测试。高峰时任务要先排队再渲染,建议每 10–20 秒查一次,或者用 callback_url。要一分钟内出片,请换别的视频模型。