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.

REST · JSON · MAGI-2 Base URL: https://magi2.studio/v1

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.

bash
1"b-c"># 1. Create a task
2curl -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
12curl '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.

http
1Authorization: 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.

ModeSendNotes
text-to-videopromptPrompt only. Aspect ratio defaults to 16:9.
image-to-videofirst_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-videoprompt + image_urls / video_urls / audio_urlsUp 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.

OutputCredits
4s · 1080p72 credits
5s · 1080p90 credits
10s · 1080p180 credits
15s · 1080p270 credits
30s · 1080p540 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

POST/v1/generate

Validates the request, charges the credits and returns a task_id within seconds. The video itself is delivered by /v1/status.

Request body (JSON)

Body ParametersJSON
prompt:optional string

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.

duration:optional integer

Length of the video in whole seconds, from 4 to 30. Defaults to 5.

aspect_ratio:optional string

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_audio:optional boolean

Generate synchronized audio (dialogue, effects, ambience, music). Set false for a silent clip; the price is the same. Defaults to true.

first_frame_url:optional string

Public image URL used as the exact first frame (image-to-video).

last_frame_url:optional string

Public image URL used as the last frame. Requires first_frame_url.

image_urls:optional string[]

Up to 10 public reference image URLs (reference-to-video).

video_urls:optional string[]

Up to 5 public reference video URLs for motion, camera or style (reference-to-video).

audio_urls:optional string[]

Up to 5 public reference audio URLs for voice, music or rhythm (reference-to-video).

seed:optional integer

Optional integer from 0 to 2147483647 for more repeatable results. Random when omitted.

model:optional string

Optional. The only value is magi-2. Defaults to magi-2.

Example: text-to-video

json
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

json
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

json
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}
GET/v1/status

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

Body ParametersJSON
task_id:string

The task_id returned by /v1/generate.

Example request

bash
1curl 'https://magi2.studio/v1/status?task_id=n89a1b2c3d4e5f60718293a4b5c6d7e8f90magi2' \
2 -H 'Authorization: Bearer YOUR_API_KEY'

Task fields

Body ParametersJSON
task_id:optional string

Task identifier.

status:optional string

IN_PROGRESS while generating, then SUCCESS or FAILED.

type:optional string

The mode the API picked for this task.

consumed_credits:optional number

Credits charged for the task. Becomes 0 after a failed task is refunded.

response:optional string[]

MP4 URL(s) when status is SUCCESS; empty otherwise. Download and store the file on your side.

error_message:optional string | null

Why the task failed, or null.

created_at:optional string

Creation time in UTC (YYYY-MM-DD HH:MM:SS).

request:optional object

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}
GET/v1/tasks

Try it

Send real requests from this page with your API key. Creating a task here is billed like any other request.

API PlaygroundPOST

Errors

Every response has the same envelope: code, message and data. On errors data is null and message explains what to change.

HTTPMeaning
400 Bad RequestA parameter is missing or invalid (for example duration out of range, a non-public URL, or frames mixed with references). Nothing is charged.
401 UnauthorizedThe 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 FoundThe task_id does not exist or belongs to a different API key.
405 Wrong HTTP method for this endpoint.
500 Internal Server ErrorUnexpected error. If a task was created and fails, its credits are refunded; retry after a short wait.
503 Service UnavailableThe 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.