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

# MAGI-2

> The MAGI-2 API generates a 4–30 second 1080p video with synchronized audio from text, first and last frames, or image, video and audio references.

> [!TIP]
>
> 1. After submission, a `task_id` will be returned. If you provided a `callback_url`, when the task status becomes `finished` or `failed`, a POST request will be sent to the `callback_url`.
> 2. Regardless of whether `callback_url` is provided, you can retrieve the response result through the unified [Query Task Status](https://docs.poyo.ai/api-manual/task-management/status.md) endpoint.

MAGI-2 is Sand AI's video generation model. It creates 1080p clips up to 30 seconds long with dialogue, sound effects and ambience generated together with the picture. It suits short dramas, ads, product shots and social clips that need long takes, spoken lines and consistent characters.

## Models

* **magi-2** - Text-to-video, first/last-frame and multimodal reference-to-video with synchronized audio

## Features

* 1080p video from 4 to 30 seconds in one generation
* Synchronized dialogue, sound effects and ambience
* Six aspect ratios: 16:9, 9:16, 1:1, 4:3, 3:4 and 21:9
* First-frame and first-and-last-frame control
* Up to 10 reference images, 5 reference videos and 5 reference audio clips in one task
* Prompts up to 15,000 characters for detailed scripts and shot lists

## Input modes

* **Text to video**: send `prompt` with the scene, motion, camera and sound.
* **First and last frames**: send one image in `image_urls` as the opening frame, or two images for the opening and closing frames. The video follows the aspect ratio of the first frame.
* **Reference to video**: send any combination of `reference_image_urls`, `reference_video_urls` and `reference_audio_urls`, including reference audio on its own, and describe in `prompt` how each reference is used.

## Required parameters

* `prompt` (string): Scene, subjects, motion, camera and sound, up to 15,000 characters. Put spoken lines in quotes.

## Optional parameters

* `duration` (integer): Length in whole seconds from `4` to `30`. Default `5`.
* `resolution` (string): `1080p`.
* `aspect_ratio` (string): `16:9` (default), `9:16`, `1:1`, `4:3`, `3:4` or `21:9` for text-to-video and reference-to-video; `auto` for first and last frames.
* `image_urls` (string\[]): One or two images: the opening frame and an optional closing frame. JPG, PNG or WEBP.
* `reference_image_urls` (string\[]): Up to 10 reference images.
* `reference_video_urls` (string\[]): Up to 5 MP4 or MOV videos, each 2–30 seconds and up to 30 seconds in total.
* `reference_audio_urls` (string\[]): Up to 5 MP3 or WAV clips, each 2–30 seconds and up to 30 seconds in total.
* `generate_audio` (boolean): `true` (default) generates synchronized audio; `false` returns a video-only file.
* `seed` (integer): Random seed from `0` to `2147483647`.

## Resolution

Every video is 1080p-class. The frame size follows the aspect ratio, for example 1920×1080 at 16:9, 1080×1920 at 9:16 and 2182×950 at 21:9.

## Output

A finished task returns one MP4 file: H.264 video at 25 fps with an AAC stereo audio track when `generate_audio` is `true`.

## Examples

* **Text to video with dialogue**: describe the scene and put the spoken line in quotes; the character speaks it in the generated audio.
* **First and last frames**: send the opening frame in `image_urls`, or add a second image to set the closing frame.
* **Reference to video**: send a character image and a music clip, then describe the new scene in `prompt`; the same character appears in the new setting and plays along with the music.

## Notes

* Use `image_urls` for first and last frames, or the `reference_*` fields for references; each task uses one of these two modes.
* All media URLs must be publicly accessible and directly downloadable.


## OpenAPI

````yaml api-manual/video-series/magi-2.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: PoYo AI - MAGI-2 API
  description: >-
    The MAGI-2 API generates a 4–30 second 1080p video with synchronized audio
    from text, first and last frames, or image, video and audio references.
  version: 1.0.0
servers:
  - url: https://api.poyo.ai
    description: Production server
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - MAGI-2
      summary: Submit a MAGI-2 video task
      operationId: submitMagi2Task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              text-to-video:
                summary: Text to video with dialogue
                value:
                  model: magi-2
                  input:
                    prompt: >-
                      In a rainy neon-lit Tokyo alley at night, an elderly
                      street musician plays a slow saxophone melody. The camera
                      slowly pushes in. He lowers the saxophone, smiles at the
                      camera and says: "Thanks for staying till the last song."
                      Rain patters on the wet pavement.
                    duration: 5
                    aspect_ratio: '16:9'
              first-last-frame:
                summary: First frame to video
                value:
                  model: magi-2
                  input:
                    prompt: >-
                      The pangolin rolls the paint roller down the windmill
                      sail, leaving a fresh coral stripe, while the sails begin
                      to turn in the breeze. Soft wind and birdsong.
                    image_urls:
                      - >-
                        https://storage.poyo.ai/models/magi-2/examples/first-frame-f29912c3eb5f.jpg
                    duration: 5
              reference-to-video:
                summary: Character image and audio references
                value:
                  model: magi-2
                  input:
                    prompt: >-
                      The elderly street musician from the reference image walks
                      along a sunlit seaside boardwalk in the morning, playing
                      the saxophone melody from the reference audio. Seagulls
                      glide overhead and gentle waves roll in. He stops, turns
                      to the camera and says: "Morning light suits this tune."
                    reference_image_urls:
                      - >-
                        https://storage.poyo.ai/models/magi-2/examples/reference-character-6586977013a0.jpg
                    reference_audio_urls:
                      - >-
                        https://storage.poyo.ai/models/magi-2/examples/reference-audio-5bf2add370f4.mp3
                    duration: 8
                    aspect_ratio: '16:9'
      responses:
        '200':
          description: Task submitted successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - Invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: false
      properties:
        model:
          type: string
          enum:
            - magi-2
          description: Public model identifier.
        callback_url:
          type: string
          format: uri
          description: Webhook URL for finished or failed task notifications.
        input:
          type: object
          additionalProperties: false
          required:
            - prompt
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 15000
              description: >-
                Describe the scene, subjects, motion, camera and sound. Put
                spoken lines in quotes. Up to 15,000 characters with
                non-whitespace text.
            duration:
              type: integer
              minimum: 4
              maximum: 30
              default: 5
              description: Video length in whole seconds, from 4 to 30. Default `5`.
            resolution:
              type: string
              enum:
                - 1080p
              default: 1080p
              description: Output resolution. `1080p`.
            aspect_ratio:
              type: string
              enum:
                - auto
                - '16:9'
                - '9:16'
                - '1:1'
                - '4:3'
                - '3:4'
                - '21:9'
              description: >-
                Video aspect ratio. Text-to-video and reference-to-video use
                `16:9` (default), `9:16`, `1:1`, `4:3`, `3:4` or `21:9`. With
                `image_urls`, the video follows the aspect ratio of the first
                frame; leave this field empty or send `auto`.
            image_urls:
              type: array
              minItems: 1
              maxItems: 2
              items:
                type: string
                format: uri
              description: >-
                First and last frame mode. The first image is the opening frame
                and an optional second image is the closing frame. JPG, PNG or
                WEBP. Each URL must be a publicly accessible HTTP or HTTPS link.
            reference_image_urls:
              type: array
              minItems: 1
              maxItems: 10
              items:
                type: string
                format: uri
              description: >-
                Reference mode. Up to 10 images for characters, objects, scenes
                or style. Each URL must be a publicly accessible HTTP or HTTPS
                link.
            reference_video_urls:
              type: array
              minItems: 1
              maxItems: 5
              items:
                type: string
                format: uri
              description: >-
                Reference mode. Up to 5 MP4 or MOV videos for motion, camera
                work or characters, each 2–30 seconds and up to 30 seconds in
                total. Each URL must be a publicly accessible HTTP or HTTPS
                link.
            reference_audio_urls:
              type: array
              minItems: 1
              maxItems: 5
              items:
                type: string
                format: uri
              description: >-
                Reference mode. Up to 5 MP3 or WAV clips for voice, music or
                rhythm, each 2–30 seconds and up to 30 seconds in total. Each
                URL must be a publicly accessible HTTP or HTTPS link.
            generate_audio:
              type: boolean
              default: true
              description: >-
                `true` (default) generates synchronized dialogue, sound effects
                and ambience; `false` returns a video-only file.
            seed:
              type: integer
              minimum: 0
              maximum: 2147483647
              description: >-
                Random seed from `0` to `2147483647`. Reuse a seed with the same
                inputs for similar results; leave it empty for a random seed.
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
          description: >-
            Business status code. `200` means success; any other value means the
            request failed. Always check this field: some validation errors
            return HTTP 200 with `code: 400` in the body.


            - `200`: Success

            - `400`: Invalid request parameters

            - `401`: Missing or invalid API key

            - `402`: Insufficient credits

            - `403`: Permission denied

            - `404`: Resource not found

            - `408`: Request timeout

            - `429`: Rate limit exceeded

            - `500`: Internal server error

            - `502`: Upstream service error

            - `503`: Service unavailable


            See [Error Codes](/api-manual/error-codes) for details.
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
            status:
              type: string
              enum:
                - not_started
                - running
                - finished
                - failed
              example: not_started
              description: >-
                Task status. Always `not_started` right after submission. Use
                [Query Task Status](/api-manual/task-management/status) or
                `callback_url` to get later states.


                - `not_started`: Queued, waiting to be processed

                - `running`: Being generated

                - `finished`: Completed; results are in `files` or `output`

                - `failed`: Failed; details are in `error_message`
            created_time:
              type: string
              format: date-time
    ErrorResponse:
      type: object
      required:
        - code
        - error
      properties:
        code:
          type: integer
          example: 400
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
          description: >-
            Business status code. `200` means success; any other value means the
            request failed. Always check this field: some validation errors
            return HTTP 200 with `code: 400` in the body.


            - `200`: Success

            - `400`: Invalid request parameters

            - `401`: Missing or invalid API key

            - `402`: Insufficient credits

            - `403`: Permission denied

            - `404`: Resource not found

            - `408`: Request timeout

            - `429`: Rate limit exceeded

            - `500`: Internal server error

            - `502`: Upstream service error

            - `503`: Service unavailable


            See [Error Codes](/api-manual/error-codes) for details.
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              example: Invalid request parameters
            type:
              type: string
              example: invalid_request_error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        All API endpoints require Bearer Token authentication.


        Create an API key: sign in to PoYo, open **Dashboard → API Key** at
        [poyo.ai/dashboard/api-key](https://poyo.ai/dashboard/api-key), and
        click to create a key.


        Add it to the request header:


        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````

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