# magi-2 (https://reapi.ai/docs/magi-2)

## Overview

MAGI-2 is Sand.ai's 480B native audio-video model. On reAPI it is exposed through three routes on the unified async video endpoint (`POST /api/v1/videos/generations`), selected by the `model` field:

| Model ID                    | Mode                                        | Required Input                                              |
| --------------------------- | ------------------------------------------- | ----------------------------------------------------------- |
| `magi-2-text-to-video`      | Text-to-Video                               | `prompt` (non-blank, up to 15,000 chars)                    |
| `magi-2-image-to-video`     | First / First-and-Last Frame Image-to-Video | `image_urls` (1–2 public HTTPS URLs)                        |
| `magi-2-reference-to-video` | Multimodal Reference-to-Video               | At least one of `image_urls`, `video_urls`, or `audio_urls` |

All three routes output 1080p MP4 video (4–30 seconds, integer) with optional synchronized dialogue, sound effects, and music (`generate_audio: true` by default).

## Endpoint & Authentication

* **Submit task:** `POST https://api.reapi.ai/v1/videos/generations`
* **Poll status:** `GET https://api.reapi.ai/v1/tasks/{task_id}`
* **Auth header:** `Authorization: Bearer YOUR_API_KEY`

## Request Parameters

| Parameter        | Type      | Default   | Description                                                                                                                                                                                                                     |
| ---------------- | --------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`          | string    | required  | One of `magi-2-text-to-video`, `magi-2-image-to-video`, or `magi-2-reference-to-video`.                                                                                                                                         |
| `prompt`         | string    | —         | Required for `magi-2-text-to-video`; optional for image-to-video and reference-to-video. Up to 15,000 characters; when provided it must not be blank.                                                                           |
| `image_urls`     | string\[] | —         | Public HTTPS image URLs (no base64 / `data:` URIs, under 30 MB each). `magi-2-image-to-video` accepts 1 image (first frame) or 2 images (first and last frames). `magi-2-reference-to-video` accepts up to 10 reference images. |
| `video_urls`     | string\[] | —         | `magi-2-reference-to-video` only. Up to 5 public HTTPS MP4/MOV reference videos (each up to 200 MB, 2–30 s; combined duration ≤ 30 s).                                                                                          |
| `audio_urls`     | string\[] | —         | `magi-2-reference-to-video` only. Up to 5 public HTTPS WAV/MP3 reference audio tracks (each up to 15 MB, 2–30 s; combined duration ≤ 30 s).                                                                                     |
| `duration`       | integer   | `5`       | Output clip duration in seconds, integer from `4` to `30`.                                                                                                                                                                      |
| `quality`        | string    | `"1080p"` | Output resolution (`"1080p"`).                                                                                                                                                                                                  |
| `aspect_ratio`   | string    | `"16:9"`  | One of `"16:9"`, `"9:16"`, `"1:1"`, `"4:3"`, `"3:4"`, `"21:9"`.                                                                                                                                                                 |
| `generate_audio` | boolean   | `true`    | Generate synchronized dialogue, sound effects, and music at no extra charge. Set `false` for silent video.                                                                                                                      |
| `seed`           | integer   | —         | Optional random seed (`0` to `4294967295`) for more repeatable runs.                                                                                                                                                            |

## Examples

### 1. Text-to-Video

```bash
curl -X POST https://api.reapi.ai/v1/videos/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2-text-to-video",
    "prompt": "A golden retriever runs across a sunny beach toward the camera, waves crashing behind it, cinematic, natural sound of waves and barking",
    "duration": 5,
    "quality": "1080p",
    "aspect_ratio": "16:9",
    "generate_audio": true
  }'
```

### 2. Image-to-Video (First / Last Frame)

```bash
curl -X POST https://api.reapi.ai/v1/videos/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2-image-to-video",
    "prompt": "The camera slowly pushes in as the subject comes to life with subtle natural motion",
    "image_urls": [
      "https://example.com/first-frame.jpg"
    ],
    "duration": 5,
    "quality": "1080p",
    "aspect_ratio": "16:9",
    "generate_audio": true
  }'
```

### 3. Reference-to-Video

```bash
curl -X POST https://api.reapi.ai/v1/videos/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2-reference-to-video",
    "prompt": "The same character from the reference image walks through a sunlit market, handheld tracking shot",
    "image_urls": [
      "https://example.com/character.jpg"
    ],
    "duration": 5,
    "quality": "1080p",
    "aspect_ratio": "16:9",
    "generate_audio": true
  }'
```

### 4. Poll Task Result

```bash
curl https://api.reapi.ai/v1/tasks/task_xxxxxxxx \
  -H "Authorization: Bearer YOUR_API_KEY"
```

When `status` reaches `completed`, the output MP4 URL is returned in `output.video_urls` (or `output.url`). Failed tasks are automatically refunded.

## Billing

All three MAGI-2 routes are billed per requested output second at 1080p (`duration` from 4 to 30 seconds). Reference images, reference videos, reference audio tracks, and synchronized output audio add no extra charge.

See current per-second rates and credit equivalents on the [MAGI-2 model page](/models/magi-2#pricing).
