# Sand AI MAGI-2 API

> MAGI-2 by Sand AI turns text, a first and last frame, or reference images, videos and audio into a 1080p video of 4 to 30 seconds with native audio. Call it from this page, through /v1/run, or with the Volcengine Ark compatible API that Sand AI documents for MAGI-2.

Source: https://www.sandbase.ai/models/sandai/magi-2
API reference: https://www.sandbase.ai/models/sandai/magi-2#api

## Facts

- Provider: Sand AI
- Type: Video model
- Model ID: `sandai/magi-2`
- Price: From $0.40 per run
- Capabilities: text to video, image to video, reference to video
- Billing: pay per use from one SandBase balance; no provider account or subscription needed

## Call it

- Unified Run API: `POST https://api.sandbase.ai/v1/run`

```bash
curl -X POST https://api.sandbase.ai/v1/run \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sandai/magi-2",
  "prompt": "At dawn, waves break gently against the rocks as the camera slowly moves forward.",
  "duration": 5,
  "resolution": "1080p",
  "aspect_ratio": "16:9",
  "generate_audio": true
}'
```

The response returns a run id; poll `GET https://api.sandbase.ai/v1/run/{id}` until the status is `completed` or `failed`.

## FAQ

### How do I call Sand AI MAGI-2 through SandBase?

Create a SandBase API key, then send requests with the model ID "sandai/magi-2" to Unified Run API (/v1/run) at https://api.sandbase.ai. The request examples on this page show the exact payload.

### Do I need a separate Sand AI account?

No. One SandBase API key and balance gives you access to Sand AI MAGI-2 and the other models in the catalog; you do not need to sign up with Sand AI separately.

## README

### MAGI-2
[MAGI-2](https://sand.ai/blog/magi-2/) by [Sand AI](https://sand.ai/) generates a 1080p video of 4 to 30 seconds from text, a first and last frame, or reference images, videos and audio, with dialogue, sound effects and music generated together with the picture. [See MAGI-2 results](https://www.sandbase.ai/lab/ai-videos/magi-2) first if you want to judge the quality.

Use the form on this page, or the Volcengine Ark compatible API below with the request body Sand AI documents. For SandBase's own API format, see [Two ways to call MAGI-2](#two-ways-to-call-magi-2).
#### Inputs
Pick one way to guide the video:
- **Text only**: a prompt.
- **First and last frame**: `image`, optionally `end_image`, with an optional prompt.
- **References**: up to 10 `images`, 5 `videos` and 5 `audios` (videos and audio 2 to 30 seconds each and 30 seconds in total), with an optional prompt. Refer to them in the prompt as @Image1, @Video1, @Audio1.

Frames and references cannot be combined in one request.
| Field | Type | Default | Notes |
|---|---|---|---|
| `prompt` | string | — | Scene, motion and sound. Up to 15,000 characters. Required for text only. |
| `image` | image | — | First frame. |
| `end_image` | image | — | Last frame. Requires `image`. |
| `images` | image list, up to 10 | — | Reference images. |
| `videos` | video list, up to 5 | — | Reference videos, MP4 or MOV. |
| `audios` | audio list, up to 5 | — | Reference audio, WAV or MP3. |
| `duration` | integer 4–30 | 5 | Output length in seconds. Billed per second. |
| `aspect_ratio` | `21:9` / `16:9` / `4:3` / `1:1` / `3:4` / `9:16` | 16:9 | Output aspect ratio. |
| `resolution` | `1080p` | 1080p | MAGI-2 renders 1080p only. |
| `generate_audio` | boolean | true | Native audio track, included in the price. |
| `seed` | integer 0–4294967295 | random | Fix the seed for reproducible results. |
| `enhance_prompt` | boolean | model default | Turn prompt enhancement on or off. |
| `omni_reference_task_type` | `auto` | — | Optional. |
#### Volcengine Ark compatible API
SandBase implements Sand AI's [Ark compatibility API](https://platform.sand.ai/docs/ark-generations/) for `magi-2`. Use your SandBase API key and point the Ark SDK or HTTP client at SandBase:
| | Sand AI | SandBase |
|---|---|---|
| Base URL | `https://api.sand.ai/compatible/ark/api/v3` | `https://api.sandbase.ai/api/v3` |
| Create a task | `POST /contents/generations/tasks` | `POST /contents/generations/tasks` |
| Retrieve a task | `GET /contents/generations/tasks/{id}` | `GET /contents/generations/tasks/{id}` |
| `model` | `magi-2` | `magi-2` |
```bash
curl https://api.sandbase.ai/api/v3/contents/generations/tasks \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "content": [
      {"type": "text", "text": "The camera moves from a clear dawn shore to sunset."},
      {"type": "image_url", "role": "first_frame", "image_url": {"url": "https://example.com/first.jpg"}},
      {"type": "image_url", "role": "last_frame", "image_url": {"url": "https://example.com/last.jpg"}}
    ],
    "duration": 5,
    "ratio": "16:9",
    "resolution": "1080p"
  }'
```
In this API, `duration` (4 to 30) and `ratio` are required, either as top-level fields or as prompt suffixes such as `--rt 16:9 --dur 5`; top-level fields win. Omit `watermark` and the other fields Sand AI lists as unsupported: any value other than `null` returns 400.

The response is `{"id": "..."}`. Poll `GET /api/v3/contents/generations/tasks/{id}` every 10 seconds. `queued` and `running` mean keep polling. On `succeeded`, download `content.video_url`; the task also reports `duration`, `framespersecond`, `resolution`, `ratio` and `generate_audio` when known. `failed`, `expired` and `cancelled` are final; failed and expired tasks carry `error.code` and `error.message`.

Requests and responses use the format in the [Sand AI documentation](https://platform.sand.ai/docs/ark-generations/). Media URLs can be public HTTPS or `data:` URLs: images JPEG, PNG, WebP, GIF, BMP, TIFF, HEIC or HEIF under 30,000,000 bytes, audio MP3 or WAV up to 15,000,000 bytes. A request body can be up to 64,000,000 bytes, of which at most 2 MiB is not media; put `model` near the start of large requests. Also note:
- `X-Request-Id` is returned only when a task is created.
- References are sent to the model grouped by type (images, then videos, then audio); the order within each type is kept.
- MAGI-2 runs on one provider here. The SandBase API models can switch providers.
#### Billing
$0.08 per second of output video, with native audio included in the price. Resolution is fixed at 1080p. Failed runs are not billed.
| Output length | Price |
|---|---|
| 4s | $0.32 |
| 5s (default) | $0.40 |
| 10s | $0.80 |
| 30s | $2.40 |
#### Two ways to call MAGI-2
| | This model (Sand AI format) | SandBase API |
|---|---|---|
| Request | `POST /api/v3/contents/generations/tasks` with `"model": "magi-2"` and a `content` array | `POST /v1/run` with the fields of each model |
| Models | `magi-2` for every kind of input | [Text to Video](/models/sandai/magi-2/text-to-video), [Image to Video](/models/sandai/magi-2/image-to-video), [Reference to Video](/models/sandai/magi-2/reference-to-video) |
| Providers | One provider | Switches to another provider if one is unavailable |
| Price | $0.08 per second | $0.08 per second |
Use this model if your code already calls Sand AI's API or the Ark SDK: change the base URL and API key, keep the request body. Use the SandBase API models for new integrations: they take the same request format as other SandBase models and keep working if a provider is unavailable. [Compare both on the MAGI-2 page](/models/magi-2).
#### See what MAGI-2 can do
- [MAGI-2 videos from X](https://www.sandbase.ai/lab/ai-videos/magi-2): the most-liked MAGI-2 clips, credited to the people who made them. Short films, ads and anime.
- Open a SandBase API model page above to see its examples.
#### Learn more
- [Sand AI Ark compatibility API](https://platform.sand.ai/docs/ark-generations/): the official request and response reference, to compare with SandBase.
- [MAGI-2 announcement from Sand AI](https://sand.ai/blog/magi-2/): model overview and release notes.
- [Sand AI](https://sand.ai/): the team behind MAGI-2.
