---
title: "MAGI-2"
description: "Sand AI 的 1080p 有声视频模型，单次生成 4–30 秒，支持文生、首尾帧，以及图片、视频、音频混合参考。"
seo:
  title: "MAGI-2 API 文档：参数与调用示例"
  description: "MAGI-2 API 文档：模型 ID sand-ai/magi-2、输入模式、参数取值与默认值，附请求示例。Sand AI 的 1080p 有声视频模型，单次生成 4–30 秒，支持文生、首尾帧，以及图片、视频、音频混合参考。"
---

{/* 由 scripts/generate-model-pages.mjs 根据 openapi/model-contracts.json 生成，请勿手改；补充说明写在 docs/zh/models/_notes/sand-ai/magi-2.mdx */}

| 模型 ID | 别名 | 接口 |
| --- | --- | --- |
| `sand-ai/magi-2` | `magi-2`、`magi-2.0` | [视频生成](/zh/docs/guides/video-generation) |

## 输入模式

| 模式 | 参考数量 | 参考角色 |
| --- | --- | --- |
| `text` 纯文本 | — | — |
| `image` 图片输入 | 1–2 | `first_frame` 1<br />`last_frame` 0–1 |
| `reference` 参考素材 | 1–20 | `reference_audio` 0–5<br />`reference_image` 0–10<br />`reference_video` 0–5 |

提示词上限：8000 个字符，超出时返回 400。

## 参数

| 参数 | 说明 | 取值 | 默认值 | 必填 |
| --- | --- | --- | --- | --- |
| `duration` | 时长：输出视频的秒数。 | `4`–`30` | `5` | 否 |
| `resolution` | 分辨率：输出内容的分辨率。 | `1080p` | `1080p` | 否 |
| `aspect_ratio` | 画幅：输出内容的宽高比。 | `21:9`、`16:9`、`4:3`、`1:1`、`3:4`、`9:16` | `16:9` | 否 |
| `generate_audio` | 生成音频：随视频生成原生音频。 | `false`、`true` | `true` | 否 |
| `n` | 单次请求输出数量：单次 API 请求（一个 Job）的输出数量，不是应用的批量张数。应用可提交多个独立请求组成一批；n=1 不表示应用只能生成一张。 | `1` | `1` | 否 |

## 示例

`text` 输入：

```json
{
  "model": "sand-ai/magi-2",
  "input": {
    "type": "text",
    "prompt": "A paper boat drifting down a rainy city street, slow tracking shot"
  },
  "parameters": {
    "duration": 5,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "generate_audio": true,
    "n": 1
  }
}
```

`image` 输入：

```json
{
  "model": "sand-ai/magi-2",
  "input": {
    "type": "image",
    "prompt": "A paper boat drifting down a rainy city street, slow tracking shot",
    "references": [
      {
        "role": "first_frame",
        "file_id": "file_..."
      }
    ]
  },
  "parameters": {
    "duration": 5,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "generate_audio": true,
    "n": 1
  }
}
```

`reference` 输入：

```json
{
  "model": "sand-ai/magi-2",
  "input": {
    "type": "reference",
    "prompt": "A paper boat drifting down a rainy city street, slow tracking shot",
    "references": [
      {
        "role": "reference_image",
        "file_id": "file_..."
      }
    ]
  },
  "parameters": {
    "duration": 5,
    "resolution": "1080p",
    "aspect_ratio": "16:9",
    "generate_audio": true,
    "n": 1
  }
}
```

完整合同以 `GET /v1/models/sand-ai/magi-2?view=contract` 为准。参数合法不代表每个渠道都能执行，请对完整请求[报价](/zh/docs/concepts/billing#获取报价)。价格与渠道见[模型市场](https://yir.ai/zh/models)。

MAGI-2 输出 1080p、25 fps 视频。出片较慢，约需 13–25 分钟，请用 [Webhook](/zh/docs/production/webhooks) 或轮询获取结果。成片比 `duration` 长约 0.24 秒。

使用 `first_frame` 时，请把 `aspect_ratio` 设成与首帧一致的值。画幅不跟随图片，默认 `16:9`。

参考生视频可以只给音频。参考视频和参考音频每段 2–30 秒，各自合计不超过 30 秒。在提示词中按顺序用 `@image_1`、`@video_1`、`@audio_1` 引用。首尾帧用 `@first_frame`、`@last_frame` 引用。图片须小于 30 MB、不超过 1600 万像素、边长 16–10,000 像素；参考视频须为 MP4 且不超过 200 MB；音频不超过 15 MB。Sand AI 的 `seed` 与 `enhance_prompt` 参数未开放。

按请求的 `duration` 计费，画幅、音频和参考素材不影响单价。

[Sand AI API 文档](https://platform.sand.ai/docs/ark-generations/)
