# Magi-2

> Magi-2 is Sand AI's video model: one generation gives 4 to 30 seconds of 1080p video with sound, from a prompt, a first and last frame, or reference images, video and audio. On Kerox it is billed per second of output, at one rate for every mode, with or without sound. Open it in Studio, or call the API with the model ID sand-ai/magi-2.

- **Model ID**: `sand-ai/magi-2`
- **Maker**: Sand AI
- **Type**: Video (`video`)
- **Status**: Live (`live`)
- **Timeout**: 43200 s
- **Typical time**: ~259 s
- **Endpoint**: `POST https://api.kerox.ai/v1/tasks`
- **Web page**: https://kerox.ai/docs/models/sand-ai/magi-2

## Request example

Submit a task and get its id at once; get the result by polling (below) or by [webhook](https://kerox.ai/docs/webhooks.md). `webhook_url` and `metadata` are optional. To use a webhook, provide your own public HTTPS address in `webhook_url`. Every field is in [Submit a task](https://kerox.ai/docs/tasks.md#submit-body).

Set `KEROX_API_KEY` first. Polling requires Bash, curl and jq. For Python, run `pip install requests` first.

### cURL

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "a red fox running through fresh snow, cinematic lighting",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9"
  }
}'
```

### Python

```python
import os
import requests

resp = requests.post(
    "https://api.kerox.ai/v1/tasks",
    headers={
        "Authorization": f"Bearer {os.environ['KEROX_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "sand-ai/magi-2",
        "input": {
            "prompt": "a red fox running through fresh snow, cinematic lighting",
            "resolution": "1080p",
            "duration": 5,
            "aspect_ratio": "16:9",
        },
    },
    timeout=60,
)
resp.raise_for_status()
task = resp.json()
print(task["id"], task["status"])  # Save the id for polling
```

### Node.js

```javascript
const res = await fetch('https://api.kerox.ai/v1/tasks', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.KEROX_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "model": "sand-ai/magi-2",
    "input": {
      "prompt": "a red fox running through fresh snow, cinematic lighting",
      "resolution": "1080p",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }),
});
const task = await res.json();
if (!res.ok) throw new Error(JSON.stringify(task));
console.log(task.id, task.status); // Save the id for polling
```

### Go

```go
package main

import (
	"bytes"
	"fmt"
	"io"
	"net/http"
	"os"
	"time"
)

func main() {
	body := []byte(`{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "a red fox running through fresh snow, cinematic lighting",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9"
  }
}`)
	req, _ := http.NewRequest("POST", "https://api.kerox.ai/v1/tasks", bytes.NewReader(body))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("KEROX_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	client := &http.Client{Timeout: 60 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()
	out, _ := io.ReadAll(resp.Body)
	if resp.StatusCode >= 400 {
		fmt.Fprintln(os.Stderr, string(out))
		os.Exit(1)
	}
	fmt.Println(string(out))
}
```

### Reference image

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "Image 1: the lighthouse beam sweeps slowly across the water",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "images": [
      "https://cdn.kerox.ai/assets/samples/seedream-5.5/lighthouse-blue-hour.webp"
    ]
  }
}'
```

### First frame

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "A lighthouse beam sweeps slowly across the waves",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "first_frame": "https://cdn.kerox.ai/assets/samples/seedream-5.5/lighthouse-blue-hour.webp"
  }
}'
```

### First and last frames

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "Slowly dissolve from the coast to the cabin by the lake",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "first_frame": "https://cdn.kerox.ai/assets/samples/seedream-5.5/lighthouse-blue-hour.webp",
    "last_frame": "https://cdn.kerox.ai/assets/samples/seedream-5.0-pro/alpine-cabin-dawn.webp"
  }
}'
```

### Reference video

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "Use the camera motion of Video 1 for a flyover of a rocky coastline",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "videos": [
      "https://cdn.kerox.ai/assets/samples/seedance-2.0/sea-stacks-fog.mp4"
    ]
  }
}'
```

### Reference audio

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/tasks \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "Show a dinosaur at dusk and time its roar to Audio 1",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "audios": [
      "https://interactive-examples.mdn.mozilla.net/media/cc0-audio/t-rex-roar.mp3"
    ]
  }
}'
```

## Parameters

The [parameter names](https://kerox.ai/docs/models.md) mean the same on every model.

| Parameter | Type | Required | Default | Values | Description | Example |
| --- | --- | --- | --- | --- | --- | --- |
| `prompt` | string | No | — | at least one non-whitespace character; 1–15000 characters | Text describing what to generate. | `"A lighthouse at dawn"` |
| `images` | string \| string[] | No | — | one public HTTPS URL; one string or an array of 1–10 items | Images for the model to draw on, in the order the prompt refers to them. | `"https://example.com/photo.png"` |
| `videos` | string \| string[] | No | — | one public HTTPS URL; one string or an array of 1–5 items; At least 2 seconds per clip and at most 30 seconds total for this media type. Video and audio are counted separately. | Videos for the model to draw on, in the order the prompt refers to them. | `"https://example.com/clip.mp4"` |
| `audios` | string \| string[] | No | — | one public HTTPS URL; one string or an array of 1–5 items; At least 2 seconds per clip and at most 30 seconds total for this media type. Video and audio are counted separately. | Audio clips for the model to draw on, in the order the prompt refers to them. | `"https://example.com/music.wav"` |
| `first_frame` | string | No | — | one public HTTPS URL | The image a video starts from. | `"https://example.com/start.png"` |
| `last_frame` | string | No | — | one public HTTPS URL | The image a video ends on. Needs `first_frame`. | `"https://example.com/end.png"` |
| `aspect_ratio` | string | No | — | 16:9, 9:16, 1:1, 4:3, 3:4, 21:9 | Width to height of the output. | `"16:9"` |
| `resolution` | string | No | `"1080p"` | 1080p | Output resolution tier. The exact pixels follow from it and `aspect_ratio`. | `"1080p"` |
| `duration` | integer | No | `5` | 4–30 | Length of the output in whole seconds. | `5` |
| `seed` | integer | No | — | 0–2147483647 | The same seed and input give a similar result. | `0` |
| `generate_audio` | boolean | No | `true` | true, false | Whether the video comes with generated sound (voice, effects, music). | `true` |
| `n` | integer | No | `1` | 1 | How many outputs one task may produce. | `1` |

- last_frame requires first_frame
- When first_frame: omit images or videos or audios
- Supply a prompt for text or reference generation. With a first frame the prompt is optional. With a first frame the video follows the frame's aspect ratio and `aspect_ratio` has no effect; the other modes use 16:9 when it is omitted.
- Only output seconds are billed. Reference media and the audio switch do not change the price.

Use a public HTTPS URL directly for images, audio and video. For local media, upload with `POST /v1/files` and pass the returned `url`. For upload MIME and size limits, see [Files & inputs](https://kerox.ai/docs/files.md#presigned).

Not supported yet: `watermark`.

## Polling and output

Poll `GET /v1/tasks/{id}`, or pass `webhook_url` when you submit and receive the same task object when it finishes: see [Webhooks](https://kerox.ai/docs/webhooks.md) for the setup. Output files expire at `expires_at` (7 days after completion), so download anything you want to keep. See every task field in [Tasks & polling](https://kerox.ai/docs/tasks.md#submit-response).

Set `TASK_ID` to the `id` returned on submission. The script waits up to 10 minutes, prints `error` on failure and downloads every `outputs[].url` on success.

```bash
(
  set -eu
  # Set TASK_ID to the id returned by the submit request.
  : "${TASK_ID:?Set TASK_ID}"
  deadline=$((SECONDS + 600))
  while (( SECONDS < deadline )); do
    task=$(curl --fail-with-body --silent --show-error --max-time "$((deadline - SECONDS))" https://api.kerox.ai/v1/tasks/"$TASK_ID" \
      -H "Authorization: Bearer $KEROX_API_KEY")
    case $(jq -er .status <<< "$task") in
      succeeded)
        if ! jq -e '.outputs | length > 0' <<< "$task" >/dev/null; then
          echo "Result files are unavailable." >&2
          exit 1
        fi
        i=0
        while IFS= read -r url; do
          file_path=${url%%\?*}
          filename="output-${i}.${file_path##*.}"
          curl --fail-with-body --silent --show-error --max-time 120 "$url" -o "$filename"
          printf "%s\n" "$filename"
          i=$((i + 1))
        done < <(jq -r '.outputs[].url' <<< "$task")
        exit 0 ;;
      failed) jq -c .error <<< "$task" >&2; exit 1 ;;
      processing) sleep 2 ;;
      *) echo "Unexpected task status." >&2; exit 1 ;;
    esac
  done
  echo "Poll timed out. Keep TASK_ID to check again later." >&2
  exit 1
)
```

### Success response JSON

Actual charges depend on your account price and task result.

```json
{
  "id": "task_01JD8X9B4Q2M7T8N3K5P6R1S0V",
  "object": "task",
  "model": "sand-ai/magi-2",
  "status": "succeeded",
  "source": "api",
  "format": "unified",
  "input": {
    "prompt": "a red fox running through fresh snow, cinematic lighting",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9"
  },
  "outputs": [
    {
      "type": "video",
      "url": "https://cdn.kerox.ai/t/task_01JD8X9B4Q2M7T8N3K5P6R1S0V/5f2b8c1e9d3a4f6b8a7c0d1e2f3a4b5c/0.mp4",
      "content_type": "video/mp4",
      "width": 1920,
      "height": 1080,
      "duration": 5
    }
  ],
  "outputs_deleted": false,
  "error": null,
  "cost": {
    "amount": "0.5000",
    "currency": "USD",
    "status": "settled"
  },
  "metadata": null,
  "warnings": [],
  "created_at": "2026-11-20T08:00:00Z",
  "started_at": "2026-11-20T08:00:01Z",
  "completed_at": "2026-11-20T08:01:10Z",
  "expires_at": "2026-11-27T08:01:10Z"
}
```

## Pricing

| Tier | Kerox / second |
| --- | --- |
| 1080p | $0.1000 |

### Estimate before submitting

The returned `amount` is what submitting would hold. An estimate creates no task and charges nothing. When `exact` is `false`, the final charge may differ from the hold.

### Without a reference video

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/estimate \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "a red fox running through fresh snow, cinematic lighting",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9"
  }
}'
```

### With a reference video

```bash
curl --fail-with-body -X POST https://api.kerox.ai/v1/estimate \
  -H "Authorization: Bearer $KEROX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "sand-ai/magi-2",
  "input": {
    "prompt": "a red fox running through fresh snow, cinematic lighting",
    "resolution": "1080p",
    "duration": 5,
    "aspect_ratio": "16:9",
    "videos": [
      "https://cdn.kerox.ai/assets/samples/seedance-2.0/sea-stacks-fog.mp4"
    ]
  }
}'
```

## Common usage

| Clip | Kerox |
| --- | --- |
| 5 s · 1080p | $0.5000 |
| 10 s · 1080p | $1.0000 |
| 15 s · 1080p | $1.5000 |

- **$10 gets you**: 100 seconds of 1080p video

## What is Magi-2

Magi-2 is the flagship video model from Sand AI, launched on November 24, 2026, after the open-source Magi-2 Preview in August. Sand AI builds picture and sound in one model: a single Transformer reads text, video and audio together, so the clip comes out with its soundtrack. The points below come from Sand AI's launch post.

### What Sand AI says about Magi-2

- **Up to 30 seconds of 1080p in one pass.** Sand AI generates up to 30 seconds of 1080p video and audio in a single generation, at 25 frames per second. The 1080p output comes from an upscaling step after the base generation.
- **Sound from the same model.** Dialogue with lip-sync, sound effects, ambient sound and music are generated with the picture, not added afterwards.
- **One stream for text, video and audio.** Sand AI describes a single-stream mixture-of-experts Transformer with about 480B parameters in total and about 28B active.
- **Multimodal references.** A generation can be guided by up to 10 images, 5 videos and 5 audio clips.
- **Stable over long takes.** Sand AI highlights instruction following, complex composition and consistency in space and time across long videos.

Sand AI also presents editing an existing video and timeline control. Those are not available on Kerox yet.

On Kerox, Magi-2 generates 1080p video from 4 to 30 seconds, in 16:9, 9:16, 1:1, 4:3, 3:4 or 21:9, with sound on by default. A request carries a prompt alone, a first frame with an optional last frame, or up to 10 reference images, 5 reference videos and 5 reference audio clips. With a first frame the video keeps the frame's shape. The price is the same in all three modes. How to call it, what it costs, and the alternatives: [Magi-2 API guide](https://kerox.ai/blog/magi-2-api)

## How to use Magi-2

1. **Top up** — Add funds from $5. There is no subscription, and your balance does not expire.
2. **Set up the video** — Write a prompt, choose the duration and aspect ratio, and add a first frame or reference files if you need them. The price for these settings shows before you start.
3. **Generate and download** — The amount is held when you start and settled when the video finishes. A failed generation is refunded in full.

Prefer code? The same model runs through the Kerox API with the model ID `sand-ai/magi-2`. See the [Magi-2 API docs](https://kerox.ai/docs/models/sand-ai/magi-2.md).

## What you can make with Magi-2

- **Text to video with sound.** A prompt alone gives a 1080p clip with natural sound, up to 30 seconds.
- **Image to video.** Start from a first frame, or set the first and the last frame and let the model fill in the motion.
- **Videos guided by references.** Pass images of a subject, a product or a setting, and describe the scene around it.
- **Scenes with dialogue.** Write the lines in quotes and the model voices them in sync with the speaker's lips.
- **Clips that follow a reference sound.** Add reference audio for a voice, a rhythm or a piece of music, up to 30 seconds in total.

## Magi-2 vs other models on Kerox

All of these run on the same balance and the same API. To switch, change the model ID and keep to settings the other model supports. Starting prices are in the table.

| Model | When to pick it | Starting price |
| --- | --- | --- |
| [Magi-2](https://kerox.ai/models/sand-ai/magi-2) | Sand AI's video model, 4 to 30 seconds at 1080p with sound, one rate for every mode. Pick it for long 1080p clips with dialogue or sound. | 1080p: $0.1000 |
| [Seedance 2.5](https://kerox.ai/models/bytedance/seedance-2.5) | ByteDance's video model, 4 to 30 seconds at 480p, 720p or 1080p, with up to 30 reference images. Pick it when you want a lower resolution or many references. | From approx. $0.0977 / s (480p) |
| [Kling 4.0](https://kerox.ai/models/kuaishou/kling-4.0) | Kuaishou's video model, 3 to 30 seconds at 720p, 1080p or 4K. Pick it when you need 4K. | 4K: $0.4941, 720p: $0.1413, 1080p: $0.2115 |
| [Wan 3.0](https://kerox.ai/models/alibaba/wan-3.0) | Alibaba's video model, 2 to 30 seconds at up to 1080p. Pick it for clips shorter than 4 seconds. | 480p: $0.0400, 720p: $0.0800, 1080p: $0.1600 |
| [MiniMax H3](https://kerox.ai/models/minimax/h3) | MiniMax's video model, 4 to 15 seconds at 768p or 2K. Pick it for short 2K clips. | 2K: $0.0650, 768p: $0.0400 |

## Magi-2 FAQ

### How long can a Magi-2 video be?

From 4 to 30 seconds in one generation, in whole seconds. The default is 5 seconds. Every clip is 1080p, and the bill counts the seconds of output only.

### Does Magi-2 generate sound?

Yes. Sound is on by default: Sand AI generates dialogue with lip-sync, sound effects, ambient sound and music with the picture. Set `generate_audio` to false, or turn off Generate audio in Studio, for a silent clip. The price per second is the same either way.

### How should I write a Magi-2 prompt?

Write it shot by shot, in the order things happen, and say where the camera is. Put spoken lines in quotes, word for word, and say who speaks them. Describe the sound you want too: Sand AI's prompt guide for Magi-2 Preview keeps dialogue in its original language and splits a clip into shots joined by cuts.

### What is the difference between Magi-1, Magi-2 Preview and Magi-2?

They are three generations from Sand AI. Magi-1, released in April 2025 under Apache 2.0, generates video autoregressively, chunk by chunk. Magi-2 Preview, open-sourced under Apache 2.0 in August 2026, generates 10-second clips with sound. Magi-2, launched in November 2026, is a larger model trained on about three times the Preview's data, and makes up to 30 seconds of 1080p with sound. Kerox runs Magi-2. Magi-2's own weights are not open yet: Sand AI says open-source releases and a technical report will follow.


## Input schema (JSON)

### Parameters (`unified.input_schema`)

```json
{
  "type": "object",
  "allOf": [
    {
      "if": {
        "required": [
          "first_frame"
        ],
        "properties": {
          "first_frame": true
        }
      },
      "else": {
        "required": [
          "prompt"
        ],
        "properties": {
          "prompt": true
        }
      },
      "then": {
        "not": {
          "anyOf": [
            {
              "required": [
                "images"
              ],
              "properties": {
                "images": true
              }
            },
            {
              "required": [
                "videos"
              ],
              "properties": {
                "videos": true
              }
            },
            {
              "required": [
                "audios"
              ],
              "properties": {
                "audios": true
              }
            }
          ]
        }
      }
    }
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "prompt": {
      "type": "string",
      "pattern": "\\S",
      "maxLength": 15000,
      "minLength": 1,
      "description": "Text describing what to generate.",
      "x-label-en": "Prompt",
      "x-label-zh": "提示词",
      "x-tier": "common"
    },
    "images": {
      "oneOf": [
        {
          "type": "string",
          "pattern": "^https://"
        },
        {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^https://"
          },
          "maxItems": 10,
          "minItems": 1
        }
      ],
      "description": "Images for the model to draw on, in the order the prompt refers to them.",
      "x-label-en": "Reference images",
      "x-label-zh": "参考图",
      "x-tier": "common"
    },
    "videos": {
      "oneOf": [
        {
          "type": "string",
          "pattern": "^https://"
        },
        {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^https://"
          },
          "maxItems": 5,
          "minItems": 1
        }
      ],
      "x-constraints": {
        "min_clip_seconds": 2,
        "max_total_seconds": 30
      },
      "description": "Videos for the model to draw on, in the order the prompt refers to them.",
      "x-label-en": "Reference videos",
      "x-label-zh": "参考视频",
      "x-tier": "advanced"
    },
    "audios": {
      "oneOf": [
        {
          "type": "string",
          "pattern": "^https://"
        },
        {
          "type": "array",
          "items": {
            "type": "string",
            "pattern": "^https://"
          },
          "maxItems": 5,
          "minItems": 1
        }
      ],
      "x-constraints": {
        "min_clip_seconds": 2,
        "max_total_seconds": 30
      },
      "description": "Audio clips for the model to draw on, in the order the prompt refers to them.",
      "x-label-en": "Reference audio",
      "x-label-zh": "参考音频",
      "x-tier": "advanced"
    },
    "first_frame": {
      "type": "string",
      "pattern": "^https://",
      "description": "The image a video starts from.",
      "x-label-en": "First frame",
      "x-label-zh": "首帧",
      "x-tier": "common"
    },
    "last_frame": {
      "type": "string",
      "pattern": "^https://",
      "description": "The image a video ends on. Needs `first_frame`.",
      "x-label-en": "Last frame",
      "x-label-zh": "尾帧",
      "x-tier": "advanced"
    },
    "aspect_ratio": {
      "enum": [
        "16:9",
        "9:16",
        "1:1",
        "4:3",
        "3:4",
        "21:9"
      ],
      "type": "string",
      "description": "Width to height of the output.",
      "x-label-en": "Aspect ratio",
      "x-label-zh": "画面比例",
      "x-tier": "common"
    },
    "resolution": {
      "enum": [
        "1080p"
      ],
      "type": "string",
      "default": "1080p",
      "description": "Output resolution tier. The exact pixels follow from it and `aspect_ratio`.",
      "x-label-en": "Resolution",
      "x-label-zh": "分辨率",
      "x-tier": "common"
    },
    "duration": {
      "type": "integer",
      "default": 5,
      "maximum": 30,
      "minimum": 4,
      "description": "Length of the output in whole seconds.",
      "x-label-en": "Duration",
      "x-label-zh": "时长",
      "x-tier": "common"
    },
    "seed": {
      "type": "integer",
      "maximum": 2147483647,
      "minimum": 0,
      "description": "The same seed and input give a similar result.",
      "x-label-en": "Seed",
      "x-label-zh": "随机种子",
      "x-tier": "advanced"
    },
    "generate_audio": {
      "type": "boolean",
      "default": true,
      "description": "Whether the video comes with generated sound (voice, effects, music).",
      "x-label-en": "Generate audio",
      "x-label-zh": "生成声音",
      "x-tier": "common"
    },
    "n": {
      "type": "integer",
      "const": 1,
      "default": 1,
      "description": "How many outputs one task may produce.",
      "x-label-en": "Number of outputs",
      "x-label-zh": "生成数量",
      "x-tier": "advanced"
    }
  },
  "x-unsupported": [
    "watermark"
  ],
  "dependentRequired": {
    "last_frame": [
      "first_frame"
    ]
  },
  "additionalProperties": false
}
```
