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.

  1. Get an API keyCreate one in your dashboard and keep it on your server.
  2. Send your first requestRun the snippet with your key in the Authorization header.
  3. 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.

HTTP
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.

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

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

Request body (JSON)

ParameterJSON
  • promptstringOptional

    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.

  • durationintegerOptional

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

  • aspect_ratiostringOptional

    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_audiobooleanOptional

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

  • first_frame_urlstringOptional

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

  • last_frame_urlstringOptional

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

  • image_urlsstring[]Optional

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

  • video_urlsstring[]Optional

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

  • audio_urlsstring[]Optional

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

  • seedintegerOptional

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

  • modelstringOptional

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

Example: text-to-video

JSON
{  "prompt": "A lighthouse keeper climbs a spiral staircase at dusk, waves crashing outside, wind and footsteps audible",  "duration": 5,  "aspect_ratio": "16:9"}

Example: image-to-video with first and last frame

JSON
{  "prompt": "She turns toward the camera and smiles as the wind lifts her hair",  "first_frame_url": "https://example.com/portrait.jpg",  "last_frame_url": "https://example.com/portrait-smile.jpg",  "duration": 6}

Example: reference-to-video with images and a voice clip

JSON
{  "prompt": "The chef from the reference photos plates a dessert in the reference kitchen, speaking to camera in the voice from the audio clip",  "image_urls": ["https://example.com/chef.jpg", "https://example.com/kitchen.jpg"],  "audio_urls": ["https://example.com/voice.mp3"],  "aspect_ratio": "9:16",  "duration": 10}

Responses

code:200
message:"success"
data:3 keys
task_id:"n89a1b2c3d4e5f60718293a4b5c6d7e8f90magi2"
status:"IN_PROGRESS"
consumed_credits:90
codenumber

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

Parameter
  • task_idstringRequired

    The task_id returned by /v1/generate.

Example request

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

Task fields

FieldJSON
  • task_idstringOptional

    Task identifier.

  • statusstringOptional

    IN_PROGRESS while generating, then SUCCESS or FAILED.

  • typestringOptional

    The mode the API picked for this task.

  • consumed_creditsnumberOptional

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

  • responsestring[]Optional

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

  • error_messagestring | nullOptional

    Why the task failed, or null.

  • created_atstringOptional

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

  • requestobjectOptional

    The request as it was submitted, after defaults were applied.

Responses

code:200
message:"success"
data:9 keys
task_id:"n89a1b2c3d4e5f60718293a4b5c6d7e8f90magi2"
status:"SUCCESS"
model:"magi-2"
type:"text-to-video"
consumed_credits:90
error_message:null
created_at:"2026-11-26 08:30:12"
request:5 keys
type:"text-to-video"
prompt:"A lighthouse keeper climbs a spiral staircase at dusk…"
duration:5
aspect_ratio:"16:9"
generate_audio:true
response:1 item
0:"https://cdn.example.com/videos/your-video.mp4"
codenumber

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

Parameter
  • pageintegerOptional

    Page number, starting at 1. Defaults to 1.

  • limitintegerOptional

    Tasks per page, from 1 to 100. Defaults to 20.

  • typestringOptional

    Only return one mode.

Example request

Bash
curl 'https://magi2.studio/v1/tasks?page=1&limit=20' \  -H 'Authorization: Bearer YOUR_API_KEY'

Responses

code:200
message:"success"
data:2 keys
tasks:1 item
0:9 keys
task_id:"n89a1b2c3d4e5f60718293a4b5c6d7e8f90magi2"
status:"SUCCESS"
model:"magi-2"
type:"text-to-video"
consumed_credits:90
error_message:null
created_at:"2026-11-26 08:30:12"
request:5 keys
type:"text-to-video"
prompt:"A lighthouse keeper climbs a spiral staircase at dusk…"
duration:5
aspect_ratio:"16:9"
generate_audio:true
response:1 item
0:"https://cdn.example.com/videos/your-video.mp4"
pagination:3 keys
page:1
limit:20
total:1
codenumber

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

API key
Headers
Request Body
Ctrl ↵to send
  1. PreparedPOST
  2. Sent—
  3. Response—
Send a request to see the response here.

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.

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