> ## 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 根据单张首帧或首尾帧图片生成 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 视频，并同步生成对白、音效和环境音。输出画面自动匹配首帧宽高比。

如需纯文本生成，请使用 [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-reference-to-video.md)。

## 模型

* **sand-ai/magi-2/image-to-video** — 首帧与首尾帧 1080p 图生视频，4–30 秒，支持同步音频。

## 功能

* 支持单张首帧或首尾两帧控制（`image_urls` 传 `1–2` 张图片）。
* 单次生成 4–30 秒 1080p 视频。
* 自动跟随首帧宽高比。
* 同步生成对白、音效和环境音，可按需关闭音频。
* 提示词最长 15,000 个字符，并支持可选 `seed`。

## 必填参数

* `prompt` (string)：描述动作、运镜、剧情与声音，最多 15,000 个字符。对白请放在引号内。
* `image_urls` (string\[])：1 或 2 个公开可访问的 HTTP(S) 图片 URL（JPG、PNG 或 WEBP）。第 1 张为首帧，可选第 2 张为尾帧。

## 可选参数

* `duration` (integer)：视频时长（整秒），范围 `4` 到 `30`，默认 `5`。
* `resolution` (string)：固定 `1080p`。
* `aspect_ratio` (string)：仅支持 `auto`（默认），自动跟随首帧宽高比。
* `generate_audio` (boolean)：`true`（默认）生成同步音频；`false` 仅输出无声视频。
* `seed` (integer)：随机种子，`0` 到 `2147483647`。

## 输出

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

## 示例

* **首帧动画**：以单张起始帧生成 5 秒镜头运动与环境音。
* **首尾帧过渡**：在 6 秒内实现首帧到尾帧的自然运镜过渡。

## 注意事项

* `image_urls` 需传入 1 或 2 个公开可访问的 HTTP(S) URL；`aspect_ratio` 仅接受 `auto` 或省略。参考字段（`reference_*`）在本接口会返回 400。
* 积分按 `duration` 秒数计费（1080p），`generate_audio` 开关不改变价格。任务失败全额退还。当前价格见[定价页](https://vidgo.ai/apis/api-pricing)。


## OpenAPI

````yaml zh/api-manual/video-series/sand-ai-magi-2-image-to-video.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Vidgo API - MAGI-2 图生视频
  description: MAGI-2 图生视频 API 根据单张首帧或首尾帧图片生成 4–30 秒的 1080p 视频，自动跟随首帧比例并同步生成音频。
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境服务器
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - MAGI-2 Image to Video
      summary: 提交 MAGI-2 图生视频任务
      operationId: submitSandAiMagi2ImageToVideoTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              firstFrame:
                summary: 首帧动画
                value:
                  model: sand-ai/magi-2/image-to-video
                  input:
                    prompt: >-
                      Slow dolly-in as warm sunlight drifts across the table and
                      coffee steam rises gently.
                    image_urls:
                      - https://example.com/opening-frame.jpg
                    duration: 5
              firstLastFrame:
                summary: 首尾帧过渡
                value:
                  model: sand-ai/magi-2/image-to-video
                  input:
                    prompt: >-
                      Smooth camera orbit transitioning from day to golden
                      twilight.
                    image_urls:
                      - https://example.com/start.jpg
                      - https://example.com/end.jpg
                    duration: 6
                    aspect_ratio: auto
      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/image-to-video
        callback_url:
          type: string
          format: uri
          description: 可选的 Webhook URL，用于接收完成或失败通知。
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - prompt
            - image_urls
          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:
                - auto
              default: auto
              description: 自动跟随首帧宽高比，仅支持 auto。
            generate_audio:
              type: boolean
              default: true
              description: 是否同步生成音频，默认 true；false 仅输出无声视频。
            seed:
              type: integer
              minimum: 0
              maximum: 2147483647
              description: 可选随机种子，0 到 2147483647。
            image_urls:
              type: array
              minItems: 1
              maxItems: 2
              items:
                type: string
                format: uri
              description: 1 或 2 个公开 HTTP(S) 图片 URL（JPG、PNG 或 WEBP）：第 1 张为首帧，可选第 2 张为尾帧。
    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.