MAGI-2 API Reference
MAGI-2 is served through REST APIs that all share one shape: you POST a JSON body with a prompt, get a task id back, then poll until the video is ready. This page covers the endpoints, the request shape, and the real cost of a call; every parameter and its valid values live on the parameters reference.
Three task endpoints
| Task | What you send | What you get |
|---|---|---|
| Text to video | a prompt | a 1080p, 25fps clip with synchronized audio |
| Image to video | a prompt plus one or more stills | the stills animated into a clip, audio included |
| Reference to video | a prompt plus up to 10 images, 5 videos, 5 audio files | a clip that keeps your characters, products, and voices consistent |
The reference endpoint is the one worth planning around. That reference set — up to 20 media items in one request — is how you keep a face, a logo, or a jacket color stable across a 30-second spot. For the text that goes with it — how to label and scope each file — see MAGI-2 reference prompts.
Request parameters
| Parameter | Default |
|---|---|
| prompt | required |
| aspect_ratio | 16:9 |
| duration | 5 |
| generate_audio | true |
| seed | random |
Those are the defaults hosted platforms document. On Sand AI's own API, duration and aspectRatio are required rather than optional. Three details trip people up:
- duration is a whole number of seconds from 4 to 30 — and the platform you pick may cap it lower.
- Resolution and frame rate are not choices. The model outputs 1080p at 25fps; where a
resolutionfield exists, 1080p is its only value. - prompt can run to 15,000 characters.
Full descriptions are on the MAGI-2 parameters reference.
Submit, then poll
Generation is asynchronous, and processing time varies with clip length and demand — WaveSpeed's docs say as much, and Sand AI's own guidance is to poll about every 10 seconds. Do not hold an HTTP connection open waiting for the result.
# 1. submit
curl -X POST "https://api.example.com/magi-2/text-to-video" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "...", "aspect_ratio": "16:9", "duration": 10, "generate_audio": true}'
# -> {"id": "task_8f21", "status": "queued"}
# 2. poll
curl "https://api.example.com/tasks/task_8f21" -H "Authorization: Bearer $API_KEY"
# -> {"status": "completed", "output": {"video_url": "..."}}
The host name and paths come from whichever provider you use. The body above is the shape hosted platforms such as Higgsfield and WaveSpeed document. Sand AI's own API spells the same settings in camelCase — aspectRatio, generateAudio, plus enhancePrompt to switch prompt enhancement on or off — and sends the prompt and any reference media as items in a parts array. Poll about every 10 seconds, treat a task as failed only after the provider's own timeout, and download the file rather than hotlinking the temporary URL — on Sand AI's API the download link is valid for 60 minutes.
What a call really costs
Sand AI lists MAGI-2 at $0.08 per second of output — $0.80 for a 10-second clip — with audio included and no change for aspect ratio. One trap to handle in code: creating a generation is not idempotent, so resubmitting after a timeout can start a second billable task. The full price table, per-platform notes, and batch math are on the MAGI-2 pricing calculator; the prompt generator builds the caption before you spend anything.
Open weights versus hosted API
Sand AI ships the preview weights openly, so you can also run MAGI-2 yourself on your own GPU. The trade is straightforward: self-hosting removes per-second charges but the preview checkpoint renders a fixed 10-second clip at 1088x1920, with no 30-second option and no aspect-ratio choice. If your product needs varying durations or the full reference set, the hosted API is the shorter path. For the full comparison — parameters, hardware, and when self-hosting pays off — see MAGI-2 Preview.
Failure modes worth handling
- Duration rejected. Higgsfield and WaveSpeed both document 4 to 30 seconds; another host may expose less. Read the error and clamp to your provider's range.
- Prompt too long. 15,000 characters is generous, but generated captions can blow past it if you concatenate blindly.
- Silent video when you expected sound. You sent generate_audio as a string ("false") instead of a boolean.
- Nothing happens for a while. Generation takes minutes, not seconds, and the time varies with clip length and demand. Keep polling instead of resubmitting — a resubmission can start a second billable task.
Written and last checked 26 November 2026. API details change — verify field names against your provider's docs before shipping.