Quickstart
Generate a 5-second, 720p video with seedance2.0. Have your API key ready, then use either the cURL or Node.js examples below.
1. Prepare your API key
Sign in to the console, check your wallet balance, and create a key under API keys. Replace VIDEO_API_KEY below with your key.
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)"Run cURL examples in your terminal. For Node.js, use version 22 or later; the examples use built-in fetch with no SDK. Save each as an .mjs file and run node filename.mjs in the terminal where you set the environment variables. Keep your API key on the server.
2. Choose a model
The examples use seedance2.0 at 5 seconds and 720p. To use another model, list the models available to your key, replace model, and choose a supported duration and resolution.
curl "$VIDEO_API_BASE/v1/models" \
--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
}
console.log(await call('/v1/models'))3. Create your first 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){
"id": "task_xxxxxxxxxxxxxxxx",
"object": "video",
"model": "seedance2.0",
"status": "queued",
"progress": 0,
"seconds": "5",
"metadata": {
"resolution": "720p",
"aspect_ratio": "16:9"
}
}Set VIDEO_TASK_ID to the returned id before running the query below. If a request times out, retry with the same VIDEO_REQUEST_ID and body. Generate a new VIDEO_REQUEST_ID for each new task.
4. Wait for completion
# 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){
"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"
}
}5. Get your video
When status is completed, metadata.url contains the video URL. On failed, stop polling and read error.message. Public video URLs need no API key. For same-site /v1/videos/{id}/content URLs, download from your server with the API key used to create the task. Save videos you need to keep.