Skip to content

MAGI-2 API Access

Use the MAGI-2 API to submit video generation jobs from an application and retrieve the finished output. Sand AI and Higgsfield publish separate developer documentation for their hosted integrations.

magi-2.im API

Call MAGI-2 from Your Own Code

Create an API key, send a prompt and get a 1080p MAGI-2 video with sound. The API uses the same credits as the generator on the home page.

Your API keys

Quick start

Base URL
https://magi-2.im/v1
Authentication
Send Authorization: Bearer magi_… with every request. Keep the key on your server: anyone who has it can spend your credits.
Pricing
1 credit per second of video, charged when the job starts and refunded automatically if it fails. Plans and packs are on the pricing page.
Limits
Videos of 4 to 30 seconds, up to 10 new videos per minute and 5 in progress at a time.

Create a video

curl · create a video
curl -X POST https://magi-2.im/v1/videos \
  -H "Authorization: Bearer $MAGI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "prompt": "A paper boat drifting down a rainy city street at night, slow tracking shot",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'
›Full API reference

Endpoints

POST/v1/videosStart a generation. Returns 202 with the video job.
GET/v1/videos/{id}Read a job. Poll every 10 seconds or more until the status is succeeded or failed.
POST/v1/uploadsUpload a JPG, PNG or WebP of up to 10 MB in the form field file, up to 30 per hour. Returns the url to pass as image_url.
GET/v1/accountYour credit balance.

Request body

FieldTypeDescription
promptstringRequired. What should happen in the video, up to 1,500 characters.
image_urlstringOptional. An https image URL used as the first frame (image to video). Upload local files with /v1/uploads.
durationintegerOptional. Whole seconds from 4 to 30, default 5. Costs 1 credit per second.
aspect_ratiostringOptional. 16:9, 9:16, 4:3, 3:4, 1:1 or 21:9, default 16:9.
generate_audiobooleanOptional. Default true. Sound costs no extra credits.

Send an Idempotency-Key header (a unique string of up to 128 ASCII characters without spaces, such as a UUID) so that a retried request returns the same job instead of charging again.

Check the result

Generation time depends on demand: in our November 2026 tests, 5-second clips took 7 to 42 minutes. The status goes from queued to processing, then to succeeded with a video_url, or to failed with an error, in which case the credits are refunded. Download the video to keep a copy.

curl · check the status
curl https://magi-2.im/v1/videos/VIDEO_ID \
  -H "Authorization: Bearer $MAGI_API_KEY"
Response
{
  "data": {
    "id": "6f1c2b9e-8a41-4c1e-9d3a-2b7f0e5c4a10",
    "status": "succeeded",
    "mode": "text",
    "prompt": "A paper boat drifting down a rainy city street at night, slow tracking shot",
    "duration": 5,
    "aspect_ratio": "16:9",
    "generate_audio": true,
    "credits": 5,
    "video_url": "https://file.eggapi.ai/...mp4",
    "error": null,
    "created_at": "2026-11-25T08:00:00.000Z",
    "finished_at": "2026-11-25T08:07:12.000Z"
  },
  "error": null
}

Start from an image

Upload a local image first, then send the returned url as image_url.

curl · upload an image
curl -X POST https://magi-2.im/v1/uploads \
  -H "Authorization: Bearer $MAGI_API_KEY" \
  -F "file=@start-frame.jpg"

Python and JavaScript

Python
import os, time, uuid, requests

API = "https://magi-2.im/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MAGI_API_KEY']}"}

job = requests.post(
    f"{API}/videos",
    headers={**HEADERS, "Idempotency-Key": str(uuid.uuid4())},
    json={"prompt": "A paper boat drifting down a rainy city street at night", "duration": 5},
    timeout=60,
).json()["data"]

while job["status"] in ("queued", "processing"):
    time.sleep(10)
    job = requests.get(f"{API}/videos/{job['id']}", headers=HEADERS, timeout=30).json()["data"]

print(job["video_url"] if job["status"] == "succeeded" else job["error"])
JavaScript
const API = "https://magi-2.im/v1"
const headers = { Authorization: `Bearer ${process.env.MAGI_API_KEY}` }

let { data: job } = await fetch(`${API}/videos`, {
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json", "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify({ prompt: "A paper boat drifting down a rainy city street at night", duration: 5 }),
}).then((res) => res.json())

while (job.status === "queued" || job.status === "processing") {
  await new Promise((resolve) => setTimeout(resolve, 10_000))
  ;({ data: job } = await fetch(`${API}/videos/${job.id}`, { headers }).then((res) => res.json()))
}

console.log(job.status === "succeeded" ? job.video_url : job.error)

Errors

Every response has a data and an error field. On errors, data is null and error has a code and a message, with a matching HTTP status. Responses with 429 or 503 can include a Retry-After header.

StatusCodesMeaning
400prompt_required, prompt_too_long, invalid_image_url, invalid_duration, invalid_aspect_ratio, invalid_generate_audio, invalid_idempotency_key, invalid_json, invalid_upload, generation_rejectedThe request was not accepted. The message names the field to fix.
401missing_api_key, invalid_api_keyThe API key is missing, wrong or revoked.
402insufficient_creditsNot enough credits for this length.
404job_not_foundNo video with this id belongs to your account.
409idempotency_key_reusedThis Idempotency-Key was already used for a different request.
413image_too_largeThe image is larger than 10 MB.
415json_required, unsupported_imageSend JSON to /v1/videos, and a JPG, PNG or WebP image to /v1/uploads.
429rate_limited, too_many_active_jobsToo many requests, or too many videos in progress. Wait and try again.
500internal_errorSomething went wrong on our side. Try again later.
503provider_busy, provider_unavailableThe video service is busy or unavailable. Try again later; no credits are kept.

Where the MAGI-2 API Is Available

ProviderAvailability and documentation
Sand AI PlatformUse the native generation API with model ID magi-2 if your organization has access. Sand AI also documents a Volcengine Ark-compatible interface. Sand AI Platform documentation · Ark compatibility
Higgsfield APIHiggsfield lists MAGI-2 endpoints for text-to-video, image-to-video, and reference-to-video. Its text-to-video endpoint uses sand/magi-2/text-to-video. Higgsfield MAGI-2 endpoints

Get Started on the Sand AI Platform

  1. Sign in to the Sand AI Platform console and use an organization that has magi-2 enabled. Create an API key and store it on your server. Sand AI API key setup
  2. Submit a job to POST /v2/generations. For a first request, use a text prompt and specify the duration and aspect ratio. To try an image input, follow the quickstart to upload the asset and include its ID. Sand AI quickstart
  3. Save the generation ID from the response and use it to check the job status. When the job succeeds, download the video from the output URL. Sand AI generation reference

Pricing and Limits

Both providers list per-second rates for 1080p video. Before estimating costs, check each provider's current rate, supported input combinations, and how many jobs can run at once. Sand AI publishes separate request and concurrency limits. Its pricing page currently lists top-ups as unavailable. Higgsfield lists its pricing and queue limits in the endpoint reference. Sand AI model pricing · Sand AI rate limits · Higgsfield pricing and limits

Self-Hosting the Preview

Sand AI provides the Preview weights and code to generate 10-second clips locally. Check the MAGI-2 Preview setup page for downloads and GPU requirements, or read the MAGI-2 model overview to compare releases.

Frequently Asked Questions

What model ID does the Sand AI API use?

Use magi-2 for the full model in the Sand AI Platform API if your organization has access to it.

How much does the MAGI-2 API cost?

Sand AI and Higgsfield each publish their current rates per second of video. Confirm the rate and supported settings with your provider before submitting a job.

Can I use an image with the MAGI-2 API?

Yes. The Sand AI quickstart shows how to upload an image and include its asset ID in a video generation request alongside a text prompt.