Skip to content

Docs / Video generation

Video generation

Generate video from text, images or video with Seedance through one API key. Create a task, poll it, download the video. Priced per output token by resolution.

Get an API key

Video models such as Seedance make a clip from a prompt, from images (a first frame, first and last frames, or reference images), or from a reference video. A clip takes a minute or more, so video generation is a task: you create it, poll it, and download the video once it has succeeded.

The request and response follow the Volcengine Ark task format. If your code already calls Seedance on Ark, change the base URL and the key.

At a glance

Create POST /v1/contents/generations/tasks returns {"id": "vid_..."} at once
Poll GET /v1/contents/generations/tasks/{id} until status is succeeded or failed
Resolutions 480p, 720p (default), 1080p, and 4k on models that offer it
Length duration 4 to 30 seconds by model, or -1 to let the model choose
Billing Per million output tokens, at the price for the output resolution. Video input has its own price
Not charged A task that fails, expires or is cancelled
Running at once 20 tasks per organisation

Create a task

curl https://api.yunshurouter.com/v1/contents/generations/tasks \
  -H "Authorization: Bearer $YUNSHU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "seedance-2-0",
    "content": [
      {"type": "text", "text": "A paper boat drifting down a rainy street at night"}
    ],
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 5
  }'

The answer is the task id: {"id": "vid_3f2a..."}.

To start from an image, add it to content with a role:

{"type": "image_url", "image_url": {"url": "https://example.com/first.png"}, "role": "first_frame"}

Poll the task

curl https://api.yunshurouter.com/v1/contents/generations/tasks/vid_3f2a... \
  -H "Authorization: Bearer $YUNSHU_API_KEY"
{
  "id": "vid_3f2a...",
  "model": "seedance-2-0",
  "status": "succeeded",
  "resolution": "720p",
  "ratio": "16:9",
  "duration": 5,
  "content": {"video_url": "https://..."},
  "usage": {"completion_tokens": 108000, "total_tokens": 108000},
  "cost": {"amount": "1.079360", "currency": "USD"}
}

status is queued, running, succeeded, failed, cancelled or expired. Poll every 10 to 30 seconds. The video URL expires after a while, so download the file when the task succeeds.

Request fields

Field Values
model A video model id from the catalogue, for example seedance-2-0
content Up to 51 items: one text prompt, and image_url, video_url or audio_url items
role On media items: first_frame, last_frame, reference_image, reference_video, reference_audio
resolution 480p, 720p, 1080p, 4k
ratio adaptive (default), 16:9, 4:3, 1:1, 3:4, 9:16, 21:9
duration 4 to 30, or -1
generate_audio, watermark, return_last_frame true or false
draft true for a quick 480p preview on models that support it; continue from it with a draft_task item
priority 0 to 9

Media must be an https:// URL. Images and audio may also be inline data: URLs, but a request body is limited to 2 MB, so link larger files. Fields not listed here are ignored.

Pricing

Each video model is priced per million output tokens, at the rate for its output resolution: 480p and 720p share a rate, and 1080p and 4k each have their own. A task whose input includes a video is billed at that model’s video-input rate. The rates are in the model catalogue, and GET /catalog/models?modality=video lists them.

When you create a task, the most it could cost (the largest frame at that resolution, for the longest clip the request allows) is reserved from your balance. When it succeeds you are charged for the tokens it used and the rest of the reservation is released. If your balance cannot cover the reservation, the request is refused with 402.

Cancel or list

Method Path What it does
DELETE /v1/contents/generations/tasks/{id} Cancel a task that is still queued
GET /v1/contents/generations/tasks?page_size=20 Your organisation’s tasks, newest first

Any key in your organisation can see its tasks. A key limited to certain models can only create tasks on video models it is allowed to use.