# MAGI-2

MAGI-2 is Sand.ai's 480B native audio-video model. On SeedRouter it is served through three public model IDs on the unified asynchronous video endpoint (`POST /v1/videos/generations`), with task polling at `GET /v1/tasks/{id}`.

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

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

## Endpoints & Authentication

* **Submit task:** `POST https://api.seedrouter.ai/v1/videos/generations`
* **Poll task status:** `GET https://api.seedrouter.ai/v1/tasks/{id}`
* **Authentication:** `Authorization: Bearer YOUR_API_KEY`
* **Content-Type:** `application/json`

## Request Parameters

Unknown fields are rejected with HTTP `400` (`invalid_request_error`).

| Parameter        | Type      | Default   | Constraints & Description                                                                                                                                                                                                                                            |
| ---------------- | --------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model`          | string    | required  | `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. When provided, must be non-blank and at most 15,000 characters.                                                                                                             |
| `image_urls`     | string\[] | —         | Public HTTP/HTTPS image URLs (no base64 or `data:` URIs, under 30 MB each). Not accepted on `magi-2-text-to-video`. `magi-2-image-to-video` requires 1 image (first frame) or 2 images (first and last frames). `magi-2-reference-to-video` accepts up to 10 images. |
| `video_urls`     | string\[] | —         | `magi-2-reference-to-video` only. Up to 5 public HTTP/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 HTTP/HTTPS WAV/MP3 reference audio tracks (each up to 15 MB, 2–30 s; combined duration ≤ 30 s).                                                                                                                     |
| `duration`       | integer   | `5`       | Requested output length in seconds, integer from `4` to `30`.                                                                                                                                                                                                        |
| `quality`        | string    | `"1080p"` | Output resolution. Currently `"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 repeatable runs.                                                                                                                                                                                                      |

## Examples

### 1. Text-to-Video

```bash
curl -X POST https://api.seedrouter.ai/v1/videos/generations \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2-text-to-video",
    "prompt": "Continuous 5-second tracking shot through a rainy Tokyo alley at dusk, neon reflections on wet asphalt, distant train rumble and footsteps",
    "duration": 5,
    "quality": "1080p",
    "aspect_ratio": "16:9",
    "generate_audio": true
  }'
```

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

```bash
curl -X POST https://api.seedrouter.ai/v1/videos/generations \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2-image-to-video",
    "prompt": "The camera slowly pushes in as subtle natural motion brings the frame to life",
    "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.seedrouter.ai/v1/videos/generations \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2-reference-to-video",
    "prompt": "The same character walks through a sunlit street 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.seedrouter.ai/v1/tasks/task_xxxxxxxx \
  -H "Authorization: Bearer $SEEDROUTER_API_KEY"
```

Submission returns:

```json
{
  "id": "task_xxxxxxxx",
  "model": "magi-2-text-to-video",
  "status": "processing",
  "created_at": 1764120000
}
```

When polling reaches `"status": "completed"`, the delivered MP4 URL is in `output.video_url`:

```json
{
  "id": "task_xxxxxxxx",
  "model": "magi-2-text-to-video",
  "status": "completed",
  "created_at": 1764120000,
  "finished_at": 1764120095,
  "output": {
    "video_url": "https://static.seedrouter.ai/..."
  }
}
```

## 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 audio generation add no extra charge. Failed tasks are not charged.

See current live per-second rates on the [MAGI-2 model page](https://seedrouter.ai/models/magi-2#pricing).
