MAGI-2

MAGI-2 generates 4–30 second 1080p videos with optional native audio. It has three modes:

modeWhat it does
text_to_videoGenerate a video from the prompt alone
image_to_videoAnimate a first frame, optionally ending on a last frame
reference_to_videoGenerate 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 nameDescription
magi-2.0Text, 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.

ResolutionCredits/s5s10s15s30s
1080p20.8104208312624
  • 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

FieldTypeRequiredDescription
modelstringYesmagi-2.0
inputobjectYesGeneration parameters
callback_urlstringNoURL that receives task completion/failure notifications

Input Parameters

FieldTypeRequiredDescription
modestringYestext_to_video, image_to_video or reference_to_video
promptstringYesUp to 8000 characters; English is recommended. Refer to media as @Image1, @Video1, @Audio1, numbered per type from 1 in the order of each list.
resolutionstringNoOnly 1080p (default).
aspect_ratiostringNo21: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.
durationintegerNoOutput length in seconds, 4–30 (default 5). This is the billed duration.
generate_audiobooleanNoGenerate native audio. Default true; does not change the price.
seedintegerNo0–4294967295, for reproducible results.
image_urlsstring[]Depends on modeimage_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_urlsstring[]Noreference_to_video only: up to 5 reference videos, each 2–30 seconds and at most 30 seconds in total.
audio_urlsstring[]Noreference_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 send image_urls, video_urls or audio_urls.
  • image_to_video: send 1–2 image_urls; video_urls and audio_urls are not allowed.
  • reference_to_video: send at least one of image_urls, video_urls or audio_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-Id so 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 StatusCodeTypeDescription
400invalid_requestinvalid_request_errorMissing or invalid parameters
401invalid_api_keyauthentication_errorAPI key is invalid, disabled, or deleted
402insufficient_creditsbilling_errorCredit balance too low, please top up
403ip_not_allowedpermission_errorRequest IP not in the key's allowlist
404model_not_foundinvalid_request_errorModel does not exist or is inactive
404task_not_foundinvalid_request_errorTask ID does not exist
429rate_limit_exceededrate_limit_errorToo many requests, please slow down
429spend_limit_exceededbilling_errorKey spend limit reached (hourly/daily/total)
500internal_errorapi_errorUnexpected server error
503upstream_errorupstream_errorUpstream 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.