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

# MAGI-2 Reference to Video

> MAGI-2 reference-to-video: a 4–30 second 1080p video with sound guided by reference images, videos and audio, keeping the look, motion and voice of the references.

MAGI-2 is the video generation model Sand AI (sand.ai) released on November 24, 2026. It generates 1080p video together with synchronized sound — dialogue, sound effects and ambience — in a single pass, 4 to 30 seconds per video.

`magi-2/reference-to-video` generates a video from reference material: `reference_image_urls` give the look of people, products and scenes (up to 10), `reference_video_urls` the motion and camera work (up to 5) and `reference_audio_urls` a voice or sound (up to 5). Provide at least one kind; the prompt can say what each reference is for.

## Setup

The MAGI-2 models use an asynchronous task API: `POST /api/v1/jobs/createTask` creates a task (`model` selects the model and the parameters go in `input`), `GET /api/v1/jobs/recordInfo?taskId=` queries it, and with `callBackUrl` the result is pushed to that URL when the task finishes. The base URL is `https://api.dreamto.ai`; send the API Key in the `Authorization: Bearer` header.

Every response has HTTP status 200; the `code` in the body tells the outcome: `200` is success, anything else an error (see the response examples of each endpoint).

| Endpoint | Purpose |
| - | - |
| [`POST /api/v1/jobs/createTask`](https://docs.dreamto.ai/en/api-reference/magi-2-reference-to-video/create-task) | Create task |
| [`GET /api/v1/jobs/recordInfo?taskId=...`](https://docs.dreamto.ai/en/api-reference/magi-2-reference-to-video/query-task) | Get task |
| [`POST callBackUrl`](https://docs.dreamto.ai/en/api-reference/magi-2-reference-to-video/task-callback) | Task callback |

## Parameters

`model` is `magi-2/reference-to-video`; the generation parameters go in `input`. Requests out of range return `code: 422`; no task is created or charged.

| Field | Values |
| - | - |
| `prompt` | Required, 1–15,000 characters; describe the subject, action, camera movement and sound, with dialogue in quotes |
| `reference_image_urls` | Optional, up to 10 reference images, JPG / PNG / WEBP |
| `reference_video_urls` | Optional, up to 5 reference videos, MP4 / MOV, 2–30 seconds each and 30 seconds in total |
| `reference_audio_urls` | Optional, up to 5 reference audio clips, MP3 / WAV, 2–30 seconds each and 30 seconds in total |
| `duration` | Optional integer from `4` to `30` seconds; default `5` |
| `aspect_ratio` | Optional: `21:9` / `16:9` / `4:3` / `1:1` / `3:4` / `9:16`; default `16:9` |
| `resolution` | Optional: `1080p` only (default) |
| `generate_audio` | `true` (default: dialogue, sound effects and ambience generated with the picture) / `false` (silent video); same price |
| `seed` | Optional, `0`–`2147483647`; random when omitted |

## Pricing

Billed per second of generated video; the model price in the console is authoritative:

| Resolution | Price (with or without sound) |
| - | - |
| `1080p` | \$0.08 / second |

Cost of a task = $0.08 × `duration` (5 seconds when omitted), e.g. $0.40 for 5 seconds and \$2.40 for 30 seconds. `generate_audio` and reference material do not change the price. The balance is checked for the request's cost when the task is created (`code: 402` when insufficient); invalid requests and failed tasks are not charged.

## Quick start

Create a task to get `data.taskId`, poll about every 10 seconds, and download `response.resultUrls` once `state` is `success`; or pass `callBackUrl` to be called back when the task finishes. `$DREAMTO_API_KEY` is your API Key.

```bash cURL theme={null}
# 1. Create the task
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
    }
  }'

# 2. Query the task
curl "https://api.dreamto.ai/api/v1/jobs/recordInfo?taskId=4b9e2d7a0c1f48e6a3d5b7c9e1f20a84" \
  -H "Authorization: Bearer $DREAMTO_API_KEY"
```

```python Python theme={null}
import os
import time

import requests

BASE_URL = "https://api.dreamto.ai"
HEADERS = {"Authorization": f"Bearer {os.environ['DREAMTO_API_KEY']}"}

payload = {
    "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
    }
}

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"])
```

## Prompt tips

* Describe the subject, action, camera movement and sound, e.g. "the camera slowly rises from below", "Sound: howling sea wind".
* Put dialogue in quotes and say who speaks it, e.g. He says quietly: "The wind is strong tonight."
* For longer videos, write what happens in order over time.
* Pass `generate_audio: false` when you need no sound; the price is the same.

## Callback

Pass `callBackUrl` (a public `http` / `https` URL) when creating the task; when the task succeeds or fails DreamTo `POST`s the result there once: the outer `code` is `200` (success) or `501` (failure) and `data` is the same as the `data` of the query endpoint. The request carries `X-DreamTo-Event: task.completed`, `X-DreamTo-Timestamp` (UTC, RFC 3339) and `X-DreamTo-Signature`:

```
X-DreamTo-Signature = hex( HMAC-SHA256( secret, X-DreamTo-Timestamp + "." + data.taskId + "." + status ) )
```

`status` is `success` when the task succeeded and `failed` when it failed (not the `fail` of `data.state`). Generate the secret under Webhook signing secret on the API Key page of the console; without a secret `X-DreamTo-Signature` is not sent. The callback times out after 10 seconds and any `2xx` counts as delivered; otherwise it is retried after 1, 5 and 30 minutes, at most 4 deliveries, so handle it idempotently by `data.taskId`. See [Task callback](https://docs.dreamto.ai/en/webhooks/task-callback.md) for secret management and verification code.

## Notes

* Pass at least one of `reference_image_urls`, `reference_video_urls` and `reference_audio_urls`; with none the request returns `code: 422`.
* The model service checks the duration and format of reference videos and audio; a task that breaks the limits fails (not charged) with the reason in `failMsg`.
* `taskId` is issued by DreamTo (32 hex digits) and can only be queried with an API Key of the same account; an unknown or expired task returns `code: 422` with `msg: recordInfo is null`.
* 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`; no task is created or charged.
* Video links (`response.resultUrls`, the same as in `resultJson`) are DreamTo download links (`/v1/tasks/{task_id}/artifacts/...`) that work without an API Key and support `Range`; they stay valid for about 14 days after the task is created, so download and keep the videos promptly.
* `param` echoes the create request, with `input` as a JSON string that needs a second parse; `creditsConsumed` is not returned, and the charge is shown in the DreamTo console bills.
* `failCode` / `failMsg` of a failed task come from the model service (an image that cannot be downloaded, content moderation and so on); internal errors are reported as `failCode: "500"` with `failMsg: "Internal Error, Please try again later."`.


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