MAGI-2
MAGI-2 generates 4–30 second 1080p videos with optional native audio. It has three modes:
mode | What it does |
|---|---|
text_to_video | Generate a video from the prompt alone |
image_to_video | Animate a first frame, optionally ending on a last frame |
reference_to_video | Generate a video guided by up to 10 reference images, 5 reference videos and 5 reference audio clips |
Output is a 1080p MP4 (H.264, 25 fps, with AAC audio when generate_audio is true).
Model
| Model name | Description |
|---|---|
magi-2.0 | Text, image or multimodal reference to 1080p video, 4–30 seconds |
Pricing
Cost = duration × 20.8 credits per second. Mode, aspect ratio, audio and reference media do not change the price.
| Resolution | Credits/s | 5s | 10s | 15s | 30s |
|---|---|---|---|---|---|
1080p | 20.8 | 104 | 208 | 312 | 624 |
- Billed seconds are the requested
duration(an integer from 4 to 30, default 5). - Credits are pre-charged when the task is created and fully refunded if the task fails.
- Invalid parameters return a 400 error and no credits are charged. Media that cannot be read is reported as a task failure and is also fully refunded.
- Prices are before account multipliers.
Create Task
POST https://api.aivideoapi.ai/v1/videos/generations
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | magi-2.0 |
input | object | Yes | Generation parameters |
callback_url | string | No | URL that receives task completion/failure notifications |
Input Parameters
| Field | Type | Required | Description |
|---|---|---|---|
mode | string | Yes | text_to_video, image_to_video or reference_to_video |
prompt | string | Yes | Up to 8000 characters; English is recommended. Refer to media as @Image1, @Video1, @Audio1, numbered per type from 1 in the order of each list. |
resolution | string | No | Only 1080p (default). |
aspect_ratio | string | No | 21:9, 16:9 (default), 4:3, 1:1, 3:4 or 9:16. auto is not supported. For image_to_video, use the aspect ratio of the first frame. |
duration | integer | No | Output length in seconds, 4–30 (default 5). This is the billed duration. |
generate_audio | boolean | No | Generate native audio. Default true; does not change the price. |
seed | integer | No | 0–4294967295, for reproducible results. |
image_urls | string[] | Depends on mode | image_to_video: required, 1–2 items (item 1 = first frame, optional item 2 = last frame). reference_to_video: up to 10 reference images. Not allowed for text_to_video. |
video_urls | string[] | No | reference_to_video only: up to 5 reference videos, each 2–30 seconds and at most 30 seconds in total. |
audio_urls | string[] | No | reference_to_video only: up to 5 reference audio clips, each and in total at most 30 seconds. |
Media rules by mode:
text_to_video: do not sendimage_urls,video_urlsoraudio_urls.image_to_video: send 1–2image_urls;video_urlsandaudio_urlsare not allowed.reference_to_video: send at least one ofimage_urls,video_urlsoraudio_urls. Audio alone is allowed.
All media must be public, directly downloadable HTTP(S) URLs of at most 4096 characters each (base64 / data URLs are not supported), and must stay reachable until the task finishes.
Examples
Text to video
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2.0",
"callback_url": "https://your-server.com/webhook",
"input": {
"mode": "text_to_video",
"prompt": "A paper boat drifts down a rain-soaked city street at dusk, neon reflections rippling on the water, slow tracking shot",
"aspect_ratio": "16:9",
"duration": 10,
"generate_audio": true
}
}'
Image to video (first and last frame)
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2.0",
"input": {
"mode": "image_to_video",
"prompt": "The camera pulls back as the lighthouse beam sweeps across the stormy sea",
"image_urls": [
"https://example.com/first-frame.png",
"https://example.com/last-frame.png"
],
"aspect_ratio": "16:9",
"duration": 5
}
}'
Reference to video
curl -X POST https://api.aivideoapi.ai/v1/videos/generations \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"model": "magi-2.0",
"input": {
"mode": "reference_to_video",
"prompt": "@Image1 dances on a rooftop at sunset, following the moves in @Video1, in time with @Audio1",
"image_urls": ["https://example.com/character.png"],
"video_urls": ["https://example.com/dance.mp4"],
"audio_urls": ["https://example.com/music.mp3"],
"aspect_ratio": "9:16",
"duration": 15,
"seed": 42
}
}'
Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24"
}
}
Query Task
curl https://api.aivideoapi.ai/v1/tasks/{taskId} \
-H "Authorization: Bearer sk-your-api-key"
Status flow: pending -> processing -> completed or failed. Generation usually takes about 13–20 minutes, and longer when the queue is busy. Prefer callback_url, or poll no more often than every 15 seconds.
- On success the video URL is in
output.urls[0]. It is valid for 24 hours, so download and save it promptly. - If the task fails, the pre-charged credits are fully refunded.
- Tasks for this model cannot be cancelled after submission.
Callback
Pass callback_url when creating the task and the system will POST to your URL when the task completes or fails. See Callbacks for headers and the retry policy.
Completed callback
{
"id": "8b6a5162-5c91-4a42-8e80-4c8ef5486f24",
"status": "completed",
"model": "magi-2.0",
"created_at": 1795700000,
"completed_at": 1795700960,
"output": {
"urls": [
"https://file.aivideoapi.ai/videos/2026/11/26/abc.mp4"
]
}
}
Failed callback
{
"id": "57c8772c-f834-46f3-9b7d-81f92e104050",
"status": "failed",
"model": "magi-2.0",
"created_at": 1795700000,
"error": {
"code": "upstream_error",
"message": "A reference image, video or audio file could not be read. Ensure every URL is public, directly downloadable and in a supported format."
}
}
Common failure reasons: the prompt or media was rejected by the content policy, a media file could not be read, a reference video or audio clip is outside the allowed length, or a general generation failure. Failed tasks are fully refunded.
Notes
- Return a 2xx status as soon as you receive the callback (within 3 seconds is recommended). A non-2xx response or a timeout (10 seconds) triggers up to 3 retries (3 minutes and 10 minutes apart).
- Deduplicate on
X-Task-Idso the same task is not stored twice. GET /v1/tasks/{taskId}is the source of truth for the final status; if all 3 callbacks fail you can still poll.
Error Codes
When a request fails, the API returns a JSON error response:
{
"error": {
"code": "insufficient_credits",
"message": "Your credit balance is too low. Please top up.",
"type": "billing_error"
}
}
Error Reference
| HTTP Status | Code | Type | Description |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | Missing or invalid parameters |
| 401 | invalid_api_key | authentication_error | API key is invalid, disabled, or deleted |
| 402 | insufficient_credits | billing_error | Credit balance too low, please top up |
| 403 | ip_not_allowed | permission_error | Request IP not in the key's allowlist |
| 404 | model_not_found | invalid_request_error | Model does not exist or is inactive |
| 404 | task_not_found | invalid_request_error | Task ID does not exist |
| 429 | rate_limit_exceeded | rate_limit_error | Too many requests, please slow down |
| 429 | spend_limit_exceeded | billing_error | Key spend limit reached (hourly/daily/total) |
| 500 | internal_error | api_error | Unexpected server error |
| 503 | upstream_error | upstream_error | Upstream AI provider returned an error |
Common Scenarios
invalid_request (400)
Returned when required fields are missing or invalid.
{
"error": {
"code": "invalid_request",
"message": "'model' is required.",
"type": "invalid_request_error"
}
}
insufficient_credits (402)
Your balance is too low. Check your balance with GET /v1/credits and top up in Dashboard > Billing.
invalid_api_key (401)
Possible causes:
- The key does not start with
sk- - The key has been disabled or deleted
- The user account has been banned
upstream_error (503)
The upstream AI provider returned an error. This may happen when:
- The input contains sensitive or prohibited content
- The provider is temporarily unavailable
- The request parameters are not supported by the provider
Credits are automatically refunded when a task fails due to upstream errors.