首尾帧生视频
MAGI-2 的 image_to_video:从首帧开始(也可以指定尾帧)生成 1080p 带声音的视频。
MAGI-2 从你的首帧开始生成视频;再传一张图时,视频停在这张尾帧上,中间的动作由模型生成。这个模式也要传 aspect_ratio:请选和首帧一样的比例(比例不一致时的效果没有验证过)。不能带参考视频、参考音频。
创建任务
POST
https://api.nanoapi.ai/v1/tasks用所有模型共用的创建任务接口,model 传 "magi-2.0"。
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer <API Key>,见鉴权 |
Content-Type | 是 | application/json |
Idempotency-Key | 否 | 每个新任务一个唯一字符串,建议用 UUID(1–255 个字符),见防止重复创建 |
请求体
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | magi-2.0 |
mode | string | 是 | image_to_video |
image_urls | string[] | 是 | 1–2 张:第 1 张是首帧,第 2 张(可选)是尾帧。见素材 |
prompt | string | 是 | 描述画面怎么动,最长 8000 字符,建议用英文。可以用 @Image1、@Image2 指代图片 |
resolution | string | 是 | 1080p,只有这一档(也要传) |
aspect_ratio | string | 是 | 21:9、16:9、4:3、1:1、3:4 或 9:16(不能传 auto)。请选和首帧一样的比例 |
duration | integer | 是 | 输出时长(秒),4–30,按此计费,见价格 |
generate_audio | boolean | 否 | 输出视频是否带声音,默认 true。不影响价格 |
webhook_url | string | 否 | 任务成功或失败时通知该地址:https,最长 2048 字符,不能指向内网、回环或保留地址。见回调 |
首帧 + 尾帧,1080p、9:16(两张都是竖图)、5 秒:
curl https://api.nanoapi.ai/v1/tasks \
-H "Authorization: Bearer $NANOAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2.0",
"mode": "image_to_video",
"image_urls": ["https://example.com/first.jpg", "https://example.com/last.jpg"],
"prompt": "The flower bud slowly opens into full bloom as morning light moves across the petals",
"resolution": "1080p",
"aspect_ratio": "9:16",
"duration": 5
}'响应:200 OK,新建的任务(字段说明)。保存 data.id,用它获取结果:渲染约需 13–20 分钟。任务仍可能失败,见错误。
{
"code": 200,
"message": "success",
"data": {
"object": "task",
"id": "tk_01jbq5w8m2c4x7b0n3q6t9e1r5",
"model": "magi-2.0",
"status": "queued",
"error": null,
"created_at": "2026-11-25T08:30:00Z"
}
}价格
费用 = 输出时长 duration × 每秒单价(1080p)正在读取当前价格…
计费秒数即请求的 duration。传一张还是两张、画面比例、输出视频是否带声音(generate_audio)都不影响价格。当前单价见 GET /v1/products(magi 的 prices),以任务的 billing.frozen 为准;冻结和扣费规则见计费。
错误
见 MAGI-2 → 错误。本模式的参数规则见上面的参数表。