APIMaster.ai

MAGI-2 视频 API

使用文字、首尾帧或多模态参考素材生成 1080p 视频,默认生成同步音轨。

MAGI-2 视频 API

使用文字、首尾帧或多模态参考素材生成 1080p 视频,默认生成同步音轨。

提交任务与下载

在控制台创建 API Key。用 Bearer 鉴权提交 JSON,保存返回的任务 ID,并持续查询同一个任务,直到成功或失败。单次查询超时不会停止任务。使用同一把 Key 下载完成的 MP4。

API Key 控制台

curl --fail-with-body "https://apimaster.ai/v1/videos/generations" \
  -H "Authorization: Bearer $APIMASTER_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: magi2-cup-001" \
  -d '{"model":"magi-2","prompt":"A slow camera move toward a ceramic cup in soft daylight.","duration":5,"aspect_ratio":"16:9"}'
{"id":"task_…","task_id":"task_…","object":"video","model":"magi-2","status":"queued"}
TASK_ID="task_..."

curl --fail-with-body "https://apimaster.ai/v1/videos/$TASK_ID" \
  -H "Authorization: Bearer $APIMASTER_API_KEY"

curl --fail-with-body --location "https://apimaster.ai/v1/videos/$TASK_ID/content" \
  -H "Authorization: Bearer $APIMASTER_API_KEY" -o magi-2.mp4

queued → in_progress → completed / failed

生成方式

文生视频

{"model":"magi-2","prompt":"A blue cup on a table. Slow camera push in with quiet room tone.","duration":4,"generate_audio":true}

首尾帧图生视频

{"model":"magi-2","prompt":"Move from the first composition to the final composition.","first_frame_image":"https://example.com/start.jpg","last_frame_image":"https://example.com/end.jpg","aspect_ratio":"auto","generate_audio":false}

多模态参考生视频

{
  "model": "magi-2",
  "prompt": "Use the image for appearance, the clip for camera movement and the audio for mood.",
  "duration": 6,
  "omni_reference_task_type": "reference",
  "image_with_roles": [{"url": "https://example.com/object.jpg", "role": "reference_image"}],
  "video_urls": ["https://example.com/camera.mp4"],
  "audio_urls": ["https://example.com/room-tone.mp3"]
}

素材必须使用无需鉴权即可下载的公网 HTTP(S) 直链。素材用于引导生成。接口不支持编辑、续写或中间关键帧。

参数说明

字段 类型 规则
model string magi-2
prompt string 三种方式都必填,最长 15,000 字符。
duration / seconds integer 输出时长为 4–30 整数秒,默认 5 秒。两个字段同时传入时必须一致。
resolution string 只支持 1080p,可省略。
aspect_ratio string 文生和参考模式默认 16:9,也支持 9:16、1:1、4:3、3:4、21:9。首尾帧模式可省略或传 auto 以跟随首帧,不支持 21:9。
generate_audio / audio boolean 默认生成音轨。两个字段同时传入时必须一致。参考音频通过 audio_urls 传入。
nsfw_check boolean 可在提交任务前审核提示词和输入图片,默认 false。
seed integer 省略或传 -1 表示随机。固定整数范围 0–2147483647,有助于重复相近设置,结果可能不同。
omni_reference_task_type string 可选 auto 或 reference。参考视频、音频或 reference_image 角色自动触发参考模式。只有 image_urls 且希望作为参考图时,显式传 reference。
image_urls string[] 首尾帧模式限 1–2 张。参考模式与 reference_image 角色合计最多 10 张。
first_frame_image / last_frame_image string 与 image_urls 二选一。使用尾帧时必须提供首帧。
image_with_roles object[] 每项包括 url 和 role。role 支持 first_frame、last_frame 或 reference_image。
video_urls / audio_urls string[] 视频和音频各最多 5 段,每段 2–30 秒,每类合计不超过 30 秒。

计费与错误

Sand AI 基础价为每请求输出秒 0.08 美元,5 秒为 0.40 美元。音轨、参考素材和画幅不改变基础单价。提交被拒或生成失败不收费。提交失败或任务失败时读取 message / error.message。提交请求超时后沿用同一 Idempotency-Key 和相同请求体。

Sand AI