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

# MAGI-2 API for Text, Image, and Reference-to-Video Generation

> Generate 4–30 second MAGI-2 videos from text, keyframes, or multimodal references with optional synchronized audio and aspect-ratio-dependent output dimensions.

## Overview

Use model ID `magi-2` to generate videos from a prompt, a first frame with an optional last frame, or a prompt with optional image, video, and audio references.

### Output dimensions

`1080p` is the output tier. The actual pixel dimensions depend on `aspect_ratio`.

| Aspect ratio | Verified output (width × height) |
| - | - |
| `16:9` | 1920 × 1080 px |
| `1:1` | 1440 × 1440 px |

Set `aspect_ratio` explicitly to control framing. If you omit it, text-to-video and reference-to-video use `16:9`. Image-to-video uses the closest supported ratio to the first frame.

## Endpoints and authentication

Base URL:

```text theme={null}
https://api.apixo.ai/api/v1
```

| Method | Endpoint | Purpose |
| - | - | - |
| POST | `/generateTask/magi-2` | Submit a generation task |
| GET | `/statusTask/magi-2?taskId={taskId}` | Retrieve task status and results |

Send `Authorization: Bearer YOUR_API_KEY` with both requests and `Content-Type: application/json` with the POST body.

## Request examples

### Text-to-video

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/magi-2" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "A slow push through an evening market, with rain and quiet footsteps.",
      "duration": 5,
      "aspect_ratio": "16:9"
    }
  }'
```

### Image-to-video

This example requests square output and uses both a first and a last frame. To animate a single image, pass only the first URL.

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "image-to-video",
    "duration": 4,
    "aspect_ratio": "1:1",
    "image_urls": ["https://example.com/first.jpg", "https://example.com/last.jpg"],
    "sound": false
  }
}
```

### Reference-to-video

```json theme={null}
{
  "request_type": "callback",
  "callback_url": "https://example.com/webhook",
  "input": {
    "mode": "reference-to-video",
    "prompt": "Keep the product design from the reference image as the camera circles it. Use the audio reference to guide the soundtrack.",
    "duration": 8,
    "image_urls": ["https://example.com/product.png"],
    "audio_urls": ["https://example.com/music.wav"]
  }
}
```

## Parameters

**request\_type** `string` (default: async)

Supported values: `async`, `callback`. With `async`, poll until `data.state` is `success` or `failed`. With `callback`, read the final webhook payload. On success, parse `data.resultJson` as JSON and read `resultUrls`. On failure, read `data.failCode` and `data.failMsg`.

**callback\_url** `string`

Required when `request_type` is `callback`. Use a public HTTPS URL that can receive the final task payload. See [Webhooks](https://apixo.ai/docs/api-reference/webhooks.md).

**input** `object` *required*

MAGI-2 generation parameters.

**properties**

**mode** `string` *required*

Supported values: `text-to-video`, `image-to-video`, `reference-to-video`.

**prompt** `string`

A nonblank prompt is required for text-to-video and reference-to-video. Optional for image-to-video. Maximum length is 15,000 characters.

**duration** `integer|string` (default: 5)

Requested output duration in whole seconds, from `4` to `30`. Numeric strings are accepted.

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

Supported value: `1080p`. This is the output tier. Pixel dimensions depend on `aspect_ratio`. Verified examples are `16:9` at 1920 × 1080 and `1:1` at 1440 × 1440.

**aspect\_ratio** `string`

Output framing. Supported values: `21:9`, `16:9`, `4:3`, `1:1`, `3:4`, `9:16`. Text-to-video and reference-to-video default to `16:9`. Image-to-video defaults to the closest supported ratio to the first frame.

**sound** `boolean` (default: true)

Generate synchronized audio with `true`. Use `false` for a silent video.

**seed** `integer|string`

Optional integer from `0` to `2147483647`. Numeric strings are accepted.

**image\_urls** `string[]`

Public HTTP(S) image URLs. Image-to-video requires the first frame at index 0 and accepts an optional last frame at index 1. Reference-to-video accepts up to 10 optional reference images.

**video\_urls** `string[]`

Up to 5 public HTTP(S) reference video URLs for reference-to-video. Use clips of 2–30 seconds, with a combined video duration of up to 30 seconds. Longer inputs may be trimmed.

**audio\_urls** `string[]`

Up to 5 public HTTP(S) reference audio URLs for reference-to-video. Use clips of 2–30 seconds, with a combined audio duration of up to 30 seconds. Longer inputs may be trimmed.

Keep media URLs accessible while the task runs. The first frame may be cropped to fit the selected output ratio.

## Task status and results

The creation response returns `data.taskId`.

```json theme={null}
{"code":200,"message":"success","data":{"taskId":"YOUR_TASK_ID"}}
```

For async requests, call the status endpoint with that ID and continue polling until `data.state` is `success` or `failed`. For callback requests, read the same result fields from the final [webhook payload](https://apixo.ai/docs/api-reference/webhooks.md).

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "YOUR_TASK_ID",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://example.com/output.mp4\"]}"
  }
}
```

On success, parse `data.resultJson` as JSON and read the MP4 URLs from `resultUrls`. On failure, read `data.failCode` and `data.failMsg`. See [Status Task](https://apixo.ai/docs/api-reference/status-task.md) and [Error Codes](https://apixo.ai/docs/api-reference/errors.md) for the shared response fields.

## Billing

The standard price is **$0.080 per requested output second** for all three modes. Aspect ratio, the sound setting, and reference media leave the rate unchanged. A 4-second request costs **$0.32** at the standard rate. See [API Pricing](https://apixo.ai/pricing/api) for current rates.

## MCP integration

The [model schema](https://apixo.ai/docs/models/schemas/video/magi-2.json) declares video decoding in `mcp.result` and file bindings in `mcp.attachments` for `image_urls`, `video_urls`, and `audio_urls`. Preserve image order when binding first and last frames.


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