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.
- Get an API keyCreate one in your dashboard and keep it on your server.
- Send your first requestRun the snippet with your key in the Authorization header.
- Read the resultCheck the JSON response. Long jobs return a task ID you can poll.
# 1. Create a taskcurl -X POST 'https://magi2.studio/v1/generate' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "prompt": "A lighthouse keeper climbs a spiral staircase at dusk, waves crashing outside, wind and footsteps audible", "duration": 5, "aspect_ratio": "16:9" }'# 2. Poll until status is SUCCESS or FAILEDcurl 'https://magi2.studio/v1/status?task_id=YOUR_TASK_ID' \ -H 'Authorization: Bearer YOUR_API_KEY'Authentication
Every request needs your API key in the Authorization header as a Bearer token.
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
Validates the request, charges the credits and returns a task_id within seconds. The video itself is delivered by /v1/status.
Request body (JSON)
promptstringOptionalWhat 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.
durationintegerOptionalLength of the video in whole seconds, from 4 to 30. Defaults to
5.aspect_ratiostringOptionalFrame 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_audiobooleanOptionalGenerate synchronized audio (dialogue, effects, ambience, music). Set false for a silent clip; the price is the same. Defaults to
true.first_frame_urlstringOptionalPublic image URL used as the exact first frame (image-to-video).
last_frame_urlstringOptionalPublic image URL used as the last frame. Requires first_frame_url.
image_urlsstring[]OptionalUp to 10 public reference image URLs (reference-to-video).
video_urlsstring[]OptionalUp to 5 public reference video URLs for motion, camera or style (reference-to-video).
audio_urlsstring[]OptionalUp to 5 public reference audio URLs for voice, music or rhythm (reference-to-video).
seedintegerOptionalOptional integer from 0 to 2147483647 for more repeatable results. Random when omitted.
modelstringOptionalOptional. The only value is magi-2. Defaults to
magi-2.
Example: text-to-video
Example: image-to-video with first and last frame
Example: reference-to-video with images and a voice clip
Responses
Returns 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
task_idstringRequiredThe task_id returned by /v1/generate.
Example request
Task fields
task_idstringOptionalTask identifier.
statusstringOptionalIN_PROGRESS while generating, then SUCCESS or FAILED.
typestringOptionalThe mode the API picked for this task.
consumed_creditsnumberOptionalCredits charged for the task. Becomes 0 after a failed task is refunded.
responsestring[]OptionalMP4 URL(s) when status is SUCCESS; empty otherwise. Download and store the file on your side.
error_messagestring | nullOptionalWhy the task failed, or null.
created_atstringOptionalCreation time in UTC (YYYY-MM-DD HH:MM:SS).
requestobjectOptionalThe request as it was submitted, after defaults were applied.
Responses
Tasks created with this API key, newest first. Statuses are stored values: call /v1/status to refresh a task that is still IN_PROGRESS.
Query parameters
pageintegerOptionalPage number, starting at 1. Defaults to
1.limitintegerOptionalTasks per page, from 1 to 100. Defaults to
20.typestringOptionalOnly return one mode.
Example request
Responses
Try it
Send real requests from this page with your API key. Creating a task here is billed like any other request.
API Playground
POST/v1/generate
- Prepared
- Sent
- Response
Recent calls
Calls you send in this session show up here.
Errors
Every response has the same envelope: code, message and data. On errors data is null and message explains what to change.
| HTTP | Meaning |
|---|---|
| 400Bad 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. |
| 401Unauthorized | The Authorization header is missing, or the API key is invalid or revoked. |
| 402 | Not enough credits for this task. Top up and retry. |
| 404Not Found | The task_id does not exist or belongs to a different API key. |
| 405 | Wrong HTTP method for this endpoint. |
| 500Internal Server Error | Unexpected error. If a task was created and fails, its credits are refunded; retry after a short wait. |
| 503Service 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.