Skip to main content
MAGIAI
Getting Started|Verified as of 2026-12-02|TechArticle

MAGI-2 API Quickstart: First 4-Second 1080p Render in 5 Minutes

Flagship 480B MAGI-2 runs strictly as an asynchronous REST API: submit a JSON payload specifying duration (integer 4–30s) and prompt (up to 15,000 chars) to receive an immediate prediction request_id, then poll the prediction endpoint every 20–30 seconds until the 1080p @ 25fps audio-video MP4 completes (7–26 minutes observed). Always validate credentials and framing with a 4-second audition ($0.32 wholesale / 40 Studio credits) first.

Submit Endpoint
POST /api/v1/model/generateVideo
Poll Endpoint
GET /api/v1/model/prediction/{id}
4s Audition Cost
$0.32 wholesale / 40 cr
Observed Latency
7–26 minutes async

1. Choose your integration path (MagiAI Studio vs. Direct Atlas / Multi-Model)

Before writing HTTP client code, decide which operational layer fits your stack. Every path below runs the exact same flagship 480B Sand.ai MAGI-2 model at 1080p @ 25fps with native single-pass audio and 20 Omni-Reference slots:

Integration path selection for MAGI-2 developers
PathAuth Header / EndpointWallet ModelBest Use Case
MagiAI Studio APIScoped `mgk_live_*` keys created in `/studio/api-keys` + unified `/api/jobs`One shared credit ledger across visual Studio UI & API (10 cr/s)Teams combining director timeline prototyping in-browser with automated batch renders
Atlas Cloud / Sand.ai Direct`Authorization: Bearer <ATLAS_API_KEY>` -> `https://api.atlascloud.ai/api/v1/model/generateVideo`Raw prepaid wholesale balance ($0.08/s flat)Dedicated backend pipelines running custom queues, storage, and retry engines
Multi-Model Gateway (e.g., SpicyAPI)Single gateway key routing MAGI-2 alongside Kling 4.0, Seedance 2.5, Veo 3.1 & LLMsUnified multi-provider usage walletApplications dispatching shots dynamically across multiple model families

2. Submit your first 4-second 1080p audition

Because MAGI-2 has no 480p or 720p draft tier, never smoke-test a new integration with a 30-second clip ($2.40 wholesale). Send `duration: 4` ($0.32 wholesale / 40 Studio credits) with a structured 6-part director prompt and explicit `no music` audio isolation.

Submit 4s T2V Audition (Atlas Cloud Direct cURL)bash
export ATLAS_API_KEY="your_atlas_api_key"

curl -sS -X POST "https://api.atlascloud.ai/api/v1/model/generateVideo" \
  -H "Authorization: Bearer $ATLAS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sand-ai/magi-2/text-to-video",
    "prompt": "[00:00-00:04] Medium close-up in a rain-streaked diner booth under warm 3200K tungsten overhead lamps, slow 50mm dolly-in. A tired detective sets a chipped ceramic mug on Formica and says calmly: \"You left the ledger at Pier Nine.\" Audio: muffled rain on glass, ceramic clink, quiet diner hum, no music.",
    "duration": 4,
    "aspect_ratio": "16:9"
  }'
Immediate JSON response returns `{ "data": { "id": "pred_...", "status": "processing" } }`. Persist that ID before waiting.

3. Poll prediction status and mirror the finished MP4

Never hold an HTTP request or serverless route open waiting for MAGI-2 synthesis to finish—real render latency spans 7 to 26 minutes. Poll `GET /api/v1/model/prediction/{request_id}` every 20 to 30 seconds from a background worker. The instant `status` transitions to `completed` (or `succeeded`), download `data.outputs[0]` and copy it straight into your own Cloudflare R2 or Amazon S3 bucket so temporary provider URLs never expire on customer galleries.

If `status` transitions to `failed`—or `completed` arrives with an empty `outputs` array due to PG-13 safety filtering (`policy_filtered`)—credit back the user's ledger hold automatically. Upstream charges $0 on filtered jobs.

Poll Prediction Status Until Terminal State (Bash)bash
REQUEST_ID="pred_replace_with_returned_id"

while true; do
  RESP=$(curl -sS "https://api.atlascloud.ai/api/v1/model/prediction/$REQUEST_ID" \
    -H "Authorization: Bearer $ATLAS_API_KEY")
  STATUS=$(echo "$RESP" | jq -r '.data.status // .status')
  echo "$(date -u +%H:%M:%SZ) status=$STATUS"

  if [ "$STATUS" = "completed" ] || [ "$STATUS" = "succeeded" ]; then
    echo "MP4 URL:" $(echo "$RESP" | jq -r '.data.outputs[0] // .outputs[0]')
    break
  elif [ "$STATUS" = "failed" ] || [ "$STATUS" = "canceled" ]; then
    echo "Failed / filtered:" "$RESP"
    break
  fi
  sleep 25
done

Testing policy_filtered Refunds Without Spending Live Credits

In MagiAI Studio's Sandbox mode (when ATLAS_API_KEY is unset during local development), submitting a prompt containing `policy_filter_test` intentionally simulates an upstream PG-13 block after 2.5 seconds so you can verify atomic 100% credit refund ledger rows end-to-end.

Related engineering pages

MAGI-2 API Quickstart: Auth, 4s Audition & Async Polling