MAGI-2 API

by Sand.ai

4 to 30-second 1080p scenes with native sound, from text, keyframes or mixed references

sand-ai/magi-2/text-to-video
MAGI-2 AI Video Generator online
  • 4–30s clips
  • Sound included
  • Start and end frames
  • Up to 10 reference images
  • 6 aspect ratios
  • Create Video
  • Image to Video
  • Reference to Video

About MAGI-2

The MAGI-2 API exposes Sand.ai's model through three endpoints that share one price: text to video, image to video with an optional closing frame, and reference to video that accepts images, clips and audio together. Every job returns a 1080p MP4 with an AAC soundtrack unless you switch audio off. Renders take a few minutes, so submit with callBackUrl and treat the task as asynchronous from the start.

Call it with the model name sand-ai/magi-2/text-to-video on POST /jobs/createTask, from $0.48.

Introduction

Overview

MAGI-2 Text to Video renders native 1080p footage at 25 fps directly from a written brief, supporting continuous durations from 4 to 30 whole seconds. Synchronized stereo AAC audio is enabled by default so dialogue in quotation marks, foley, and ambient music match on-screen action in a single pass.

Choosing a MAGI-2 endpoint

Starting materialEndpoint
Opening frame, with optional closing frameMAGI-2 Image to Video
Reference images, videos, and audio clipsMAGI-2 Reference to Video

Writing strong prompts

  • Lead with framing, lens feel, and location before detailing subject movement.
  • Put spoken lines in double quotes and name the speaker so voice timing locks cleanly.
  • Draft at 4 or 5 seconds before ordering 15–30 second shots.

Request parameters

ParameterRequiredDescription
seedNoUse the same seed and settings for more controlled comparisons. ≥ 0 · ≤ 2147483647
promptYesDescribe what you want to make.
aspect_ratioNoThe shape of the frame: wide, square or tall. 16:9 · 9:16 · 1:1 · 4:3 · 3:4 · 21:9 · Default: 16:9
generate_audioNoAdds sound made to match the picture: voices, ambience and effects. Default: true
duration_secondsNoLength of the generated clip. ≥ 4 · ≤ 30 · Default: 5

Pricing

Prices are in USD and charged to your PopNow balance. When a task is accepted, we reserve the maximum quoted amount from your PopNow balance. On completion, we charge for actual usage, never more than the hold, and release the remainder. If the task fails, the hold is released.

OptionUSD per second
Standard$0.096

Send the same request body to POST /jobs/quote to see the estimated and maximum USD charge before running. A quote does not run the task or charge your balance.

API quick start

Call the MAGI-2 API in three steps

  1. Create an API key. Sign in to PopNow and create a key in the API console. Keys start with sk-popnow-. API calls are billed in USD from your PopNow balance.
  2. Send the request. POST /jobs/createTask with model sand-ai/magi-2/text-to-video and an input object that follows the parameter table. The response returns a task ID straight away.
  3. Get the result. Poll GET /jobs/recordInfo with the task ID, or pass a callBackUrl and we post the result to it. Download the output links when the task succeeds.
# 1. Create the task. Keep the Idempotency-Key if you retry after a network error.
export IDEMPOTENCY_KEY="$(uuidgen)"
curl -X POST https://api.popnow.ai/api/v1/jobs/createTask \
  -H "Authorization: Bearer $POPNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -d '{
  "model": "sand-ai/magi-2/text-to-video",
  "input": {
    "prompt": "A slow aerial shot drifting over a misty pine forest at sunrise",
    "aspect_ratio": "16:9",
    "duration_seconds": 5
  }
}'

# 2. Copy data.taskId from the response, then poll until state is succeeded, failed, canceled or expired.
TASK_ID="TASK_ID_FROM_RESPONSE"
curl "https://api.popnow.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
  -H "Authorization: Bearer $POPNOW_API_KEY"

Replace the prompt and any links with your own. The API tab has the response, polling and callback reference.

What to build with the MAGI-2 API

  • A scene composer: let users stack character, location and prop images, assign each one a role in a form, and compile the roles into @image_1, @image_2 wording server-side so the prompt and the array order can never drift apart.
  • Keyframe transitions for marketing: send a product's opening and closing shots as image_url and last_image_url and let the model animate the change between them.
  • Dubbed character moments: pair a portrait with a short voice clip in reference_audio_urls and have the character speak new lines in that voice.

MAGI-2 parameter notes

  • duration_seconds is an integer from 4 to 30 and drives the price directly. Expose it as a stepper, not free text, and quote again whenever it changes.
  • generate_audio defaults to true and does not change the rate; turning it off only removes the audio stream. Default it on unless your product adds its own soundtrack.
  • On image-to-video, aspect_ratio defaults to auto and follows the opening frame; on the other two endpoints it defaults to 16:9. Do not reuse a saved auto value when a user switches to text or reference mode.
  • Reference arrays are positional. If a user reorders uploads, rewrite every @image_n, @video_n and @audio_n token in the prompt before calling quote or createTask.

How MAGI-2 API pricing adds up

All three endpoints bill per requested second at the same 1080p rate, whether audio is on or off and however many references you attach. Quote after the user picks a duration, show the maximum charge before submission, and record the final cost from recordInfo when the task succeeds.

  • Create Video, 5-second clip: $0.48 each, $48.00 for 100 clips

Async jobs, webhooks and rate limits

Every MAGI-2 request is asynchronous: createTask returns a taskId straight away, and the result arrives when the job finishes. Poll GET /jobs/recordInfo every few seconds, or pass a public https callBackUrl and verify the X-Webhook-Signature header (HMAC-SHA256 over taskId, timestamp and the body hash) before trusting the payload. Each account gets 1,000 write requests per 10 seconds; a 429 carries Retry-After. Send an Idempotency-Key with createTask so a retried request for sand-ai/magi-2/text-to-video never runs or bills twice.

Common MAGI-2 API errors

errorCodeWhat it usually means and how to fix it
invalid_requestduration_seconds must be a whole number between 4 and 30, and the prompt is required on text and reference endpoints. Validate both in your form before sending.
invalid_assetReference clips and audio must be 2 to 30 seconds each and reachable over HTTPS. Reject files outside that range client-side instead of letting the job fail.
content_rejectedThe prompt or a reference was refused. Show the message to the user; the held amount is released and nothing is charged.

MAGI-2 API questions

How much does the MAGI-2 API cost?

MAGI-2 starts at $0.48 for a 5-second clip with Create Video, its lowest-priced task. API usage is charged in USD to your PopNow balance. When a task is accepted, we reserve the maximum quoted amount from your PopNow balance. On completion, we charge for actual usage, never more than the hold, and release the remainder. If the task fails, the hold is released.

What is the model name for MAGI-2 in the API?

Put sand-ai/magi-2/text-to-video for Create Video; sand-ai/magi-2/image-to-video for Image to Video; sand-ai/magi-2/reference-to-video for Reference to Video in the model field of POST /jobs/createTask.

Which MAGI-2 endpoint should a keyframe feature call?

sand-ai/magi-2/image-to-video. Pass image_url for the opening frame and last_image_url for the closing frame; the prompt is optional there.

How many references can one MAGI-2 request carry?

Up to ten images, five video clips and five audio clips. Clips and audio are 2 to 30 seconds each and are trimmed past 30 seconds combined.

Does the MAGI-2 API return audio in the same file?

Yes. The MP4 carries a stereo AAC track by default. Set generate_audio to false for a silent file at the same price.

What are the limits of the MAGI-2 API?

Clip length: 4–30 s; Aspect ratios: 16:9 · 9:16 · 1:1 · 4:3 · 3:4 · 21:9; Prompt length (characters): 15,000. Requests outside these limits are rejected before anything is charged.

Can I try MAGI-2 without writing code?

Run MAGI-2 in the Playground without an API key, using the same PopNow balance as the website, shown in USD. Each run appears in your developer history with its matching code.

More about MAGI-2