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

# MAGI-2

> MAGI-2 by Sand AI: 1080p video up to 30 seconds from text, a first frame, or reference images, videos and audio.

MAGI-2 from Sand AI generates 1080p video from 4 to 30 seconds. It works from a text prompt alone, from a first-frame image, or from up to 10 reference images, 5 reference videos and 5 reference audio clips, and can generate sound.

* Model ID: `magi-2`
* Endpoint: `POST https://refillapi.com/v1/videos` (async task)
* [Price](https://refillapi.com/pricing/magi-2)

## Request

**Authorization** `string` *required*

`Bearer YOUR_API_KEY`

**model** `string` *required*

`magi-2`

**prompt** `string` *required*

What happens in the video, including camera and sound. Up to 8,000 characters.

**seconds** `integer` (default: 5)

Length: an integer from 4 to 30.

**input\_reference** `string`

First frame: a public image URL. Cannot be combined with `metadata.parts`.

**metadata.aspectRatio** `string` (default: 16:9)

`16:9`, `9:16`, `21:9`, `4:3`, `1:1` or `3:4`.

**metadata.resolution** `string` (default: 1080p)

Only `1080p`.

**metadata.generateAudio** `boolean`

Whether to generate sound with the video.

**metadata.parts** `object[]`

Reference media, in Sand AI's format. Each item is one of:

* `{"type": "reference_image", "image": {"url": "https://..."}}` — up to 10
* `{"type": "reference_video", "video": {"url": "https://..."}}` — up to 5; each 2–30 s, 30 s in total
* `{"type": "reference_audio", "audio": {"url": "https://..."}}` — up to 5

You may also put the prompt here as one `{"type": "text", "text": "..."}` item instead of the top-level `prompt` — but not both.

Field names in `metadata` use Sand AI's spelling (`aspectRatio`, `generateAudio`). Any other `metadata` field, and `size`, are rejected.

## Text to video

```bash theme={null}
curl https://refillapi.com/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "prompt": "A paper boat drifting down a rainy city gutter, close-up, the sound of rain",
    "seconds": 8,
    "metadata": { "aspectRatio": "16:9", "generateAudio": true }
  }'
```

## First frame to video

```bash theme={null}
curl https://refillapi.com/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "prompt": "The flower slowly opens as the camera pushes in",
    "seconds": 5,
    "input_reference": "https://example.com/first-frame.jpg"
  }'
```

## Reference images and video

```bash theme={null}
curl https://refillapi.com/v1/videos \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "prompt": "The woman from the reference photo dances on a city street, following the moves in the reference video",
    "seconds": 10,
    "metadata": {
      "aspectRatio": "9:16",
      "parts": [
        {"type": "reference_image", "image": {"url": "https://example.com/person.png"}},
        {"type": "reference_video", "video": {"url": "https://example.com/dance.mp4"}}
      ]
    }
  }'
```

Polling and download work as in [Video generation](https://docs.refillapi.com/api/videos/overview.md#2-poll).

> [!NOTE]
>
> MAGI-2 is slower than most video models: plan on **10–30 minutes** per task. Poll every 30 seconds or so.

## Billing

Billed per second of output video at 1080p. The requested length is held when you submit and settled against the length actually generated; failed tasks are refunded in full. Reference media are not billed separately. Current price: [magi-2 pricing](https://refillapi.com/pricing/magi-2).

## Errors

| Error | Cause |
| - | - |
| `seconds must be an integer between 4 and 30` | Length out of range |
| `metadata.aspectRatio must be one of …` | Unsupported ratio |
| `metadata.resolution must be 1080p` | Only 1080p is available |
| `input_reference cannot be combined with reference parts` | Use either a first frame or reference media |
| `provide the prompt once, either as prompt or as a text part` | Prompt given twice |
| `at most 10 reference_image parts are supported` | Too many references of one type |
| `Your request was rejected by content moderation.` | The task failed moderation (refunded) |
| `Reference videos must be at most 30 seconds each and 30 seconds in total.` | Reference video too long (task fails, refunded) |


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