Skip to content

Video generation

This guide covers the video generation workflow and common tasks. For parameter values, per-model durations and resolutions, media limits and error codes, see the API reference.

  1. Prepare your keyCreate a key under API keys in the console.
  2. Choose a modelList the models available to your API key.
  3. Create a taskProvide a model, prompt and optional media.
  4. Poll for completionCheck the task status every 3–5 seconds.
  5. Get your videoPlay or download the video at metadata.url.

1. Prepare your key

Create an API key in the console and keep it on your server. Send requests to https://ling-light.com with Authorization: Bearer <API_KEY>. Add an Idempotency-Key when creating a task and keep it on retries to avoid duplicate tasks and charges.

Set environment variables in your server terminalbash
export VIDEO_API_BASE="https://ling-light.com"
export VIDEO_API_KEY="sk-your-api-key"
# Generate once per new business request; keep it for retries.
export VIDEO_REQUEST_ID="$(uuidgen)"

2. Choose a model

  • Seedance 2.0 / 2.5 series: text-to-video, first/last frames and reference media (seedance2.0-mini has no first/last frames), with more references on 2.5; only the 2.5 series supports extension / editing; billed per second.
  • Seedance 2.5 LL: text-to-video and reference media, without frames or extension / editing; billed per task and requires resolution.
  • Available resolutions, durations and capabilities per model follow the live configuration; check the live model table in the API reference.
Create video · parameters and models
Resolutions, durations and media limits per model.
Models and prices
Prices by resolution.

3. Create a video task

POST /v1/videos takes a model, a prompt and optional media, and infers the mode from the media: none for text-to-video, a first and last frame for frame-guided generation, or reference images, videos or audio for reference-guided generation.

Text to video

Create a video task
curl --request POST "$VIDEO_API_BASE/v1/videos" \
  --header "Authorization: Bearer $VIDEO_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $VIDEO_REQUEST_ID" \
  --data '{
  "model": "seedance2.0",
  "prompt": "An orange cat watching rain from a windowsill, slow camera push-in",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}'
const baseUrl = process.env.VIDEO_API_BASE
const apiKey = process.env.VIDEO_API_KEY
if (!baseUrl || !apiKey) throw new Error('Set VIDEO_API_BASE and VIDEO_API_KEY first')

async function call(path, init = {}) {
  const response = await fetch(new URL(path, baseUrl), {
    ...init,
    signal: AbortSignal.timeout(30_000),
    headers: {
      Authorization: `Bearer ${apiKey}`,
      Accept: 'application/json',
      ...(init.body ? { 'Content-Type': 'application/json' } : {}),
      ...init.headers,
    },
  })
  const body = await response.json()
  if (!response.ok || body.error) {
    throw new Error(`HTTP ${response.status}: ${body.message || body.error?.message || 'Request failed'}`)
  }
  return body
}

// Keep this ID and the identical body when retrying this business request.
const requestId = process.env.VIDEO_REQUEST_ID
if (!requestId) throw new Error('Set VIDEO_REQUEST_ID first')
const task = await call('/v1/videos', {
  method: 'POST',
  headers: { 'Idempotency-Key': requestId },
  body: JSON.stringify({
  "model": "seedance2.0",
  "prompt": "An orange cat watching rain from a windowsill, slow camera push-in",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}),
})
console.log(task)
Create task response · save idjson
{
  "id": "task_xxxxxxxxxxxxxxxx",
  "object": "video",
  "model": "seedance2.0",
  "status": "queued",
  "progress": 0,
  "seconds": "5",
  "metadata": {
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }
}

First and last frames

Put one first_frame image and one last_frame image in references. They must come as a pair, with no other reference media. Set aspect_ratio to auto (or adaptive) to let the model pick the canvas from the frames; for the seedance2.5 series (including -flash and -vip), frames accept only auto / adaptive, and adaptive is used when the field is omitted. seedance2.0-mini does not support first/last frames.

Frame-guided request · replace the sample image URLs
curl --request POST "$VIDEO_API_BASE/v1/videos" \
  --header "Authorization: Bearer $VIDEO_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $VIDEO_REQUEST_ID" \
  --data '{
  "model": "seedance2.0",
  "prompt": "The person moves naturally from @图片1 to @图片2 while the camera stays stable",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "references": [
    {
      "type": "image",
      "role": "first_frame",
      "source": "https://cdn.example.com/first-frame.png"
    },
    {
      "type": "image",
      "role": "last_frame",
      "source": "https://cdn.example.com/last-frame.png"
    }
  ]
}'
const baseUrl = process.env.VIDEO_API_BASE
const apiKey = process.env.VIDEO_API_KEY
if (!baseUrl || !apiKey) throw new Error('Set VIDEO_API_BASE and VIDEO_API_KEY first')

async function call(path, init = {}) {
  const response = await fetch(new URL(path, baseUrl), {
    ...init,
    signal: AbortSignal.timeout(30_000),
    headers: {
      Authorization: `Bearer ${apiKey}`,
      Accept: 'application/json',
      ...(init.body ? { 'Content-Type': 'application/json' } : {}),
      ...init.headers,
    },
  })
  const body = await response.json()
  if (!response.ok || body.error) {
    throw new Error(`HTTP ${response.status}: ${body.message || body.error?.message || 'Request failed'}`)
  }
  return body
}

// Keep this ID and the identical body when retrying this business request.
const requestId = process.env.VIDEO_REQUEST_ID
if (!requestId) throw new Error('Set VIDEO_REQUEST_ID first')
const task = await call('/v1/videos', {
  method: 'POST',
  headers: { 'Idempotency-Key': requestId },
  body: JSON.stringify({
  "model": "seedance2.0",
  "prompt": "The person moves naturally from @图片1 to @图片2 while the camera stays stable",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "references": [
    {
      "type": "image",
      "role": "first_frame",
      "source": "https://cdn.example.com/first-frame.png"
    },
    {
      "type": "image",
      "role": "last_frame",
      "source": "https://cdn.example.com/last-frame.png"
    }
  ]
}),
})
console.log(task)

Reference media

Use public HTTPS URLs or asset://<asset ID> from your asset library. Refer to media in the prompt as @图片1, @视频1 and @音频1, numbered from 1 per media type in request order.

Mixed reference-media request
curl --request POST "$VIDEO_API_BASE/v1/videos" \
  --header "Authorization: Bearer $VIDEO_API_KEY" \
  --header "Content-Type: application/json" \
  --header "Idempotency-Key: $VIDEO_REQUEST_ID" \
  --data '{
  "model": "seedance2.5",
  "prompt": "The girl in @图片1 turns to the camera; voice follows @音频1 and motion follows @视频1",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "references": [
    {
      "type": "image",
      "role": "reference",
      "source": "https://cdn.example.com/girl.png"
    },
    {
      "type": "audio",
      "role": "reference",
      "source": "https://cdn.example.com/voice.mp3"
    },
    {
      "type": "video",
      "role": "reference",
      "source": "https://cdn.example.com/motion.mp4"
    }
  ]
}'
const baseUrl = process.env.VIDEO_API_BASE
const apiKey = process.env.VIDEO_API_KEY
if (!baseUrl || !apiKey) throw new Error('Set VIDEO_API_BASE and VIDEO_API_KEY first')

async function call(path, init = {}) {
  const response = await fetch(new URL(path, baseUrl), {
    ...init,
    signal: AbortSignal.timeout(30_000),
    headers: {
      Authorization: `Bearer ${apiKey}`,
      Accept: 'application/json',
      ...(init.body ? { 'Content-Type': 'application/json' } : {}),
      ...init.headers,
    },
  })
  const body = await response.json()
  if (!response.ok || body.error) {
    throw new Error(`HTTP ${response.status}: ${body.message || body.error?.message || 'Request failed'}`)
  }
  return body
}

// Keep this ID and the identical body when retrying this business request.
const requestId = process.env.VIDEO_REQUEST_ID
if (!requestId) throw new Error('Set VIDEO_REQUEST_ID first')
const task = await call('/v1/videos', {
  method: 'POST',
  headers: { 'Idempotency-Key': requestId },
  body: JSON.stringify({
  "model": "seedance2.5",
  "prompt": "The girl in @图片1 turns to the camera; voice follows @音频1 and motion follows @视频1",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "references": [
    {
      "type": "image",
      "role": "reference",
      "source": "https://cdn.example.com/girl.png"
    },
    {
      "type": "audio",
      "role": "reference",
      "source": "https://cdn.example.com/voice.mp3"
    },
    {
      "type": "video",
      "role": "reference",
      "source": "https://cdn.example.com/motion.mp4"
    }
  ]
}),
})
console.log(task)

Extension and editing

Only the Seedance 2.5 series (seedance2.5 and suffixed versions such as -flash and -vip, except seedance2.5-LL) accepts task_mode: extend continues from the end of the source, with seconds as the added duration; edit changes the source, with seconds equal to its duration. Both modes take exactly one source video in references.

Extension request bodyjson
{
  "model": "seedance2.5",
  "task_mode": "extend",
  "prompt": "Continue naturally for 5 seconds from the end of @视频1, preserving its scene and camera style",
  "seconds": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "references": [
    {
      "type": "video",
      "role": "reference",
      "source": "https://cdn.example.com/source.mp4"
    }
  ]
}

4. Poll the task

Save the returned id and poll every 3–5 seconds with one loop per task. Use status to decide: keep waiting on queued and in_progress, read the result on completed, and read error.message on failed. If your client times out, keep querying the same task instead of creating another.

Query the task · automatic polling with Node.js
# Replace with the id from the create response.
export VIDEO_TASK_ID="task_xxxxxxxxxxxxxxxx"
# Run every 3–5 seconds until completed or failed.
curl "$VIDEO_API_BASE/v1/videos/$VIDEO_TASK_ID" \
  --header "Authorization: Bearer $VIDEO_API_KEY"
const baseUrl = process.env.VIDEO_API_BASE
const apiKey = process.env.VIDEO_API_KEY
if (!baseUrl || !apiKey) throw new Error('Set VIDEO_API_BASE and VIDEO_API_KEY first')

async function call(path, init = {}) {
  const response = await fetch(new URL(path, baseUrl), {
    ...init,
    signal: AbortSignal.timeout(30_000),
    headers: {
      Authorization: `Bearer ${apiKey}`,
      Accept: 'application/json',
      ...(init.body ? { 'Content-Type': 'application/json' } : {}),
      ...init.headers,
    },
  })
  const body = await response.json()
  if (!response.ok || body.error) {
    throw new Error(`HTTP ${response.status}: ${body.message || body.error?.message || 'Request failed'}`)
  }
  return body
}

const taskId = process.env.VIDEO_TASK_ID
if (!taskId) throw new Error('Set VIDEO_TASK_ID to the id from the create response')
const deadline = Date.now() + 20 * 60_000
let task
while (Date.now() < deadline) {
  task = await call(`/v1/videos/${encodeURIComponent(taskId)}`)
  if (task.status === 'failed') throw new Error(task.error?.message || 'Video generation failed')
  if (task.status === 'completed') break
  await new Promise(resolve => setTimeout(resolve, 4000))
}
if (task?.status !== 'completed') {
  throw new Error('Polling stopped after 20 minutes. Resume querying the same task ID; do not create another task.')
}
console.log(task.metadata?.url)

5. Get the video

Completed task response · read metadata.urljson
{
  "id": "task_xxxxxxxxxxxxxxxx",
  "object": "video",
  "model": "seedance2.0",
  "status": "completed",
  "progress": 100,
  "seconds": "5",
  "metadata": {
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "url": "https://media.example.com/videos/task_xxxxxxxxxxxxxxxx.mp4"
  }
}

Download from metadata.url as returned: public storage links need no API key, while this site’s /v1/videos/{id}/content URLs need your API key from the server. Save videos you need to keep in your own storage.

Errors and retries

  • When a request is rejected, read message and fix the parameters. Rejected requests create no task and are not charged.
  • After a timeout, disconnect or 5xx the task may already exist. Retry with the original Idempotency-Key and identical body to get the original task instead of a duplicate.
  • On 429, wait as directed by Retry-After before polling or submitting again.
API reference · Create video
All request parameters, per-model limits and error codes.
Image generation
GPT Image and Seedream images.
Last updated