Skip to content

MAGI-2 Video

POST/v2/generations

Submit a MAGI-2 generation in Sand AI's native format. A successful submission returns HTTP 202 and a generation id.

Request body

stringmodelrequired

magi-2.

arraypartsrequired

Exactly one text item, plus up to 10 reference_image, 5 reference_video and 5 reference_audio items.

integerdurationrequired

Output length in whole seconds, 4 to 30.

stringaspectRatiorequired

21:9, 16:9, 4:3, 1:1, 3:4 or 9:16.

Optional<string>resolution

Only 1080p. Omitted, null or blank means 1080p.

Optional<boolean>generateAudio

Native audio track. Defaults to true.

Optional<boolean>enhancePrompt

Prompt enhancement on or off. Omit to use the model default.

Optional<integer>seed

Omit or -1 for a random seed; 0 to 4294967295 fixes it.

MAGI-2 guide ​

MAGI-2 by Sand AI generates a 1080p video of 4 to 30 seconds from text, a first and last frame, or reference images, videos and audio, with dialogue, sound effects and music generated together with the picture.

Generation is asynchronous. Submit a request, then poll it until it reaches a terminal status. All three APIs below run the same model, make the same video and cost the same.

Choose an API ​

/v1/runArk compatible APISand AI native API
CreatePOST /v1/runPOST /api/v3/contents/generations/tasksPOST /v2/generations
RetrieveGET /v1/run/{id}GET /api/v3/contents/generations/tasks/{id}GET /v2/generations/{id}
modelsandai/magi-2magi-2magi-2
Request bodyFlat fieldscontent arrayparts array
InputsText, first and last frame, referencesText, first and last frame, referencesText and references
Video URLoutputs[0].urlcontent.video_urloutput.videoUrl
Best forNew integrations and apps that call other SandBase modelsCode written for Sand AI's Ark API or the Ark SDKCode written for Sand AI's native API

Code written for Sand AI that passes media as HTTPS URLs only needs a new base URL and a SandBase API key:

APISand AI base URLSandBase base URL
Ark compatible APIhttps://api.sand.ai/compatible/ark/api/v3https://api.sandbase.ai/api/v3
Native APIhttps://api.sand.aihttps://api.sandbase.ai

sandai/magi-2 runs on one provider on every API. If you need a switch to another provider when one is unavailable, call the per-mode models on /v1/run: sandai/magi-2/text-to-video, sandai/magi-2/image-to-video and sandai/magi-2/reference-to-video.

Inputs ​

Pick one way to guide the video:

Input/v1/runArk contentNative parts
Textprompt{"type": "text"}{"type": "text"} (always exactly one)
First frameimageimage_url with role: first_frameNot available
Last frameend_image (needs a first frame)image_url with role: last_frameNot available
Reference images, up to 10imagesimage_url with role: reference_imagereference_image with image.url
Reference videos, up to 5videosvideo_url with role: reference_videoreference_video with video.url
Reference audio, up to 5audiosaudio_url with role: reference_audioreference_audio with audio.url

Frames and references cannot be combined in one request. Media are public HTTPS URLs; the Ark and /v1/run APIs also accept data: URLs for images and audio. Uploaded Sand AI asset IDs (assetId, asset://) are not supported on SandBase.

Common output options: duration (4 to 30, billed per second), aspect ratio (aspect_ratio, ratio or aspectRatio: 21:9, 16:9, 4:3, 1:1, 3:4, 9:16), resolution 1080p only, native audio on by default (generate_audio / generateAudio), and an optional seed.

Media limits ​

InputFormatsPer filePer request
PromptTextUp to 15,000 charactersAt most one
ImageJPEG, PNG, WebP, BMP, TIFF, GIF, HEIC, HEIFUnder 30,000,000 bytes; at most 16,384 pixels per side and 67,108,864 pixels in totalUp to 10 references, or a first frame with an optional last frame
VideoMP4 or MOV, video codec H.264 or H.265; audio track optional: AAC or MP3, or PCM in MOVUp to 200,000,000 bytes, 2 to 30 secondsUp to 5, at most 30 seconds in total
AudioMP3 or WAVUp to 15,000,000 bytes, 2 to 30 secondsUp to 5, at most 30 seconds in total

Durations are measured from the file, so a clip that plays for 30.2 seconds or 1.9 seconds is rejected: trim it to between 2 and 30 seconds. A video whose audio track is Opus or another codec not listed above is rejected even when the picture is H.264. The audio total counts only audio references, not the sound inside reference videos. A media URL must download without cookies, extra headers or a login, and be at most 8,192 characters long.

A prompt over 15,000 characters is rejected when you create the request (400). Most media limits are checked when the generation runs, because the file has to be downloaded first: the generation ends as failed with a message that describes the problem, and it is not billed.

Quickstart: /v1/run ​

bash
curl https://api.sandbase.ai/v1/run \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "sandai/magi-2",
    "prompt": "The camera moves from a clear dawn shore to sunset.",
    "image": "https://example.com/first.jpg",
    "end_image": "https://example.com/last.jpg",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'

curl https://api.sandbase.ai/v1/run/$RUN_ID \
  -H "Authorization: Bearer $SANDBASE_API_KEY"

pending and running mean keep polling. On completed, download outputs[0].url. failed is final.

Quickstart: Ark compatible API ​

bash
curl https://api.sandbase.ai/api/v3/contents/generations/tasks \
  -H "Authorization: Bearer $SANDBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "magi-2",
    "content": [
      {"type": "text", "text": "The camera moves from a clear dawn shore to sunset."},
      {"type": "image_url", "role": "first_frame", "image_url": {"url": "https://example.com/first.jpg"}},
      {"type": "image_url", "role": "last_frame", "image_url": {"url": "https://example.com/last.jpg"}}
    ],
    "duration": 5,
    "ratio": "16:9",
    "resolution": "1080p"
  }'

duration and ratio are required, as top-level fields or as prompt suffixes such as --rt 16:9 --dur 5. Poll GET /api/v3/contents/generations/tasks/{id}: queued and running mean keep polling; on succeeded download content.video_url; failed, expired and cancelled are final. Requests and responses follow Sand AI's Ark compatibility documentation.

Quickstart: Sand AI native API ​

Create a generation with the request on this page (see the API reference above), then retrieve it:

bash
curl https://api.sandbase.ai/v2/generations/$GENERATION_ID \
  -H "Authorization: Bearer $SANDBASE_API_KEY"
json
{
  "id": "4cc8c3fa-d9d4-4876-a303-6e5ee0a31910",
  "status": "succeeded",
  "output": {
    "videoUrl": "https://media.sandbase.ai/files/4cc8c3fa-d9d4-4876-a303-6e5ee0a31910/0.mp4",
    "urlExpiresAt": null
  },
  "error": null,
  "createdAt": "2026-12-05T01:55:00.123Z"
}

All five fields are always present. queued and processing mean keep polling; on succeeded download output.videoUrl; failed and canceled are final, and failed generations carry error.code (generation_failed, generation_timeout or content_policy_violation) and error.message. Any API key of the owning organization can retrieve a generation.

The request is validated as Sand AI documents it: unknown fields (including watermark, even false), role and null values other than resolution return 400 invalid_parameter with the field path in details, for example {"parts[1].image.url": "..."}. A body that is not a JSON object, or repeats a key, returns 400 invalid_request. Requests and responses follow Sand AI's native API documentation.

Errors ​

HTTPArk compatible APINative APIMeaning
400InvalidParameter / MissingParameterinvalid_parameter, invalid_request, model_not_supported, invalid_image_url, invalid_media_urlFix the request
400 / 402InsufficientBalance (400) or PermissionDenied (402)insufficient_credits (400)Add credits
403 / 400PermissionDenied (403)insufficient_credits (400, create only)The API key reached its spending limit; raise it in the Console
401AuthenticationErrorinvalid_api_keyCheck the API key
403PermissionDenied / AccessDeniedpermission_denied, organization_bannedThe account cannot use the model yet, or the key is restricted
404ResourceNotFoundgeneration_not_foundUnknown id, or owned by someone else
429RateLimitExceededrate_limit_exceededSlow down, or wait for running generations
5xxInternalServiceError, ServiceUnavailableinternal_error, service_unavailableRetry reads with backoff; do not resend creates automatically

MAGI-2 is a paid model: an organization can call it after its first top-up. A generation that fails is not billed.

Billing ​

$0.08 per second of output video, native audio included. 4 seconds cost $0.32, 5 seconds $0.40, 30 seconds $2.40. The price is the same on every API.

Differences from Sand AI ​

  • Generation and task IDs are UUID strings, not decimal integers. Treat them as opaque strings; do not parse them as integers.
  • The video URL is stored by SandBase and does not expire, so urlExpiresAt is null (Sand AI returns a 60-minute signed URL).
  • Rate limits and concurrency follow your SandBase organization, not Sand AI's defaults.
  • Uploaded Sand AI assets (POST /v1/assets, assetId, asset://) are not supported; pass public HTTPS URLs. Requests that already use HTTPS URLs work unchanged.
  • Reference media are sent to the model grouped by type (images, then videos, then audio); the order within each type is kept, the relative order across types is not.
  • Most media download and moderation failures surface when the generation runs, as a failed generation, rather than as an error on the create request.
  • The native API request body is limited to 4 MiB.