> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vidgo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# MAGI-2 参考生视频

> MAGI-2 参考生视频 API 结合最多 10 张参考图、5 段参考视频和 5 段参考音频，生成 4–30 秒带同步音频的 1080p 视频。

> [!TIP]
>
> 1. 提交后会返回 `task_id`。如果提供了 `callback_url`，当任务状态变为 `finished` 或 `failed` 时，系统会向 `callback_url` 发送 POST 请求。
> 2. 无论是否提供 `callback_url`，都可以通过统一的[查询任务状态](https://docs.vidgo.ai/zh/api-manual/task-management/status.md)接口获取结果。

MAGI-2 参考生视频通过参考图、参考视频和参考音频的任意组合（包括仅传参考音频）生成 4–30 秒的 1080p 视频。可在 `prompt` 中说明每类参考素材如何控制角色外观、动作、音色或配乐。

如需纯文本生成，请使用 [MAGI-2 文生视频](https://docs.vidgo.ai/zh/api-manual/video-series/sand-ai-magi-2-text-to-video.md)；如需首尾帧控制，请使用 [MAGI-2 图生视频](https://docs.vidgo.ai/zh/api-manual/video-series/sand-ai-magi-2-image-to-video.md)。

## 模型

* **sand-ai/magi-2/reference-to-video** — 多模态参考 1080p 视频生成，4–30 秒，支持同步音频。

## 功能

* 单任务最多支持 10 张参考图、5 段参考视频和 5 段参考音频。
* 三类参考素材可任意组合，也支持仅传入参考音频。
* 单次生成 4–30 秒 1080p 视频，支持六种宽高比（`16:9`、`9:16`、`1:1`、`4:3`、`3:4`、`21:9`）。
* 提示词最长 15,000 个字符，同步生成对白、音效和环境音。

## 必填参数

* `prompt` (string)：描述各参考素材的用途以及场景、动作、运镜和声音，最多 15,000 个字符。
* `reference_image_urls`、`reference_video_urls`、`reference_audio_urls` 至少提供一项非空数组。

## 可选参数

* `reference_image_urls` (string\[])：最多 10 个公开 HTTP(S) 参考图 URL（JPG、PNG 或 WEBP）。
* `reference_video_urls` (string\[])：最多 5 个公开 HTTP(S) MP4 或 MOV 视频 URL（单段 2–30 秒，总时长不超过 30 秒）。
* `reference_audio_urls` (string\[])：最多 5 个公开 HTTP(S) MP3 或 WAV 音频 URL（单段 2–30 秒，总时长不超过 30 秒）。
* `duration` (integer)：视频时长（整秒），范围 `4` 到 `30`，默认 `5`。
* `resolution` (string)：固定 `1080p`。
* `aspect_ratio` (string)：`16:9`（默认）、`9:16`、`1:1`、`4:3`、`3:4` 或 `21:9`。
* `generate_audio` (boolean)：`true`（默认）生成同步音频；`false` 仅输出无声视频。
* `seed` (integer)：随机种子，`0` 到 `2147483647`。

## 输出

任务完成后返回单个 MP4 文件：25 fps 的 H.264 视频；当 `generate_audio` 为 `true` 时附带 AAC 立体声音轨。

## 示例

* **角色图 + 音频参考**：保持参考图中的角色形象，并配合参考音频旋律生成 8 秒画面。
* **纯音频参考**：仅通过 `reference_audio_urls` 驱动 5 秒音乐表演视频。

## 注意事项

* `reference_image_urls`、`reference_video_urls`、`reference_audio_urls` 至少需传入一项；本接口不接受 `image_urls`（会返回 400）。
* 所有媒体 URL 必须公开可访问且可直接下载。
* 积分按 `duration` 秒数计费（1080p），参考素材数量与 `generate_audio` 开关不额外加价。任务失败全额退还。当前价格见[定价页](https://vidgo.ai/apis/api-pricing)。


## OpenAPI

````yaml zh/api-manual/video-series/sand-ai-magi-2-reference-to-video.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Vidgo API - MAGI-2 参考生视频
  description: MAGI-2 参考生视频 API 结合最多 10 张参考图、5 段参考视频和 5 段参考音频，生成 4–30 秒带同步音频的 1080p 视频。
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境服务器
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - MAGI-2 Reference to Video
      summary: 提交 MAGI-2 参考生视频任务
      operationId: submitSandAiMagi2ReferenceToVideoTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              characterAudio:
                summary: 角色图 + 音频参考
                value:
                  model: sand-ai/magi-2/reference-to-video
                  input:
                    prompt: >-
                      The musician from the reference image walks along a sunlit
                      boardwalk playing the melody from the reference audio.
                    reference_image_urls:
                      - https://example.com/character.jpg
                    reference_audio_urls:
                      - https://example.com/melody.mp3
                    duration: 8
                    aspect_ratio: '16:9'
              audioOnly:
                summary: 纯音频参考
                value:
                  model: sand-ai/magi-2/reference-to-video
                  input:
                    prompt: >-
                      A cellist performs under warm stage spotlights in time
                      with the reference audio.
                    reference_audio_urls:
                      - https://example.com/melody.mp3
                    duration: 5
                    aspect_ratio: '16:9'
      responses:
        '200':
          description: 任务提交结果。任务 ID 标识一项异步任务；生成可能仍在进行中。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: 请求参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: false
      properties:
        model:
          type: string
          example: sand-ai/magi-2/reference-to-video
        callback_url:
          type: string
          format: uri
          description: 可选的 Webhook URL，用于接收完成或失败通知。
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - prompt
          additionalProperties: false
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 15000
              description: 描述场景、主体、动作、运镜与声音。角色对白请放在引号内。
            duration:
              type: integer
              minimum: 4
              maximum: 30
              default: 5
              description: 输出视频时长（整秒），4 到 30 秒，默认 5。
            resolution:
              type: string
              enum:
                - 1080p
              default: 1080p
              description: 输出分辨率，固定 1080p。
            aspect_ratio:
              type: string
              enum:
                - '16:9'
                - '9:16'
                - '1:1'
                - '4:3'
                - '3:4'
                - '21:9'
              default: '16:9'
              description: 输出画面宽高比，默认 16:9。
            generate_audio:
              type: boolean
              default: true
              description: 是否同步生成音频，默认 true；false 仅输出无声视频。
            seed:
              type: integer
              minimum: 0
              maximum: 2147483647
              description: 可选随机种子，0 到 2147483647。
            reference_image_urls:
              type: array
              maxItems: 10
              items:
                type: string
                format: uri
              description: 最多 10 个公开 HTTP(S) 参考图 URL（JPG、PNG 或 WEBP）。三类参考数组至少提供一项。
            reference_video_urls:
              type: array
              maxItems: 5
              items:
                type: string
                format: uri
              description: 最多 5 个公开 HTTP(S) MP4 或 MOV 参考视频 URL（每段 2–30 秒，总时长不超过 30 秒）。
            reference_audio_urls:
              type: array
              maxItems: 5
              items:
                type: string
                format: uri
              description: >-
                最多 5 个公开 HTTP(S) MP3 或 WAV 参考音频 URL（每段 2–30 秒，总时长不超过 30
                秒），支持单独传入。
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-example-001
            status:
              type: string
              example: not_started
            created_time:
              type: string
              format: date-time
              example: '2026-11-29T10:30:00'
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: 错误信息。参见[错误码](/zh/api-manual/error-codes)。
          example: prompt is required
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '使用 `Authorization: Bearer VIDGO_API_KEY`。'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.