Magi-2 Video Integration
Generate 1080p video from text, frames, or reference media with Magi-2. Submit a task, poll for the MP4, and compare examples of all three modes.
Magi-2 generates 4–30 seconds of 1080p video with optional audio. Use a ModelSell API key with access to magi-2 on a gateway that has the model enabled. Each generation returns a public task ID for polling.
Set up
Use your gateway's base URL without a trailing slash. For the two media examples, set IMAGE_URL to a direct, publicly downloadable HTTPS image URL. Those commands use jq to build the JSON body.
export MODELSELL_BASE_URL="https://api.modelsell.com"
export MODELSELL_API_KEY="<your-modelsell-api-key>"
export IMAGE_URL="<your-public-https-image-url>"Text to video
Describe the scene and motion in prompt. The native URL selects the model and mode.
curl --fail-with-body "$MODELSELL_BASE_URL/sand/magi-2/text-to-video" \
-H "Authorization: Bearer $MODELSELL_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"prompt": "The camera glides over a still mountain lake at sunset.",
"duration": 5,
"resolution": "1080p",
"aspect_ratio": "16:9",
"generate_audio": true
}'Open the text-to-video sample (MP4)
Image to video
image_url sets the first frame. Add end_image_url to set the last frame, or an optional prompt to describe the movement.
jq -n --arg image "$IMAGE_URL" \
'{
image_url: $image,
prompt: "Slowly move the camera toward the lake as ripples cross the water.",
duration: 5, resolution: "1080p", aspect_ratio: "16:9", generate_audio: true
}' |
curl --fail-with-body "$MODELSELL_BASE_URL/sand/magi-2/image-to-video" \
-H "Authorization: Bearer $MODELSELL_API_KEY" \
-H 'Content-Type: application/json' -d @-Open the image-to-video sample (MP4)
Reference to video
Supply at least one reference in image_urls, video_urls, or audio_urls. A single image in image_urls can guide the scene without fixing its first frame. You can combine media types and optionally describe how to use them in prompt.
jq -n --arg image "$IMAGE_URL" \
'{
image_urls: [$image],
prompt: "Use the landscape and colors as a reference for a new scene by the lake.",
duration: 5, resolution: "1080p", aspect_ratio: "16:9", generate_audio: true
}' |
curl --fail-with-body "$MODELSELL_BASE_URL/sand/magi-2/reference-to-video" \
-H "Authorization: Bearer $MODELSELL_API_KEY" \
-H 'Content-Type: application/json' -d @-Open the reference-to-video sample (MP4)
Parameters and media limits
| Native field | Accepted values |
|---|---|
prompt | 1–15,000 characters when supplied. Required for text to video and optional in the other two modes. |
duration | Integer seconds from 4 to 30. Default 5. |
resolution | 1080p (default). |
aspect_ratio | 21:9, 16:9 (default), 4:3, 1:1, 3:4, or 9:16. |
generate_audio | Boolean. Defaults to true. Send false for silent video. |
seed | Optional integer from 0 to 4294967295. |
Reference mode accepts up to 10 images (each under 30 MB), 5 MP4/MOV videos (up to 200 MB each), and 5 WAV/MP3 audio files (up to 15 MB each). Each video or audio clip must be 2–30 seconds long. Combined video duration and combined audio duration must each fit within 30 seconds. Provider parameter reference
Poll for the MP4
Save the native creation response's request_id, then poll with the same API key. The response also includes a relative status_url on your gateway.
export TASK_ID="<request_id-from-creation>"
curl --fail-with-body "$MODELSELL_BASE_URL/requests/$TASK_ID/status" \
-H "Authorization: Bearer $MODELSELL_API_KEY"Native status | Action |
|---|---|
queued, in_progress | Wait a few seconds and poll again. |
completed | Download the MP4 from video.url while the URL is valid. |
failed, nsfw, canceled | Stop polling. Read error when present and retain the public task ID for support. |
In integration testing, both media modes returned Generation failed with a public image URL and no prompt. Both succeeded when the same JPEG was hosted on Higgsfield and a motion prompt was supplied. The two changes were tested together, so the failure cause is unknown.
Unified video format
Send JSON to POST /v1/videos with Bearer authentication and "model":"magi-2". Use seconds for duration and size for resolution. Put aspect_ratio, generate_audio, seed, and provider reference arrays in metadata.
| Intended operation | Unified input |
|---|---|
| Text to video | prompt alone |
| Image to video | images with one first frame or two ordered first/last frames |
| Reference to video | metadata.image_urls, metadata.video_urls, or metadata.audio_urls. A one-item reference array selects reference mode. |
This example uses one image as a reference and requests silent video.
{
"model": "magi-2",
"prompt": "Use the landscape as a reference for a slow aerial shot.",
"seconds": "5",
"size": "1080p",
"metadata": {
"image_urls": ["https://example.com/your-landscape.jpg"],
"aspect_ratio": "16:9",
"generate_audio": false
}
}Replace the example image URL with your own. Save the unified response's id and query GET /v1/videos/{id} with the same key. Read video_url on completed or error.message on failed.