Model insights

MAGI-2 API guide: text, image and reference to video

How to call MAGI-2 on DreamTo: three model IDs for text, image and reference to video, 4 to 30 seconds at 1080p with sound, with requests, limits and price.

An open hand with a small swirling galaxy of paint hovering above the palm
On this page

MAGI-2 turns a prompt, a first frame or a set of references into a 1080p video that already has its sound: dialogue, sound effects and ambience are generated in the same pass as the picture. A video runs from 4 to 30 seconds. On DreamTo it is three model IDs on one asynchronous task API, called with one API key.

This guide covers what each model accepts, the documented limits, a complete request for each, and how to collect results. Everything in it comes from our model catalog and API docs.

What MAGI-2 is#

MAGI-2 is a video generation model from Sand AI, released on November 24, 2026 according to our API docs. The catalog describes it as a 480B-parameter MoE model that renders picture and sound in one pass, with output at 1080p and 25 fps in six aspect ratios.

You direct the sound from the prompt: describe the sounds and put dialogue in quotes, and the model renders lip-synced dialogue, foley and ambience with the picture. Setting generate_audio to false gives a silent video at the same price.

Three model IDs on one task API#

POST /api/v1/jobs/createTask creates a task from a model and an input object. GET /api/v1/jobs/recordInfo?taskId=... returns its state and result, or you pass callBackUrl and the result is pushed to that URL when the task finishes. The base URL is https://api.dreamto.ai and the API key goes in the Authorization: Bearer header. The authentication page explains how to create a key and where to keep it.

Model IDStarts fromAspect ratioPage
magi-2/text-to-videoA promptaspect_ratio, six valuesModel page · Playground
magi-2/image-to-videoA first frame, optionally a last frameFollows the first-frame imageModel page · Playground
magi-2/reference-to-videoReference images, videos and audioaspect_ratio, six valuesModel page · Playground

Each model has its own docs page: text to video, image to video and reference to video.

Parameters shared by all three#

FieldValues
promptRequired, 1 to 15,000 characters. Describe subject, action, camera movement and sound; put dialogue in quotes.
durationOptional integer from 4 to 30 seconds. Default 5.
resolutionOptional. 1080p is the only value and the default.
generate_audiotrue (default) or false for a silent video. Same price either way.
seedOptional, 0 to 2147483647. Random when omitted.

Text to video and reference to video also take aspect_ratio: 21:9, 16:9, 4:3, 1:1, 3:4 or 9:16, defaulting to 16:9. Image to video does not; passing it returns code: 422, because the first-frame image sets the ratio.

First request: text to video#

Only prompt is required. The request below is the docs' own example, with the optional fields written out at their defaults: 5 seconds, 16:9, 1080p, sound on. Its prompt has the shape the docs suggest: subject and action, one camera move, a quoted line of dialogue with its speaker, and a sound note.

bash
curl -X POST "https://api.dreamto.ai/api/v1/jobs/createTask" \  -H "Authorization: Bearer $DREAMTO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "magi-2/text-to-video",    "input": {      "prompt": "At dusk an old lighthouse keeper climbs the spiral stairs while the camera slowly rises behind him from below. He stops at the window and says quietly: \"The wind is strong tonight.\" Sound: howling sea wind and creaking wooden stairs",      "duration": 5,      "aspect_ratio": "16:9",      "resolution": "1080p",      "generate_audio": true    }  }'

Every response has HTTP status 200, and the code in the body is the outcome. With code 200 the task was created and data.taskId is its ID. Any other code is an error, with the reason in msg and data set to null:

codeMeaning
401The API key is missing or invalid
402The balance does not cover the cost of the request
422The request is invalid; no task is created or charged
429The rate limit was exceeded
500Server error

Polling the task#

Poll recordInfo about every 10 seconds. state is waiting or generating while the task runs and ends as success or fail. The docs say generation usually takes one to a few minutes, longer for long videos. This Python script creates the task and polls it:

python
import osimport timeimport requestsBASE_URL = "https://api.dreamto.ai"HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}payload = {    "model": "magi-2/text-to-video",    "input": {        "prompt": "At dusk an old lighthouse keeper climbs the spiral stairs while the camera slowly rises behind him from below. He stops at the window and says quietly: \"The wind is strong tonight.\" Sound: howling sea wind and creaking wooden stairs",        "duration": 5,        "aspect_ratio": "16:9",        "resolution": "1080p",        "generate_audio": True    }}created = requests.post(f"{BASE_URL}/api/v1/jobs/createTask", headers=HEADERS, json=payload, timeout=60).json()if created["code"] != 200:    raise SystemExit(f"{created['code']}: {created['msg']}")task_id = created["data"]["taskId"]while True:    record = requests.get(f"{BASE_URL}/api/v1/jobs/recordInfo", headers=HEADERS, params={"taskId": task_id}, timeout=60).json()["data"]    if record["state"] in ("success", "fail"):        break    time.sleep(10)if record["state"] == "success":    print(record["response"]["resultUrls"])else:    print(record["failCode"], record["failMsg"])

On success, response.resultUrls holds the video links. On failure, failCode and failMsg carry the reason from the model service, such as an image that could not be downloaded or a content moderation result.

First request: image to video#

Image to video requires first_frame_url, uses that image as the first frame and takes the output aspect ratio from it. Add last_frame_url and the video ends on that image, which the docs say suits transitions and changes of state. Both must be public http(s) URLs of JPG, PNG or WEBP images.

This is the docs' first-and-last-frame example: 8 seconds, a fixed seed, and a callBackUrl for the completion callback. resolution and generate_audio are left out, so they take their defaults.

bash
curl -X POST "https://api.dreamto.ai/api/v1/jobs/createTask" \  -H "Authorization: Bearer $DREAMTO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "magi-2/image-to-video",    "callBackUrl": "https://your-domain.com/api/callback",    "input": {      "first_frame_url": "https://cdn.example.com/street-day.jpg",      "last_frame_url": "https://cdn.example.com/street-night.jpg",      "prompt": "The street slowly turns from day to night as the streetlights come on one by one; the camera stays still. Sound: fading traffic and a distant dog barking",      "duration": 8,      "seed": 42    }  }'

Replace the three URLs with your own. callBackUrl sits next to model, not inside input; leave it out if you poll. Leave out last_frame_url to fix only the first frame. The polling script above works here once you swap in this model and input.

Image to video has no reference fields: the catalog states that frames cannot be combined with general references, which belong to reference to video. For first and last frames in other video models on DreamTo, see the image-to-video API guide.

First request: reference to video#

Reference to video is the model for carrying something over from existing material: a person, a product, a scene, a motion or a voice. You pass up to three kinds of reference, and the prompt can say what each one is for.

FieldLimit
reference_image_urlsUp to 10 images, JPG / PNG / WEBP
reference_video_urlsUp to 5 videos, MP4 / MOV, 2 to 30 seconds each and 30 seconds in total
reference_audio_urlsUp to 5 clips, MP3 / WAV, 2 to 30 seconds each and 30 seconds in total

At least one of the three is required; with none, the request returns code: 422. The docs give each kind a role: images supply the look of people, products and scenes, videos the motion and camera work, audio a voice or a sound. The docs' example below pairs one image for the lead with one audio clip for her voice.

bash
curl -X POST "https://api.dreamto.ai/api/v1/jobs/createTask" \  -H "Authorization: Bearer $DREAMTO_API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "magi-2/reference-to-video",    "input": {      "prompt": "Use the woman in the reference image as the lead. She stands on a rooftop after the rain, turns to the camera and says: \"We finally made it.\" Her voice follows the reference audio",      "reference_image_urls": [        "https://cdn.example.com/lead.jpg"      ],      "reference_audio_urls": [        "https://cdn.example.com/voice.wav"      ],      "duration": 5,      "aspect_ratio": "16:9",      "resolution": "1080p",      "generate_audio": true    }  }'

The model service checks the duration and format of reference videos and audio. A task that breaks those limits fails with the reason in failMsg. It is not charged, but the failure only shows up after the task is created, so check clip lengths and formats before you submit.

Writing prompts that use the sound#

The prompt can be up to 15,000 characters long, and the docs' advice on it is brief. Describe the subject, the action, the camera movement and the sound. Put dialogue in quotes and say who speaks it. For longer videos, write what happens in order over time.

The catalog's highlights and tips for MAGI-2 add four habits:

  • Organize a multi-shot prompt as ordered beats, and give each one its framing, its main action and its audio cue.
  • Tie each sound to a visible action, location or actor, and say which sounds stay underneath the scene.
  • When you review a result, look at the cuts first: eyelines, direction of travel and prop positions on either side.
  • With references, start with only the sources that define the actor and the action. Add setting or sound references one at a time, so you can trace where a result diverges.

Here is a prompt written that way for text to video:

text
Wide shot of a night market stall: a vendor tosses noodles in a wok as flames rise, the wok hissing over the murmur of the crowd. Cut to a close-up of a customer's hands taking the bowl, chopsticks clicking against the rim. Cut to a medium shot of the customer, who says: "That smells incredible." A scooter passes behind her, its engine fading.

It has three beats. Each one names a framing and a visible action, and each sound is attached to the thing that makes it instead of sitting in one line at the end.

Pricing and limits#

All three models are billed per second of generated video. As of December 2026 the list price is $0.08 per second at 1080p for each of them; generate_audio and reference material do not change it. A task costs $0.08 times its duration: $0.40 for 5 seconds, $0.64 for the 8-second request above, $2.40 for 30 seconds. Current prices and any discounts are on the prices page.

The balance is checked against the cost of the request when the task is created, and an insufficient balance returns code: 402. Invalid requests and failed tasks are not charged.

Other documented behavior to build around:

  • The body accepts only model, callBackUrl and input. Undeclared input fields, wrong types and out-of-range values return code: 422 with an English reason in msg.
  • Result links work without an API key and support Range. They stay valid for about 14 days after the task is created, so download and store videos promptly.
  • param in the query response echoes the create request, with input as a JSON string that needs a second parse.
  • creditsConsumed is not returned. The charge appears in your bills in the DreamTo console.
  • A task can be queried only with an API key of the same account. An unknown or expired task returns code: 422 with msg: recordInfo is null.

Webhooks instead of polling#

Pass callBackUrl (a public http or https URL) when you create the task, as in the image-to-video request above. When the task succeeds or fails, DreamTo sends one POST to that URL. The outer code is 200 for success or 501 for failure, and data is the same as the data of recordInfo.

The request carries X-DreamTo-Event: task.completed, X-DreamTo-Timestamp and X-DreamTo-Signature. The signature is sent only after you generate a webhook signing secret on the API Key page of the console. It is the hex HMAC-SHA256, keyed with that secret, of three values joined by dots: the X-DreamTo-Timestamp value, data.taskId and a status. The status is success for a succeeded task and failed for a failed one, not the fail that data.state uses.

The callback times out after 10 seconds and any 2xx counts as delivered. Otherwise it is retried after 1, 5 and 30 minutes, 4 deliveries at most, so handle callbacks idempotently by data.taskId.

Secret management and sample verification code are on the task callback page. Its samples read taskId and status from the top level of a different callback body, so adapt them: for MAGI-2 the task ID is data.taskId.

Choosing between the three#

Use text to video when you have a scene in words and no source material. Use image to video when a particular image has to be the first frame, and add a last frame when the video must end on a set composition. Use reference to video when a person, a product, a motion or a voice has to come from existing material.

To weigh MAGI-2 against other video models, see the comparison of six AI video APIs, which sets out their inputs, limits and prices. The rest of the catalog is under all models.

FAQ#

How long can a MAGI-2 video be?#

From 4 to 30 seconds, set with the integer duration field. The default is 5 seconds, and the range is the same for all three models.

Does MAGI-2 generate audio?#

Yes. By default it generates dialogue, sound effects and ambience together with the picture in a single pass. Set generate_audio to false for a silent video. The price is the same either way.

What resolution and aspect ratios does MAGI-2 support?#

Output is 1080p only. Text to video and reference to video accept 21:9, 16:9, 4:3, 1:1, 3:4 and 9:16, with 16:9 as the default. Image to video follows the aspect ratio of the first-frame image and returns code: 422 if you pass aspect_ratio.

How much does the MAGI-2 API cost?#

As of December 2026 the list price is $0.08 per second of generated video, the same for all three models and with or without sound. Failed tasks and invalid requests are not charged. See the prices page for current figures.

How many reference files can I send?#

Reference to video takes up to 10 images, 5 videos and 5 audio clips, and needs at least one reference. Each video or audio clip must be 2 to 30 seconds long, with 30 seconds in total per kind. Images are JPG, PNG or WEBP, videos MP4 or MOV, audio MP3 or WAV.

About 14 days from the time the task is created. The links work without an API key and support Range. Download and store your videos soon after they finish.

  • MAGI-2
  • Video API