Skip to content

MAGI-2 Video Generation

Generate video from text, first and last frames, or image, video and audio references. Fixed 1080p output, 4–30 seconds, with audio enabled by default.

All documentation
POST/v1/videos/generations

MAGI-2 is a video generation model from Sand AI. Submit to POST /v1/videos/generations, read data[0].task_id, then use the task status API to retrieve the result.

Authorization string required

Use Authorization: Bearer <token>, where <token> is your Openrouter API key.

Request examples

curl --request POST \
  --url https://openrouterapi.ru/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "magi-2",
  "prompt": "A red paper boat drifts along a gutter on a rainy night, macro camera, with the sound of rain",
  "duration": 5,
  "aspect_ratio": "9:16",
  "generate_audio": true,
  "nsfw_check": true
}'

Generation modes

ModeHow to submit
Text-to-videoProvide prompt without image, video or audio inputs.
Image-to-videoUse image_urls for the first frame and optional last frame, or use the dedicated frame fields.
Reference-to-videovideo_urls, audio_urls, or images with role: "reference_image" automatically select reference mode. With only image_urls, explicitly set omni_reference_task_type: "reference" to treat them as references.

The input materials determine the mode first. Automatically selected reference mode behaves the same as explicit reference. In reference mode, all images are references; images in image_urls and entries with role: "reference_image" in image_with_roles share a combined limit of 10 images.

The reference examples explicitly set omni_reference_task_type: "reference". Describe the purpose of each input in the prompt. References guide generation; source videos are not spliced into the output and source audio is not preserved verbatim.

Request parameters

modelstringrequired

magi-2

nsfw_checkbooleandefault: false

Whether to run content moderation before submitting the video task.

  • true: use omni-moderation-latest to review prompts and input images
  • false or omitted: do not send a moderation request, adding no moderation cost or latency (default)
promptstringrequired

Required in all three modes, up to 15,000 characters. Describe the scene, action, camera and sound; put spoken dialogue in quotation marks.

durationintegerdefault: 5

Whole seconds from 4 to 30, default 5. Explicit 0, fractional values and out-of-range values return HTTP 400. Omit this field to use the default.

secondsinteger

Alias for duration. If both are sent, their values must match.

resolutionstringdefault: 1080p

Only 1080p is supported; omitting the field also produces 1080p. Other values return HTTP 400.

aspect_ratiostring

Text-to-video and reference-to-video support 16:9 (default), 9:16, 1:1, 4:3, 3:4 and 21:9. Image-to-video supports the first five ratios, excluding 21:9; omit the field or use auto to follow the first frame’s aspect ratio. Output resolution remains 1080p.

generate_audiobooleandefault: true

Whether to generate audio, default true. Set to false for output without an audio track. If audio is also sent, the values must match.

audioboolean

Alias for generate_audio; the values must not conflict. Send reference audio through audio_urls.

seedinteger

An integer from 0 to 2147483647. Omit it or send -1 for a random seed. A fixed seed can make results with identical parameters more similar, but does not guarantee identical output.

omni_reference_task_typestringdefault: auto

Supports auto (default) and reference. Explicitly set reference when using multiple image_urls as reference images. edit and extend are unsupported.

image_urlsstring[]

Each item must be a public HTTP(S) image URL. The 2-image limit applies only to image-to-video: the first frame and optional last frame. This mode applies when only images are supplied, with no reference video or audio, no explicit reference, and no reference_image role. In reference mode, this entire array contains references and shares a combined limit of 10 with reference_image entries in image_with_roles, whether the mode is selected automatically or explicitly.

first_frame_imagestring

Public HTTP(S) URL of the first frame. Choose either the dedicated frame fields or image_urls.

last_frame_imagestring

Optional public HTTP(S) URL of the last frame, used together with a first frame. Choose either the dedicated frame fields or image_urls.

image_with_rolesobject[]

Each item contains url (a public HTTP(S) image URL) and role: first_frame, last_frame or reference_image. Image-to-video allows at most one first frame and one last frame. The reference_image role selects reference mode; these images and those in image_urls share a combined limit of 10.

video_urlsstring[]

Up to 5 reference videos, each 2–30 seconds, with a combined duration of at most 30 seconds recommended; the model may truncate excess duration. Use an array of public HTTP(S) URLs. The singular video_url field is unsupported.

audio_urlsstring[]

Up to 5 reference audio clips, each 2–30 seconds, with a combined duration of at most 30 seconds recommended; the model may truncate excess duration. Each item must be a public HTTP(S) URL.

Input requirements

All inputs must use publicly accessible direct HTTP(S) URLs. Login requirements, hotlink protection or download failures can cause the task to fail. For local files, first use image upload, video upload or audio upload to obtain a URL.

Request examples

First and last frames

json
{
  "model": "magi-2",
  "prompt": "The girl slowly turns and smoothly transitions to the pose in the last frame, with soft lighting",
  "image_urls": [
    "https://example.com/start.jpg",
    "https://example.com/end.jpg"
  ],
  "duration": 5
}

With one image, only a first frame is supplied. Omitting aspect_ratio follows its aspect ratio. You may use first_frame_image and last_frame_image instead of the example’s image_urls.

Image-only references

json
{
  "model": "magi-2",
  "prompt": "The characters from both reference images meet in the same garden, preserving their distinctive appearances",
  "image_urls": [
    "https://example.com/reference-1.jpg"
  ],
  "image_with_roles": [
    {
      "url": "https://example.com/reference-2.jpg",
      "role": "reference_image"
    }
  ],
  "omni_reference_task_type": "reference",
  "aspect_ratio": "16:9",
  "duration": 5
}

Mixed image, video and audio references

json
{
  "model": "magi-2",
  "prompt": "Use the reference video’s camera movement, the girl’s appearance from the image and the musical style of the audio to show her walking on a beach at sunset",
  "image_urls": [
    "https://example.com/girl.jpg"
  ],
  "video_urls": [
    "https://example.com/camera.mp4"
  ],
  "audio_urls": [
    "https://example.com/bgm.mp3"
  ],
  "omni_reference_task_type": "reference",
  "aspect_ratio": "16:9",
  "duration": 8
}

Task polling and results

Poll the task status API until completed or failed. Generation usually takes several minutes and may take longer under load. A fixed waiting period alone does not mean the task failed. Stopping polling does not cancel the task.

bash
curl --request GET \
  --url 'https://openrouterapi.ru/v1/tasks/task_example_magi2' \
  --header 'Authorization: Bearer <token>'
FieldDescription
data.statuspending / processing: in progress; completed: success; failed: failure.
data.progressProgress from 0 to 100.
data.result.videos[0].urlOutput video download URL stored on the platform; see the task API for the full result structure.
data.error.messageFailure details when the task fails.

Unsupported features

The following return HTTP 400 on submission: mode, negative_prompt, watermark: true, camera_control, multi_shot / multi_prompt, element_list, video_list, voice_list, audio_setting, intermediate keyframe inputs, omni_reference_task_type: "edit" / "extend", singular video_url, and any resolution other than 1080p. Video editing and extension are not available.

Common errors

For submission failures, read error.message. For failures after task creation, read data.error.message from the task status response.

Error message or scenarioAction
duration must be between 4 and 30 whole secondsUse whole seconds from 4 to 30; omission defaults to 5.
duration (5) and seconds (6) are aliases and must matchUse matching duration aliases, or send only one.
requires promptProvide a prompt in all three modes.
image_urls takes at most 2 imagesUse at most two frame images; explicitly set reference for image-only references.
image-to-video only supports aspect_ratioRemove 21:9 for image-to-video; omit the ratio or use auto to follow the first frame.
accepts at most 10 reference images / 5 videos / 5 audiosUse at most 10 reference images, 5 videos and 5 audio clips.
has no video edit / extend / does not support keyframesRemove editing, extension and intermediate-frame parameters; use video_urls for reference videos.
always outputs 1080pSend only 1080p, or omit resolution.
audio (true) and generate_audio (false) are aliases and must matchUse matching audio switches, or send only one.
Could not download the input...Use public URLs that can be downloaded directly, then resubmit.

Responses

{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_example_magi2"
    }
  ]
}

Found a problem in these docs? Email support@openrouterapi.ru.