Nbility logoNbility Docs

Search documentation

Search guides and API reference content

Videos

MAGI-2 Video Generation

magi-2 supports text-to-video and image, video, and audio references. Output is fixed at 1080p, with an integer duration of 4–30 seconds. Select the model in the video tab of Playground to configure and submit an asynchronous task.

Endpoints and authentication

MethodPathPurpose
POST/v1/videosCreate a video task
GET/v1/videos/{task_id}Retrieve task status
GET / HEAD/v1/videos/{task_id}/contentDownload the video with authentication
GET/v1/tasks/{task_id}/artifactsObtain media links for browser playback
POST/v1/media/uploadsUpload local reference media

Use your Nbility API key and a base URL without /v1. Creation, queries, uploads, and authenticated downloads require a Bearer header.

export BASE_URL='https://api.nbility.ai'
export NBILITY_API_KEY='replace-with-your-nbility-api-key'

Quickstart

curl --fail-with-body -sS "${BASE_URL}/v1/videos" \
  -H "Authorization: Bearer ${NBILITY_API_KEY}" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "model": "magi-2",
  "duration": 5,
  "aspectRatio": "16:9",
  "resolution": "1080p",
  "generateAudio": true,
  "parts": [
    {"type": "text", "text": "Ocean waves strike the rocks as the camera moves forward in the sunset"}
  ]
}
JSON

Successful creation returns a site task ID, for example:

{"id":"task_example","model":"magi-2","status":"queued"}

Acceptance does not mean media preparation, moderation, or generation has finished. Check task logs after a create request times out. The interface does not promise deduplication through Idempotency-Key; resubmitting can create another billable task.

Request fields

FieldTypeRequiredDescription
modelstringYesmagi-2
durationintegerYes4–30 seconds; automatic or fractional duration is unsupported
aspectRatiostringYes16:9, 4:3, 1:1, 3:4, 9:16, or 21:9
resolutionstringNoOnly 1080p; also the default when omitted
generateAudiobooleanNoWhether to generate audio; defaults to true; send false to disable
seedintegerNoOptional random seed: -1 or an integer from 0 to 9007199254740991
partsarrayYes, or use promptExactly one text item, plus up to 20 reference media items
promptstringWhen no text item is usedShorthand text prompt; cannot be combined with a text item in parts

Text must contain nonblank content and at most 15,000 Unicode characters. Field names are case-sensitive. Multimodal requests use parts, rather than content. Adaptive framing, first/last frame roles, watermark, and returning the last frame are unsupported.

OpenAI Video aliases are also accepted: seconds for duration, size for resolution, ratio for aspectRatio, and generate_audio for generateAudio. When both forms are supplied, their values must agree. Following the examples' naming consistently is recommended.

Image, video, and audio references

typeContent fieldLimit
texttextExactly one
reference_imageimage.url10 images
reference_videovideo.url5 videos
reference_audioaudio.url5 audio clips

Each media address must be a publicly downloadable HTTPS URL of at most 8192 characters. Base64, data URIs, asset://, local paths, and private-network addresses are unsupported. Replace the quickstart's parts with this array to combine reference types:

[
  {"type":"text","text":"Use the character from the image, the camera movement from the video, and the rhythm from the audio"},
  {"type":"reference_image","image":{"url":"https://example.com/character.png"}},
  {"type":"reference_video","video":{"url":"https://example.com/motion.mp4"}},
  {"type":"reference_audio","audio":{"url":"https://example.com/music.wav"}}
]

Replace the example URLs with your own downloadable media. Check that the content, format, and quality are suitable for the model. A successful create response does not confirm that media processing has passed.

Upload local media with:

curl --fail-with-body -sS "${BASE_URL}/v1/media/uploads" \
  -H "Authorization: Bearer ${NBILITY_API_KEY}" \
  -F 'file=@character.png'

Read url from the response and place it in the corresponding image.url, video.url, or audio.url. The upload endpoint accepts PNG/JPG/JPEG/WebP images (30MB), MP4/MOV videos (50MB), and MP3/WAV/M4A/AAC audio (15MB). Upload URLs expire after one hour, so create the task promptly. Playground uploads selected local files before submitting the video request.

Retrieve and download

export TASK_ID='replace-with-id-from-the-create-response'
curl --fail-with-body -sS "${BASE_URL}/v1/videos/${TASK_ID}" \
  -H "Authorization: Bearer ${NBILITY_API_KEY}"

Statuses are queued, in_progress, completed, and failed. Poll every 5–10 seconds until a terminal status is reached. Failure details may appear in error.message.

After completion, url may be an authenticated relative path such as /v1/videos/task_example/content. Save the video through the site's download endpoint:

curl --fail-with-body -sS "${BASE_URL}/v1/videos/${TASK_ID}/content" \
  -H "Authorization: Bearer ${NBILITY_API_KEY}" \
  -o magi-2.mp4

For browser playback, request GET /v1/tasks/{task_id}/artifacts with your API key, then use the video entry's content_url. The complete URL contains a task-scoped access credential. Keep it private and save your own copy promptly. Never put your API key in a playback URL.

Responses compatibility

You can also use POST /v1/responses, placing the prompt in input and generation settings in metadata:

curl --fail-with-body -sS "${BASE_URL}/v1/responses" \
  -H "Authorization: Bearer ${NBILITY_API_KEY}" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "model": "magi-2",
  "background": true,
  "input": "Ocean waves strike the rocks as the camera moves forward",
  "metadata": {"duration":5,"aspectRatio":"16:9","generateAudio":false,"seed":0}
}
JSON

Retrieve the result with the response ID at GET /v1/responses/{id}. background: true returns a pending response immediately. stream: true streams progress and the final result, rather than a live video encoding stream. See Responses API for the common format.

Pricing and errors

Billing uses the requested generation seconds. Check model pricing for the current rate and your API key's group multiplier. A 5-second task is billed as 5 seconds; reference counts do not add charges, and the output container's duration does not replace the requested duration for billing. Quota is reserved on acceptance and refunded if the task fails.

Invalid parameters return 400, invalid API keys return 401, insufficient model permissions or quota return 403, and excessive requests return 429. Media processing, moderation, or generation service errors can also fail an accepted task. Query existing tasks before creating replacements. See error handling.

Table of Contents