MAGI-2 video generation API

Use magi-2 to generate 1080p clips from 4 to 30 seconds with optional synced audio. The Playground supports text-to-video. Use the API for first and last frames and image, video, or audio references.

At a glance

model
magi-2
resolution
1080p only. Defaults to 1080p.
duration / seconds
4–30 whole seconds, default 5. Use a number or an integer string. Both fields must agree when supplied together.
aspect_ratio
Text and reference mode support 16:9 / 9:16 / 1:1 / 4:3 / 3:4 / 21:9 and default to 16:9. Omit it in frame mode to inherit the first frame's aspect ratio.
generate_audio
Boolean, defaults to true. Set false for silent output. The audio alias must agree when both are supplied.
Billing
The requested output seconds determine the upfront charge. At a 1× group rate of CNY 0.728/s, the default 5-second clip costs CNY 3.64. Successful jobs keep the charge and failed jobs refund it. See the marketplace for current pricing.

Setup steps

  1. 1

    Submit a text-to-video job

    Set the WANAPIS_API_KEY environment variable. Send POST /v1/video/generations with model and a nonempty prompt. Save data.task_id from the acknowledgement.

    cURL
    curl -fsS "https://api.wanapis.com/v1/video/generations" \
      -H "Authorization: Bearer $WANAPIS_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
      "model": "magi-2",
      "prompt": "A slow tracking shot of a paper boat drifting through a rain puddle",
      "resolution": "1080p",
      "duration": 5,
      "aspect_ratio": "16:9",
      "generate_audio": true
    }'
  2. 2

    Generate from a first frame or a pair of frames

    Use publicly downloadable image URLs. The first item in image_urls is the opening frame and the optional second item is the closing frame. You can also use first_frame_image and last_frame_image. Submit frame mode separately from reference mode.

    Frame request body (replace the file URLs)
    {
      "model": "magi-2",
      "prompt": "The paper boat drifts from the opening frame to the closing frame",
      "duration": 5,
      "image_urls": [
        "https://example.com/opening.jpg",
        "https://example.com/closing.jpg"
      ],
      "generate_audio": false
    }
  3. 3

    Add multimodal references

    Set omni_reference_task_type to reference to select reference mode. Use up to 10 images across image_urls and reference_image entries in image_with_roles, plus up to 5 clips each in video_urls and audio_urls. Provide publicly downloadable HTTPS URLs.

    Image, video and audio reference request (replace the file URLs)
    {
      "model": "magi-2",
      "prompt": "Keep the boat from the image and follow the camera motion and rhythm of the reference clips",
      "duration": 8,
      "aspect_ratio": "16:9",
      "omni_reference_task_type": "reference",
      "image_urls": [
        "https://example.com/boat.jpg"
      ],
      "video_urls": [
        "https://example.com/camera.mp4"
      ],
      "audio_urls": [
        "https://example.com/rain.mp3"
      ]
    }
  4. 4

    Poll the submitted task

    Replace TASK_ID with data.task_id from submission. Poll about every 5 seconds. Read data.result_url when data.status is SUCCESS, or data.fail_reason on FAILURE. Keep polling the same task ID while it runs.

    Check task status
    TASK_ID=task_example
    curl -fsS "https://api.wanapis.com/v1/video/generations/$TASK_ID" \
      -H "Authorization: Bearer $WANAPIS_API_KEY"
  5. 5

    Download the MP4

    After success, fetch data.result_url with the same Bearer API key used for submission. The example below downloads the file by task ID. Result URLs expire, so save the file promptly.

    Save the video
    curl -fsS "https://api.wanapis.com/v1/videos/$TASK_ID/content" \
      -H "Authorization: Bearer $WANAPIS_API_KEY" \
      -o magi-2.mp4

FAQ

Can I request 720p, auto duration, or fractional seconds?

MAGI-2 supports 1080p at 4–30 whole seconds. Omit the duration for a 5-second clip.

Why does opening a download link in my browser return 401?

The gateway download needs the task owner's Bearer API key or their signed-in console session. For scripts, send the key in the Authorization header.

Connect MAGI-2 to WanAPIs now

One API key for GPT, Claude, Gemini, DeepSeek, Kimi, GLM and more — pay only for the tokens you use.