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

# MAGI-2 参考生视频

> Sand AI MAGI-2 参考生视频支持最多 20 份图片、视频、音频混合参考（支持纯音频参考），单次生成 4-30 秒 1080p 原生有声视频。

> [!NOTE]
>
> `image_urls`（0–10，`<30 MB`）、`video_urls`（0–5 个 MP4，每段 2–30 秒且合计 ≤30 秒）、`audio_urls`（0–5，≤15 MB，每段 2–30 秒且合计 ≤30 秒，**允许仅提供音频参考**）合计须为 1–20 份公开 HTTPS 地址。提示词按顺序用 `@image_1`、`@video_1`、`@audio_1` 引用。按请求时长按秒统一计费，出片耗时约 **13–20 分钟**。


## OpenAPI

````yaml api-reference/openapi/magi-2--magi-2-r2v.zh.yaml POST /v1/videos/generations
openapi: 3.1.0
info:
  title: MAGI-2 参考生视频 API
  version: 1.0.0
  description: >-
    Sand AI MAGI-2 参考生视频支持最多 20 份图片/视频/音频混合参考（最多 10 张图、5 段视频、5 段音频，支持纯音频参考），单次生成
    4-30 秒 1080p 原生有声视频。在 APIPod 中，公开模型 ID 为 magi-2-r2v。
servers:
  - url: https://api.apipod.ai
    description: 生产环境
security: []
paths:
  /v1/videos/generations:
    post:
      tags:
        - MAGI-2 参考生视频
      summary: 创建视频生成任务
      description: >-
        Sand AI MAGI-2 参考生视频支持最多 20 份全模态参考素材（允许纯音频参考），提示词按顺序用
        @image_1、@video_1、@audio_1 引用。公开模型 ID 为 magi-2-r2v。
      operationId: create-magi-2-magi-2-r2v
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              title: MAGI-2 参考生视频
              properties:
                model:
                  type: string
                  title: 模型 ID
                  description: APIPod 公开模型 ID。
                  const: magi-2-r2v
                prompt:
                  type: string
                  title: 提示词
                  description: 必填，最多 8000 个字符；按顺序使用 @image_1、@video_1、@audio_1 引用素材。
                  minLength: 1
                  maxLength: 8000
                image_urls:
                  type: array
                  title: 参考图片
                  description: 可选，0-10 个公开 HTTPS 图片地址（单张 <30 MB）。三类参考合计须为 1-20 份。
                  items:
                    type: string
                    description: 公开 HTTPS 图片 URL。
                  maxItems: 10
                video_urls:
                  type: array
                  title: 参考视频
                  description: 可选，0-5 个公开 HTTPS MP4 视频地址（每段 2-30 秒，合计 <=30 秒）。
                  items:
                    type: string
                    description: 公开 HTTPS MP4 视频 URL。
                  maxItems: 5
                audio_urls:
                  type: array
                  title: 参考音频
                  description: 可选，0-5 个公开 HTTPS 音频地址（<=15 MB、每段 2-30 秒、合计 <=30 秒）；允许纯音频参考。
                  items:
                    type: string
                    description: 公开 HTTPS 音频 URL。
                  maxItems: 5
                duration:
                  type: integer
                  title: 时长（秒）
                  description: 输出视频秒数，取值 4-30，默认 5。
                  minimum: 4
                  maximum: 30
                  default: 5
                resolution:
                  type: string
                  title: 分辨率
                  description: 输出分辨率，仅支持 1080p。
                  enum:
                    - 1080p
                  default: 1080p
                aspect_ratio:
                  type: string
                  title: 画幅
                  description: 输出视频宽高比。
                  enum:
                    - '21:9'
                    - '16:9'
                    - '4:3'
                    - '1:1'
                    - '3:4'
                    - '9:16'
                  default: '16:9'
                generate_audio:
                  type: boolean
                  title: 生成音频
                  description: 是否随视频同步生成原生音频，默认 true。
                  default: true
                callback_url:
                  type: string
                  title: 回调地址
                  description: 可选，任务终态 Webhook 回调地址。
              required:
                - model
                - prompt
            example:
              model: magi-2-r2v
              prompt: >-
                @image_1 中的角色步入 @image_2 的花谷场景，运镜节奏参考 @video_1 并配合 @audio_1
                的氛围音乐。
              image_urls:
                - https://cdn.example.com/character.png
                - https://cdn.example.com/valley.png
              video_urls:
                - https://cdn.example.com/camera-ref.mp4
              audio_urls:
                - https://cdn.example.com/score.mp3
              duration: 15
              resolution: 1080p
              aspect_ratio: '16:9'
              generate_audio: true
      responses:
        '200':
          description: 任务已受理
          content:
            application/json:
              schema:
                type: object
                title: 任务提交响应
                properties:
                  code:
                    type: integer
                  data:
                    type: object
                    properties:
                      task_id:
                        type: string
                        description: 生成任务 ID
                  message:
                    type: string
                required:
                  - code
                  - message
                  - data
              example:
                code: 200
                message: success
                data:
                  task_id: vid_task_01JEXAMPLE
      security:
        - bearerAuth: []
      x-codeSamples:
        - lang: Shell
          label: cURL
          source: |-
            curl https://api.apipod.ai/v1/videos/generations \
              -H "Authorization: Bearer $APIPOD_API_KEY" \
              -H "Content-Type: application/json" \
              -d '{
              "model": "magi-2-r2v",
              "prompt": "@image_1 中的角色步入 @image_2 的花谷场景，运镜节奏参考 @video_1 并配合 @audio_1 的氛围音乐。",
              "image_urls": [
                "https://cdn.example.com/character.png",
                "https://cdn.example.com/valley.png"
              ],
              "video_urls": ["https://cdn.example.com/camera-ref.mp4"],
              "audio_urls": ["https://cdn.example.com/score.mp3"],
              "duration": 15,
              "resolution": "1080p",
              "aspect_ratio": "16:9",
              "generate_audio": true
            }'
        - lang: Python
          label: Python
          source: |-
            import os import requests
            response = requests.post(
                "https://api.apipod.ai/v1/videos/generations",
                headers={
                    "Authorization": f"Bearer {os.environ['APIPOD_API_KEY']}",
                    "Content-Type": "application/json",
                },
                json={
                    "model": "magi-2-r2v",
                    "prompt": "@image_1 中的角色步入 @image_2 的花谷场景。",
                    "image_urls": [
                        "https://cdn.example.com/character.png",
                        "https://cdn.example.com/valley.png",
                    ],
                    "duration": 15,
                    "resolution": "1080p",
                    "aspect_ratio": "16:9",
                    "generate_audio": True,
                },
                timeout=60,
            ) response.raise_for_status() print(response.json())
        - lang: JavaScript
          label: Node.js
          source: >-
            const response = await
            fetch("https://api.apipod.ai/v1/videos/generations", {
              method: "POST",
              headers: {
                Authorization: `Bearer ${process.env.APIPOD_API_KEY}`,
                "Content-Type": "application/json",
              },
              body: JSON.stringify({
                model: "magi-2-r2v",
                prompt: "@image_1 中的角色步入 @image_2 的花谷场景。",
                image_urls: [
                  "https://cdn.example.com/character.png",
                  "https://cdn.example.com/valley.png",
                ],
                duration: 15,
                resolution: "1080p",
                aspect_ratio: "16:9",
                generate_audio: true,
              }),
            });

            if (!response.ok) {
              throw new Error(`APIPod request failed: ${response.status} ${await response.text()}`);
            }

            console.log(await response.json());
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: APIPod API key
      description: 在 Authorization 请求头中以 Bearer Token 形式携带您的 APIPod API Key。

````

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