Skip to main content

Video Generation API

The video API supports generation from text, image references, and video references. Processing is asynchronous:

Create a task -> Query its status -> Download the video.

Preparation​

API Host​

https://api.b.ai

Authentication​

All three endpoints require an API Key:

Authorization: Bearer YOUR_API_KEY

Personal and Team API Keys are supported. Use the same identity that created the task when querying or downloading it.

Model IDs​

ModelRequest model
Seedance 2.0seedance-2.0
Seedance 2.0 Fastseedance-2.0-fast
Seedance 2.0 Miniseedance-2.0-mini
Seedance 2.5seedance-2.5

Available models depend on those enabled for your account.

The examples below use an environment variable:

export BAI_API_KEY="YOUR_API_KEY"

1. Create a Video Task​

POST https://api.b.ai/v1/videos

Submit a JSON request. A successfully accepted request returns a task ID. The video is generated in the background and is not returned in this request.

Request Example: Text to Video​

curl https://api.b.ai/v1/videos \
-H "Authorization: Bearer ${BAI_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"model": "seedance-2.0-mini",
"content": [
{
"type": "text",
"text": "Gentle morning waves wash onto a beach, with a fixed camera, soft sunlight, and no subtitles."
}
],
"duration": 4,
"resolution": "480p",
"ratio": "16:9",
"generate_audio": true,
"watermark": false
}'

Main Parameters​

ParameterTypeDescription
modelstringRequired model ID
contentarrayInput content, including text and optional reference media
durationintegerVideo duration in seconds; explicitly setting it is recommended
resolutionstringResolution; defaults to 720p when omitted
ratiostringAspect ratio, such as 16:9; image-reference requests may use adaptive where supported by the model
generate_audiobooleanWhether to generate audio; defaults to true when omitted
watermarkbooleanWhether to add a watermark
return_last_framebooleanWhether to request the final frame as an image

Model parameter ranges:

ModelResolutionsSpecified Duration
seedance-2.0480p, 720p, 1080p, 4k4-15 seconds
seedance-2.0-fast480p, 720p4-15 seconds
seedance-2.0-mini480p, 720p4-15 seconds
seedance-2.5480p, 720p, 1080p4-30 seconds

Reference media combinations must also meet the requirements of the selected model.

Image References​

Add an image item to content:

{
"type": "image_url",
"image_url": {
"url": "https://your-domain.com/first-frame.png"
},
"role": "first_frame"
}

For first-and-last-frame generation, provide two images with role set to first_frame and last_frame, respectively.

Video References​

Add a video item to content:

{
"type": "video_url",
"video_url": {
"url": "https://your-domain.com/reference.mp4"
},
"role": "reference_video"
}

Upload reference media to storage accessible to the upstream service, and keep the URLs valid throughout generation. This API does not provide a media-upload service.

Existing Request Format Compatibility​

Existing clients can continue using prompt and metadata:

{
"model": "seedance-2.0-mini",
"prompt": "Gentle morning waves wash onto a beach, with soft sunlight.",
"seconds": 4,
"metadata": {
"resolution": "480p",
"ratio": "16:9",
"generate_audio": true,
"watermark": false
}
}

Choose one format where possible. If the same parameter appears at the top level and in metadata, keep its values consistent.

Creation Response​

The initial successful acceptance typically returns 202 Accepted. The following example shows the main fields:

{
"id": "task_example_001",
"object": "video",
"model": "seedance-2.0-mini",
"status": "queued",
"progress": 0,
"created_at": 1791504000,
"seconds": "4",
"size": "480p",
"metadata": {
"billing_status": "reserved"
}
}

Save the response id for status queries and downloads. 202 indicates asynchronous processing, not successful generation.

Duplicate Submissions and Retries​

Each submission may create a separate task and incur charges. Once you have a task ID, query that task instead of creating it again.

2. Query a Video Task​

GET https://api.b.ai/v1/videos/{task_id}

Request Example​

export TASK_ID="task_example_001"

curl "https://api.b.ai/v1/videos/${TASK_ID}" \
-H "Authorization: Bearer ${BAI_API_KEY}"

Success Response​

The following example shows the main fields:

{
"id": "task_example_001",
"object": "video",
"model": "seedance-2.0-mini",
"status": "completed",
"progress": 100,
"created_at": 1791504000,
"completed_at": 1791504120,
"seconds": "4",
"size": "480p",
"metadata": {
"billing_status": "settled",
"url": "/v1/videos/task_example_001/content"
}
}

If a final frame was requested and returned by the upstream service, metadata also includes last_frame_url.

Task Statuses​

statusDescription
queuedQueued
in_progressGenerating
completedGeneration and settlement have completed; the video can be downloaded
failedTask failed; check error
unknownStatus is not yet confirmed; continue checking the original task

Query every 5-10 seconds. Do not determine success from progress: 100 alone.

A failed task may still return HTTP 200 from the query endpoint. Read the response status. The following example shows the main fields of a failed task:

{
"id": "task_example_001",
"status": "failed",
"error": {
"code": "upstream_video_error",
"message": "Reference media could not be accessed"
},
"metadata": {
"billing_status": "released"
}
}

Refer to the actual response for the failure reason. released means the reserved quota has been released; the release process may complete asynchronously.

If billing_status is review, retain the task ID and contact the platform for verification. Do not automatically create another video task.

3. Download the Video​

GET https://api.b.ai/v1/videos/{task_id}/content

Download when the query result shows both status: completed and billing_status: settled.

Request Example​

curl --fail --location \
"https://api.b.ai/v1/videos/${TASK_ID}/content" \
-H "Authorization: Bearer ${BAI_API_KEY}" \
--output video.mp4

A successful response contains the binary video file, with MP4 as the default format.

Downloads also require authentication. The platform proxies the upstream file and does not provide permanent video storage. Download generated videos to your own storage promptly.

Usage and Billing​

  • Quota is reserved before task creation. After generation completes, charges are settled using the upstream service's actual total_tokens.
  • The rate depends on model, resolution, and whether reference video is included, with the applicable group multiplier applied.
  • Image-only input is classified as having no reference video. Input containing a valid video_url is classified as including reference video.
  • Reserved quota is not the final charge.
  • Queries and downloads do not incur additional video-generation charges.

See Video Model Pricing for standard reference rates.

Common Errors​

HTTP StatusCommon Cause
400Invalid parameters or content format
401Invalid or expired API Key
402Insufficient available quota in the platform wallet
403Permissions or Team member quota restrictions
404Task not found or inaccessible to the current identity
409Idempotency conflict, or settlement is not yet complete when downloading
429Request rate limited
502 / 503Temporary upstream or platform service error

For example:

{
"error": {
"type": "video_error",
"message": "insufficient video credits"
}
}

This error means insufficient quota was available when the platform attempted to reserve the video-generation charge.

After a network timeout or temporary error, query the original task if you have its ID. If no task ID was received, check whether a task was created before resubmitting, to avoid duplicate generation and charges.