Tutorial
MAGI-2 API: generate and retrieve a 1080p clip
Make a 1080p MAGI-2 video from a prompt, budget $1.21 for 10 seconds, and resume polling the same video task when your local wait ends.

The MAGI-2 API on API Stock generates 4–30 seconds of 1080p video at $0.121 per requested second, so a 10-second clip costs $1.21 with sound. Submit the request once, save its task ID, and use that ID to retrieve the video even if your local polling window ends.
What does one clip cost?
The following USD amounts use the live catalog checked on 27 November 2026. The tariff is per requested output second. Changing the audio setting or using a reference does not change the per-second price.
| Requested duration | One generation | Three paid candidates |
|---|---|---|
| 4 seconds | $0.484 | $1.452 |
| 10 seconds | $1.21 | $3.63 |
| 30 seconds | $3.63 | $10.89 |
Three candidates is a budget choice. If a completed clip misses the brief and you submit a fresh generation, include that extra request in your budget. Checking a saved task ID just reads the existing result. Check current pricing before scheduling a batch.
How do you submit a 10-second video task?
For a warehouse training clip, ask for one visible action and one matching sound. You can first paste the prompt into the MAGI-2 playground, choose 10 seconds at 16:9 and keep sound enabled. To integrate the same brief into a job, use Bash, curl, jq and an API key in API_STOCK_KEY.
Run this block once for a new job. Use a separate working directory for each clip so it has its own magi-task.id.
submit_magi_clip() {if [ -e magi-task.id ]; thenprintf 'Use the existing task ID in magi-task.id.\n' >&2return 1filocal response task_idresponse=$(curl -fsS --max-time 30 'https://api.api-stock.com/api/v1/generation/create' \-H "Authorization: Bearer ${API_STOCK_KEY:?Set API_STOCK_KEY}" \-H 'Content-Type: application/json' \--data-binary @- <<'JSON'{"model": "magi-2","input": {"prompt": "Fixed close-up in a warehouse. A gloved hand pulls a yellow lever down once. A short metallic click sounds as the lever reaches its stop. Hold on the lever in its lowered position. No speech or music.","duration": 10,"resolution": "1080p","aspectRatio": "16:9","generateAudio": true}}JSON) || return 1task_id=$(printf '%s\n' "$response" | jq -er '.data.taskId | strings | select(length > 0)') || return 1if ! printf '%s\n' "$task_id" > magi-task.id; thenprintf 'Save this task ID manually to magi-task.id: %s\n' "$task_id" >&2return 1fi}submit_magi_clip
If the submission times out before you get a task ID, check the dashboard generation history before sending another POST. The server may already have accepted and charged the request.
This example uses text only. To anchor the composition, use public HTTPS URLs for firstFrameImage and optionally lastFrameImage. Omit aspectRatio in that mode so the first frame determines it. To guide motion or sound with reference clips, keep the text prompt and use the reference fields in a separate request. MAGI-2 model reference
How do you retrieve the video after your local wait ends?
Use the block below in the same directory. Each status lookup has a 15-second network limit. This example checks up to 12 times with 10-second pauses. A render can take longer, so run this block again later using the same saved ID.
retrieve_magi_clip() {local task_id response status file_url attempttask_id=$(cat magi-task.id) || return 1[ -n "$task_id" ] || return 1for ((attempt = 1; attempt <= 12; attempt++)); doresponse=$(curl -fsS --max-time 15 "https://api.api-stock.com/api/v1/task/status/$task_id" \-H "Authorization: Bearer ${API_STOCK_KEY:?Set API_STOCK_KEY}") || return 1status=$(printf '%s\n' "$response" | jq -er '.data.status') || return 1case "$status" infinished)file_url=$(printf '%s\n' "$response" |jq -er 'first(.data.files[] | select(.fileType == "video") | .fileUrl)') || return 1curl -fsSL --max-time 120 "$file_url" -o magi-clip.part &&mv magi-clip.part magi-clip.mp4return $?;;failed)printf '%s\n' "$response" | jq -r '.data.errorMessage // "Generation failed."' >&2return 1;;expired)printf 'The task details have expired.\n' >&2return 1;;not_started|processing)if [ "$attempt" -lt 12 ]; then sleep 10; fi;;*)printf 'Unexpected task status %s.\n' "$status" >&2return 1;;esacdoneprintf 'Still pending. Run this retrieval block again with task %s.\n' "$task_id" >&2return 2}retrieve_magi_clip
A failed status lookup ends this local attempt. On a transient HTTP error, retry the retrieval block with the saved ID. The MP4 download uses the returned file URL and does not send the API key to the media host. Download the MP4 when the task finishes, since standard task details and file links expire three days after creation. The example was checked against the public API schema and exercised with simulated status responses. No video was rendered for this guide.
For an app, save the ID with your own job record and configure a webhook for completion events. Deduplicate delivery by task ID and check status from your worker if the callback is late. This lets you release the original web request while the render runs. Tasks and webhooks
How do you decide whether to keep the clip?
Watch the full clip and listen for the metallic click at the moment the lever stops. Check that the lever moves once and the lowered position remains visible long enough for the instruction. If the timing is too loose for a training step, add a clean click on a separate audio track or revise the shot before paying for more candidates. The text-to-video guide explains how to describe motion and sound separately.
FAQ
Is sound included in the MAGI-2 API price?
Yes. Sound is enabled by default. Setting generateAudio to false leaves the same per-second tariff.
Does ending polling cancel the render?
The polling loop only reads task status. Save the ID and check it again later. A task that reaches failed shows an error and the charge is refunded. Task statuses
Can I request a cheaper 720p draft on MAGI-2?
This endpoint offers 1080p. A four-second request at $0.484 is the lowest-cost check of one simple motion or sound cue at the catalog tariff above.
Can I use a first frame and motion references together?
The first-frame and reference modes use separate requests. Use firstFrameImage for a specific opening composition, or use a prompt with videoUrls to guide motion. Model inputs
- magi
- video
- api
- webhooks
Try it with your own key
Choose a model in the API Stock catalog, check its price and try it in your browser or through the API.
Read next
TutorialHeyGen Avatar 6 API for training videos you can updateBuild a training video from three HeyGen Avatar 6 Turbo scenes for $6.15 at 1080p. Save each task ID and render only the scene that needs a revision.·4 min read
TutorialGemini Omni 1.2 Flash API: video edits, duration and costCreate, edit or extend video with Gemini Omni 1.2 Flash: compare 1.1 prices, calculate billable seconds, and follow one API task through to a saved file.·7 min read
TutorialSuno API docs: key, pricing and first songSuno API docs: create an API Stock key, generate music, poll tasks and download audio. Includes curl, a Python client and per-action references.·11 min read

