Magi 2 API documentation

Three REST endpoints turn a prompt, a still or a set of reference files into a MAGI-2 clip of 4 to 30 seconds at 1080p with sound. Requests carry one key, jobs run in the background, and every second of output costs 20 credits ($0.20).

Base URL
https://magi2api.app/api/v1
Auth
Authorization: Bearer <key>
Model
magi-2 (MAGI-2 by Sand.ai)
Output
MP4, 1080p, 25 fps, 4–30 s, sound on by default
Price
20 credits per second = $0.20/s
Jobs in flight
2 per account
Result link
valid for 24 hours
Delivery
async job: POST, then poll GET

Quick start

From an empty account to a downloaded clip in three calls. The examples use a five-second text-to-video request, the cheapest useful test.

  1. 1

    Get a key

    Buy any credit pack (from $10), open Settings → API keys and create a key. It is shown once and starts with magi2api_. Keep it on your server, never in browser code.

  2. 2

    Submit the job

    POST your prompt to /videos. The reply comes back at once with HTTP 202, the job id and the credits taken (100 for five seconds).

  3. 3

    Poll, then download

    GET /videos/{id} every 10–15 seconds. When status is completed, download video_url; the link works for a day, so copy the file to your own storage.

# 1. Submit (returns 202 with the job id)
curl -X POST https://magi2api.app/api/v1/videos \
  -H "Authorization: Bearer $MAGI2API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A lighthouse keeper climbs a spiral staircase at dusk, lantern swinging; wind and waves outside, his boots ringing on iron steps.",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'

# 2. Poll until "status" is "completed" or "failed"
curl https://magi2api.app/api/v1/videos/JOB_ID \
  -H "Authorization: Bearer $MAGI2API_KEY"

# 3. Download the clip from "video_url"
curl -L -o clip.mp4 "VIDEO_URL"

Keys and access

Send the key in the Authorization header as a bearer token. An x-api-key header with the bare key is accepted too, for clients that cannot set Authorization.

A key belongs to one account and spends that account's credits. Create as many as you like (one per app or environment makes them easy to revoke) and delete a leaked one from the same settings page; it stops working on the next request.

Generating needs one completed credit pack purchase on the account. Signing up alone does not open the API, and new accounts start with no credits. Reading /credits works for any valid key.

Header
Authorization: Bearer magi2api_xxxxxxxxxxxxxxxx

Settings → API keys

Pricing

One flat rate for every mode: 20 credits for each second you ask for, with sound included and no extra charge for reference files. A credit is worth 1 US cent, so the API costs $0.20 per second of video.

Clip lengthCreditsUSD
4 s80$0.80
5 s100$1.00
10 s200$2.00
15 s300$3.00
30 s600$6.00
Credit packCreditsSeconds of video5 s clips
$101,0005010
$252,50012525
$505,00025050
$10010,000500100
  • Credits are taken when the job is accepted, for the duration you requested.
  • A job that fails gives its credits back automatically. Its status then shows credits_charged: 0 and error.refunded: true.
  • A prompt that is refused, or that could not be checked because the checker was briefly down, is never charged.
  • Packs are one-time purchases with no subscription. Credits from any pack work in the API and in the browser playground.

Buy packs on the pricing page while signed in. Your balance is visible in the dashboard and through GET /credits. Credit packs

Create a video

POST/api/v1/videos

Books one clip. Files are passed as public https links; the API downloads each one before the job is accepted, so a dead link fails the request instead of the render.

FieldTypeDefaultNotes
modelstringmagi-2Only magi-2 is served.
promptstring""Up to 5,000 characters. Required for text and reference jobs (at least 5 characters), optional when image_url is sent.
durationinteger5Whole seconds, 4 to 30. Billed at 20 credits each.
aspect_ratiostring16:916:9, 9:16, 1:1, 4:3, 3:4, 21:9. Ignored for image-to-video, which keeps the shape of your image.
generate_audiobooleantruefalse for a silent clip. The price is the same either way.
image_urlstring—First frame. Turns the job into image-to-video.
last_image_urlstring—Final frame. Only together with image_url.
reference_imagesstring[]—Up to 9 images. Turns the job into reference-to-video.
reference_videosstring[]—Up to 3 clips.
reference_audiosstring[]—Up to 3 audio files.

Unknown fields are rejected with 400 invalid_request, so a typo in a field name does not silently fall back to a default.

Image to video, request body
{
  "image_url": "https://example.com/frames/harbour-first.jpg",
  "last_image_url": "https://example.com/frames/harbour-last.jpg",
  "prompt": "The fishing boat slides out of the harbour as gulls lift off.",
  "duration": 8
}
Reference to video, request body
{
  "prompt": "The woman from @image_1 dances in the street from @image_2, moving like the dancer in @video_1, to the beat of @audio_1.",
  "reference_images": [
    "https://example.com/ref/dancer.png",
    "https://example.com/ref/street.jpg"
  ],
  "reference_videos": [
    "https://example.com/ref/moves.mp4"
  ],
  "reference_audios": [
    "https://example.com/ref/beat.mp3"
  ],
  "duration": 10,
  "aspect_ratio": "9:16"
}
Response: 202 Accepted
{
  "id": "f3a9c2e1-7b44-4d0e-9a51-2c6b8e0d4f17",
  "object": "video",
  "model": "magi-2",
  "mode": "text-to-video",
  "status": "queued",
  "duration": 5,
  "aspect_ratio": "16:9",
  "resolution": "1080p",
  "generate_audio": true,
  "credits_charged": 100,
  "created_at": "2026-11-25T18:04:12.000Z",
  "status_url": "https://magi2api.app/api/v1/videos/f3a9c2e1-7b44-4d0e-9a51-2c6b8e0d4f17"
}

Get a video

GET/api/v1/videos/{id}

Returns the job as it stands. Only the account that created a job can read it; any other key gets 404.

queued
Accepted and waiting for a render slot upstream.
processing
Rendering.
completed
Done. video_url is a signed link to the MP4, valid for 24 hours from this response; ask again for a fresh one.
failed
Not produced. error.message says why and error.refunded tells you the credits went back.
FieldMeaning
idJob id, as returned when you created it.
modetext-to-video, image-to-video or reference-to-video, decided by which fields you sent.
statusqueued, processing, completed or failed.
aspect_ratioThe ratio you asked for, or null for image-to-video (the image decides).
credits_chargedWhat the job costs you now: the full price while it runs or once it completes, 0 after a refund.
video_urlSigned MP4 link when completed, otherwise null.
video_url_expires_inSeconds until video_url stops working.
errornull, or { message, refunded } for a failed job.
created_at / completed_atISO 8601 timestamps, UTC.
200, completed
{
  "id": "f3a9c2e1-7b44-4d0e-9a51-2c6b8e0d4f17",
  "object": "video",
  "model": "magi-2",
  "mode": "text-to-video",
  "status": "completed",
  "duration": 5,
  "aspect_ratio": "16:9",
  "resolution": "1080p",
  "credits_charged": 100,
  "video_url": "https://magi2api.app/api/storage/shared/videos/...mp4?expires=...&signature=...",
  "video_url_expires_in": 86400,
  "error": null,
  "created_at": "2026-11-25T18:04:12.000Z",
  "completed_at": "2026-11-25T18:09:47.000Z"
}
200, failed (fields shortened)
{
  "id": "f3a9c2e1-7b44-4d0e-9a51-2c6b8e0d4f17",
  "status": "failed",
  "credits_charged": 0,
  "video_url": null,
  "error": {
    "message": "The video could not be generated on the model side. Please try again.",
    "refunded": true
  }
}

Most clips finish in about 15 to 20 minutes, longer at peak times. When the main inference route turns a job down, cannot start it within 30 minutes or fails it, the job moves once to a backup route, which usually takes another 3 to 10 minutes. A job that still has no clip is given up and refunded.

Check your balance

GET/api/v1/credits

The credit balance of the account the key belongs to, and the current API rate. Useful as a cheap check that a key works before you send a paid job.

200
{
  "object": "credits",
  "balance": 900,
  "magi_2_credits_per_second": 20
}

Input modes

There is one endpoint for all three modes. The fields you send decide which one runs, and the mode comes back in the response.

Text to video

prompt

Describe the scene, the action, the camera and what should be heard. Lines of dialogue written into the prompt come out spoken, with matching lip movement. aspect_ratio applies.

Image to video

image_url, optional last_image_url, optional prompt

The clip opens on your image and, with last_image_url, ends on the second one. The frame shape follows the image: aspect_ratio is not applied, so crop the image to the ratio you want before you send it.

Reference to video

prompt plus reference_images / reference_videos / reference_audios

Up to 12 files in total (9 images, 3 clips, 3 audio). Point at them in the prompt by kind and position: @image_1, @video_1, @audio_1 (the @Image1 form works too). Cannot be combined with image_url.

Field kindAccepted formats
ImagesJPEG, PNG, WebP
VideoMP4, MOV, WebM
AudioMP3, WAV, M4A, AAC, OGG

Each file at most 25 MB, served over https with a correct Content-Type header. A link that answers with an HTML page (a sharing page instead of the file itself) is rejected as unsupported_file.

Errors

Every error has the same shape: an HTTP status and a JSON body with a stable code and a sentence you can show a user. Branch on code, not on message.

429
{
  "error": {
    "code": "too_many_active_jobs",
    "message": "An account can have 2 videos queued or rendering at once. Wait for one to finish, then send this request again."
  }
}
HTTPcodeWhat happenedWhat to do
400invalid_json / invalid_requestThe body is not JSON, a field is missing, out of range or unknown.Fix the field named in the message.
400prompt_rejectedThe prompt asks for content Magi 2 does not make.Rewrite the prompt. Nothing was charged.
400file_unreachableA link could not be downloaded (timeout, 4xx/5xx).Check the link is public and direct.
400unsupported_file / file_too_largeWrong file type for that field, empty, or over 25 MB.Convert or shrink the file.
401missing_api_key / invalid_api_keyNo key, or a key that is wrong, expired or deleted.Send a current key.
402insufficient_creditsThe balance is below the price of the clip.Top up, or ask for fewer seconds.
403purchase_requiredThe account has not bought a credit pack yet.Buy any pack, then retry with the same key.
403account_suspendedThe account has been suspended.Contact support@magi2api.app.
404not_foundNo job with that id on this account.Check the id and the key.
405method_not_allowedWrong HTTP method, for example GET /videos.Use the method in the Allow header.
429too_many_active_jobs2 videos are already queued or rendering on the account.Wait for one to finish, then resend.
503moderation_unavailableThe prompt check could not run just now.Retry in a minute. Nothing was charged.
500internal_errorSomething failed on our side.Retry; if it repeats, email us the time and request.

A job that was accepted and later fails does not return an error code from POST: it shows status failed on GET /videos/{id}, with the reason in error.message and the credits back on the balance.

Limits

  • 2 videos queued or rendering per account at once, counting playground jobs too. The next POST gets 429 until one finishes.
  • Clip length: whole seconds from 4 to 30. Output is always 1080p at 25 fps.
  • Reference files: 12 per request at most (9 images, 3 clips, 3 audio), 25 MB each.
  • No per-key request quota on polling or balance checks; poll every 10–15 seconds, there is nothing to gain from polling faster.
  • Result links expire after 24 hours. The clip itself stays in your account history, where you can also download it.
  • There are no webhooks: completion is read by polling GET /videos/{id}.

Magi 2 API FAQ

Is this the official Sand.ai API?

No. Magi2API is an independent service: it runs Sand.ai’s MAGI-2 through third-party inference providers and sells access by the second. Sand.ai has not published a public API or price of its own.

Is there a free tier or trial?

No. Accounts start at zero credits and the API opens with the first pack; the smallest is $10 for 1,000 credits, enough for 50 seconds of video. A failed job costs nothing, so you only pay for clips you receive.

How much does a Magi 2 API call cost?

20 credits ($0.20) per second requested, the same for every mode, with sound included: $1.00 for a five-second clip and $6.00 for the full 30 seconds.

How long does one video take?

Usually 15 to 20 minutes from POST to completed, depending on the clip length and how busy the upstream queue is. Plan for longer at peak times and poll rather than holding a request open.

Can I set the aspect ratio for image-to-video?

No. When image_url is sent the clip takes the shape of the image, and aspect_ratio is ignored (the response shows aspect_ratio: null). Crop the image first.

Do you send a webhook when the video is ready?

No. Poll GET /videos/{id}; status changes to completed or failed, and a completed job carries the download link.

Where do I find my API key?

Signed in, open Settings → API keys. A key is shown in full only once, when it is created; if you lose it, delete it and create another.

Ready for your first clip?

Buy a pack, create a key and send the five-second example above: 100 credits, refunded if it fails.