REST API v1 · model: "magi-2"

MAGI-2 API Reference (Sand.ai MAGI-2)

MAGI-2 API is an independent REST API platform for Sand.ai's MAGI-2 model. Call POST /v1/videos/tasks to start a render, poll GET /v1/tasks/:task_id every 8 seconds, and archive the 1080p 25fps MP4 within 72 hours.

Authentication & Gateway URL

Authenticate every request using HTTP Bearer auth headers: Content-Type: application/json and Authorization: Bearer <MAGI2_API_KEY>.

Manage your account credentials in Settings -> API Keys and fund usage balance in Settings -> Credits.

Base URL
https://magi2api.net/api
Header
Authorization: Bearer <YOUR_MAGI2_API_KEY>

Core Endpoints

Backend integration spans five endpoints for creating video tasks, polling status, listing history, uploading local files, and checking credit usage.

MethodEndpointResponsibilityResponse
POST/v1/videos/tasksCreate an asynchronous MAGI-2 generation task and return task ID201 Created
GET/v1/tasks/{task_id}Query task status (queued, processing, succeeded, failed) and output URL200 OK
GET/v1/tasksList recent generation tasks belonging to the authenticated key200 OK
POST/v1/filesUpload local image/audio (<=50 MB) or video (<=100 MB) for HTTPS URLs201 Created
GET/v1/usage?period=7dInspect aggregated credit consumption over 24h, 7d, 30d, or all200 OK

Four Input Modes & Mutual-Exclusion Rules

MAGI-2 classifies each task payload automatically from present input arrays and rejects conflicting parameter sets.

1. Text-to-Video

Omit images[] and all reference_* arrays. Set aspect_ratio to 16:9, 9:16, 1:1, 4:3, 3:4, or 21:9.

2. First-Frame Image-to-Video

Provide images[] with 1 public HTTPS URL. MAGI-2 locks start composition; omit aspect_ratio.

3. First-and-Last Keyframes

Provide images[] with 2 public HTTPS URLs (start, end). MAGI-2 interpolates motion between frames; omit aspect_ratio.

4. Multimodal Reference-to-Video

Provide reference_images (<=10), reference_videos (<=5), and reference_audios (<=5). Bind them inline via @image1, @video1, @audio1.

MAGI-2 API rejects requests that combine images[] with reference_* fields. Each reference video or audio clip must run 2 to 30 seconds with a 30-second total cap per type.

Request Body Parameters (POST /v1/videos/tasks)

All fields below match live validation constraints enforced on model="magi-2" before tasks enter the queue.

ParameterTypeDefaultConstraints & Behavior
modelstring (req)magi-2Required literal "magi-2". Identifies Sand.ai MAGI-2 execution pipeline.
promptstring (req)-Required UTF-8 text directive, 1–5000 characters. Supports @imageN, @videoN, @audioN.
durationinteger5Integer seconds between 4 and 30 inclusive. Bills linearly at $0.088/second.
aspect_ratioenum16:9Allowed values: 16:9, 9:16, 1:1, 4:3, 3:4, 21:9. Forbidden when images[] is set.
resolutionenum1080pFixed to "1080p" (25 fps). Passing 480p or 720p returns 422.
generate_audiobooleantrueGenerates synchronized bilingual voice and ambient sound effects alongside video.
seedintegerrandomOptional integer from 0 to 2147483647 for reproducible noise initialization.
imagesstring[][]1 or 2 public HTTPS URLs. Sets First-Frame or First-Last Keyframe mode.
reference_imagesstring[][]Up to 10 public HTTPS image URLs referenced inline as @image1..@image10.
reference_videosstring[][]Up to 5 public HTTPS video URLs (2–30s each, 30s total) bound via @video1..@video5.
reference_audiosstring[][]Up to 5 public HTTPS audio URLs (2–30s each, 30s total) bound via @audio1..@audio5.
callback_urlstring-Optional HTTPS webhook URL (<=2048 chars) receiving signed task updates.

Asynchronous Submit & Poll Examples

Pass an explicit Idempotency-Key header (<=255 chars, 24h window) on POST /v1/videos/tasks so retries never create duplicate jobs.

POST /v1/videos/tasks · Async Poll Pattern
curl -X POST "https://magi2api.net/api/v1/videos/tasks" \
  -H "Authorization: Bearer $MAGI2_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: magi2-shot-001" \
  -d '{
    "model": "magi-2",
    "prompt": "@image1 stands inside the workshop from @image2. Track her hand movement matching @video1 while preserving the acoustic cadence of @audio1.",
    "duration": 8,
    "aspect_ratio": "16:9",
    "resolution": "1080p",
    "generate_audio": true,
    "reference_images": [
      "https://example.com/refs/character.png",
      "https://example.com/refs/workshop.png"
    ],
    "reference_videos": ["https://example.com/refs/motion.mp4"],
    "reference_audios": ["https://example.com/refs/voice.mp3"]
  }'

Response Lifecycle & 72-Hour Retention

Task creation returns HTTP 201 containing data.id, initial status ("queued"), and poll_after_seconds (8 by default).

Clients poll GET /v1/tasks/:task_id at or above poll_after_seconds until data.status transitions to "succeeded" or "failed".

Completed data.output.url links expire after 72 hours. Services must download and persist generated MP4 files into durable R2 or S3 storage immediately.

Response & Error Payload Formats
{
  "data": {
    "id": "tsk_01JXYZMAGI2DEMO",
    "model": "magi-2",
    "status": "queued",
    "created_at": "2026-11-27T04:10:00Z"
  },
  "poll_after_seconds": 8
}

Uploading Local Media (POST /v1/files)

Upload local assets to POST /v1/files before submitting a generation job. Images and audio accept up to 50 MB; videos accept up to 100 MB.

HTTP Error Reference

The API returns standard HTTP status codes paired with structured JSON error descriptions.

Status CodeRoot Cause & Client Action
400 Bad RequestMalformed JSON body or missing required parameters. Fix syntax before retrying.
401 UnauthorizedMissing or invalid Bearer API key. Check your key status inside the console.
402 Payment RequiredInsufficient credit balance for this render duration. Top up your console balance and retry.
404 Not FoundTask ID does not exist or belongs to a different account key.
422 UnprocessableValidation failed (e.g., images + reference_* conflict, 720p requested, or aspect_ratio sent with images[]).
429 Rate LimitedAccount rate limit exceeded. Apply exponential backoff respecting Retry-After.
5xx Server ErrorUpstream node error. Retry safely with the same Idempotency-Key; failed tasks refund 100%.