MAGI-2 API Reference
Generate 1080p MAGI-2 videos with synchronized audio from your own code. One endpoint creates a task, one returns its status and video URL, one lists your history. Every request uses your Magi2 Studio API key and the same credits as the studio.
New to the API? The integration guide walks through your first request, polling, saving the video and handling errors. → Read the integration guide
Quickstart
Create a task, then poll its status until the video is ready. Replace YOUR_API_KEY with a key from your dashboard.
| 1 | "b-c"># 1. Create a task |
| 2 | curl -X POST 'https://magi2.studio/v1/generate' \ |
| 3 | -H 'Authorization: Bearer YOUR_API_KEY' \ |
| 4 | -H 'Content-Type: application/json' \ |
| 5 | -d '{ |
| 6 | "prompt": "A lighthouse keeper climbs a spiral staircase at dusk, waves crashing outside, wind and footsteps audible", |
| 7 | "duration": 5, |
| 8 | "aspect_ratio": "16:9" |
| 9 | }' |
| 10 | |
| 11 | "b-c"># 2. Poll until status is SUCCESS or FAILED |
| 12 | curl 'https://magi2.studio/v1/status?task_id=YOUR_TASK_ID' \ |
| 13 | -H 'Authorization: Bearer YOUR_API_KEY' |
Authentication
Every request needs your API key in the Authorization header as a Bearer token.
| 1 | Authorization: Bearer YOUR_API_KEY |
Keep keys on the server. Anyone with a key can spend its credits. Never put it in browser or mobile code, and revoke a key from the dashboard if it leaks. → Create an API key
Generation modes
There is no mode field: the API picks the mode from the inputs you send. Frames and references cannot be mixed in one request.
| Mode | Send | Notes |
|---|---|---|
| text-to-video | prompt | Prompt only. Aspect ratio defaults to 16:9. |
| image-to-video | first_frame_url (+ last_frame_url, prompt) | The image becomes the first frame; add last_frame_url to set the ending. The video keeps the first frame's aspect ratio, and the prompt is optional. |
| reference-to-video | prompt + image_urls / video_urls / audio_urls | Up to 10 images, 5 videos and 5 audio clips keep characters, products, places, motion or voices consistent. A prompt is required. |
Pricing
Every mode costs the same: 18 credits per second of output at 1080p. Reference images, videos and audio never cost extra.
| Output | Credits |
|---|---|
| 4s · 1080p | 72 credits |
| 5s · 1080p | 90 credits |
| 10s · 1080p | 180 credits |
| 15s · 1080p | 270 credits |
| 30s · 1080p | 540 credits |
Credits are charged when the task is created and refunded automatically if it fails. API calls and the browser studio share one credit balance. → Buy credits or a plan
Endpoints
/v1/generateValidates the request, charges the credits and returns a task_id within seconds. The video itself is delivered by /v1/status.
Request body (JSON)
What happens in the shot: subject, action, camera, style, dialogue and sound. Up to 15,000 characters. Required for text-to-video and reference-to-video; optional with first_frame_url.
Length of the video in whole seconds, from 4 to 30. Defaults to 5.
Frame shape for text-to-video and reference-to-video. Ignored with first_frame_url, where the video follows the first frame. Defaults to 16:9.
Generate synchronized audio (dialogue, effects, ambience, music). Set false for a silent clip; the price is the same. Defaults to true.
Public image URL used as the exact first frame (image-to-video).
Public image URL used as the last frame. Requires first_frame_url.
Up to 10 public reference image URLs (reference-to-video).
Up to 5 public reference video URLs for motion, camera or style (reference-to-video).
Up to 5 public reference audio URLs for voice, music or rhythm (reference-to-video).
Optional integer from 0 to 2147483647 for more repeatable results. Random when omitted.
Optional. The only value is magi-2. Defaults to magi-2.
Example: text-to-video
| 1 | { |
| 2 | "prompt": "A lighthouse keeper climbs a spiral staircase at dusk, waves crashing outside, wind and footsteps audible", |
| 3 | "duration": 5, |
| 4 | "aspect_ratio": "16:9" |
| 5 | } |
Example: image-to-video with first and last frame
| 1 | { |
| 2 | "prompt": "She turns toward the camera and smiles as the wind lifts her hair", |
| 3 | "first_frame_url": "https://example.com/portrait.jpg", |
| 4 | "last_frame_url": "https://example.com/portrait-smile.jpg", |
| 5 | "duration": 6 |
| 6 | } |
Example: reference-to-video with images and a voice clip
| 1 | { |
| 2 | "prompt": "The chef from the reference photos plates a dessert in the reference kitchen, speaking to camera in the voice from the audio clip", |
| 3 | "image_urls": ["https://example.com/chef.jpg", "https://example.com/kitchen.jpg"], |
| 4 | "audio_urls": ["https://example.com/voice.mp3"], |
| 5 | "aspect_ratio": "9:16", |
| 6 | "duration": 10 |
| 7 | } |
Responses
| 1 | { |
| 2 | "code": 200, |
| 3 | "message": "success", |
| 4 | "data": { |
| 5 | "task_id": "n89a1b2c3d4e5f60718293a4b5c6d7e8f90magi2", |
| 6 | "status": "IN_PROGRESS", |
| 7 | "consumed_credits": 90 |
| 8 | } |
| 9 | } |
/v1/statusReturns the task's current status. Poll every 15–30 seconds until status is SUCCESS or FAILED. Only tasks created with the same API key are visible.
Query parameters
The task_id returned by /v1/generate.
Example request
| 1 | curl 'https://magi2.studio/v1/status?task_id=n89a1b2c3d4e5f60718293a4b5c6d7e8f90magi2' \ |
| 2 | -H 'Authorization: Bearer YOUR_API_KEY' |
Task fields
Task identifier.
IN_PROGRESS while generating, then SUCCESS or FAILED.
The mode the API picked for this task.
Credits charged for the task. Becomes 0 after a failed task is refunded.
MP4 URL(s) when status is SUCCESS; empty otherwise. Download and store the file on your side.
Why the task failed, or null.
Creation time in UTC (YYYY-MM-DD HH:MM:SS).
The request as it was submitted, after defaults were applied.
Responses
| 1 | { |
| 2 | "code": 200, |
| 3 | "message": "success", |
| 4 | "data": { |
| 5 | "task_id": "n89a1b2c3d4e5f60718293a4b5c6d7e8f90magi2", |
| 6 | "status": "SUCCESS", |
| 7 | "model": "magi-2", |
| 8 | "type": "text-to-video", |
| 9 | "consumed_credits": 90, |
| 10 | "error_message": null, |
| 11 | "created_at": "2026-11-26 08:30:12", |
| 12 | "request": { |
| 13 | "type": "text-to-video", |
| 14 | "prompt": "A lighthouse keeper climbs a spiral staircase at dusk…", |
| 15 | "duration": 5, |
| 16 | "aspect_ratio": "16:9", |
| 17 | "generate_audio": true |
| 18 | }, |
| 19 | "response": [ |
| 20 | "https://cdn.example.com/videos/your-video.mp4" |
| 21 | ] |
| 22 | } |
| 23 | } |
/v1/tasksTry it
Send real requests from this page with your API key. Creating a task here is billed like any other request.
Errors
Every response has the same envelope: code, message and data. On errors data is null and message explains what to change.
| HTTP | Meaning |
|---|---|
| 400 Bad Request | A parameter is missing or invalid (for example duration out of range, a non-public URL, or frames mixed with references). Nothing is charged. |
| 401 Unauthorized | The Authorization header is missing, or the API key is invalid or revoked. |
| 402 | Not enough credits for this task. Top up and retry. |
| 404 Not Found | The task_id does not exist or belongs to a different API key. |
| 405 | Wrong HTTP method for this endpoint. |
| 500 Internal Server Error | Unexpected error. If a task was created and fails, its credits are refunded; retry after a short wait. |
| 503 Service Unavailable | The generation service is temporarily unavailable. Retry later. |
FAQ
How much does a MAGI-2 API call cost?
18 credits per second of output in every mode, so a 5-second clip costs 90 credits. Failed tasks are refunded automatically.
How long does a video take?
Most clips finish within a few minutes; longer clips and busy periods take longer. Poll /v1/status every 15–30 seconds instead of submitting again.
Can I upload local files?
No. Images, videos and audio must be public http(s) URLs that our servers can download, such as files in your own storage bucket or CDN.
Do API calls show up in my dashboard?
Yes. The API call logs page in the dashboard lists every task per API key with its request, status, credits and video.
Is there an MCP server for AI agents?
Yes. Connect Claude, Cursor, Codex or any MCP client to the MCP endpoint with the same API key; see the MCP server page.
MAGI-2 is a video model published by Sand.ai. Magi2 Studio is an independent service that runs it through a third-party API provider; it is not operated by, affiliated with or endorsed by Sand.ai.