S
Hướng dẫn API Seedance 2.0

API tạo video Seedance 2.0

Truy cập các model tạo video Seedance 2.0 của ByteDance thông qua API hợp nhất của TokenHub. Hỗ trợ text-to-video, image-to-video, chỉnh sửa video, tạo theo âm thanh và hơn thế nữa. Hướng dẫn này sẽ dẫn bạn qua toàn bộ quy trình tích hợp.

Text → VideoImage → VideoVideo → VideoAudio Reference480p / 720p / 1080p4–15 giây

1Lấy API Key của bạn

  1. Truy cập tokenhub.store để tạo tài khoản (hỗ trợ đăng nhập GitHub / Google)
  2. Vào Dashboard → API Keys, nhấp "Create New Key"
  3. Vào Dashboard → Billing để thêm Credits (1 Credit = $1 USD)
  4. Sao chép API Key của bạn (định dạng: th-xxxxxxxxxxxx...
⚠️ API Key chỉ được hiển thị một lần khi tạo. Hãy lưu trữ an toàn. Nếu bị mất, bạn sẽ cần tạo mới.

2Tổng quan API

Base URL

https://tokenhub.store/api/v1

Xác thực

Tất cả yêu cầu đều cần một API Key trong header:

Header
Authorization: Bearer th-your-api-key

Hai Endpoint

POST
/videos/generations

Tạo một tác vụ tạo video, trả về task ID

GET
/videos/generations/{task_id}

Truy vấn trạng thái tác vụ, trả về video URL khi thành công

3Model & Giá

ID modelĐầu vàoGiáMô tả
doubao-seedance-2.0Không có đầu vào video$6.970/1M (1080p $7.727)model chủ lực, chất lượng cao nhất. Hỗ trợ 1080p.
Có đầu vào video$4.242/1M (1080p $4.697)model chủ lực với đầu vào video, tiết kiệm chi phí.
doubao-seedance-2.0-fastKhông có đầu vào video$5.606/1Mmodel nhanh, tạo nhanh hơn.
Có đầu vào video$3.333/1Mmodel nhanh với đầu vào video, rẻ nhất.

Chi tiết thanh toán:

  • Video đầu ra: tính phí theo 1M tokens (số lượng token phụ thuộc vào độ phân giải và thời lượng)
  • Ảnh đầu vào: miễn phí (không tính phí)
  • Video đầu vào: tính phí theo 1M tokens theo mức giá khi có đầu vào video
  • Tổng chi phí = tổng token đã dùng × đơn giá trên mỗi token (xem bảng phía trên)

Ví dụ: doubao-seedance-2.0 không có đầu vào video (≤720p), tạo video 5s với khoảng ~1M tokens → chi phí ≈ $6.970

4Tham số yêu cầu

Tham sốKiểuBắt buộcMô tả
modelstringBắt buộcModel ID, ví dụ "doubao-seedance-2.0"
promptstringBắt buộcVăn bản mô tả video. Prompt bằng tiếng Anh thường cho kết quả tốt hơn
durationnumberTùy chọnThời lượng video (giây), phạm vi 4–15, mặc định 5
resolutionstringTùy chọn"480p", "720p", hoặc "1080p" (mặc định 720p; 1080p chỉ dành cho doubao-seedance-2.0)
aspect_ratiostringTùy chọnTỷ lệ khung hình: "adaptive" (mặc định), "16:9", "9:16", "1:1", v.v.
image_urlstringTùy chọnURL ảnh tham chiếu (image-to-video)
image_urlsstring[]Tùy chọnMảng các URL ảnh tham chiếu
video_urlstringTùy chọnURL video tham chiếu (chỉnh sửa video / video-to-video)
video_urlsstring[]Tùy chọnMảng các URL video tham chiếu (tối đa 3)
video_durationsnumber[]Tùy chọnMảng thời lượng của từng video tính bằng giây, ví dụ [3, 5]
input_video_durationnumberTùy chọnTổng thời lượng video đầu vào tính bằng giây (tùy chọn thay cho video_durations)
audio_urlstringTùy chọnURL âm thanh tham chiếu (nhạc nền / SFX)
audio_urlsstring[]Tùy chọnMảng các URL âm thanh tham chiếu (tối đa 3)
generate_audiobooleanTùy chọnCó tạo âm thanh hay không, mặc định true
watermarkbooleanTùy chọnCó thêm watermark hay không, mặc định false
contentarrayTùy chọnMảng tài nguyên media. Mỗi mục: { type: "image_url", image_url: { url }, role }. Các role được hỗ trợ: first_frame (tối đa 1), last_frame (tối đa 1), reference_image, reference_video, reference_audio

5Giới hạn đầu vào

Bạn có thể kết hợp tự do văn bản, hình ảnh, video và âm thanh làm đầu vào. Lưu ý các giới hạn sau:

Hình ảnh: 0–9 mỗi request
Video: 0–3 mỗi request, mỗi video 2–15s, tổng thời lượng ≤ 15s
Âm thanh: 0–3 mỗi request, mỗi file 2–15s, tổng thời lượng ≤ 15s
❌ Đầu vào chỉ có "Text + Audio" và "Pure Audio" KHÔNG được hỗ trợ

Định dạng được hỗ trợ

  • Định dạng hình ảnh: JPEG, PNG, WebP, BMP, TIFF, GIF (tối đa 30MB mỗi file)
  • Định dạng video: MP4, MOV (H.264/H.265, tối đa 50MB mỗi file)
  • Định dạng âm thanh: WAV, MP3 (tối đa 15MB mỗi file)
⚡ Mẹo: Chỉ thời lượng video ảnh hưởng đến tính phí. Tổng chi phí = (thời lượng video đầu vào + thời lượng video đầu ra) × rate. Hình ảnh đầu vào là miễn phí.

6Ví dụ API hoàn chỉnh

Cách dùng cơ bản nhất — mô tả một cảnh bằng văn bản để tạo video.

bash
curl -X POST https://tokenhub.store/api/v1/videos/generations \
  -H "Authorization: Bearer th-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2.0",
    "prompt": "A golden retriever running on a sunny beach, waves crashing in the background, cinematic slow motion, 4K quality",
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "watermark": false
  }'

Phản hồi:

json
{
  "id": "xxxxxx-task-id",
  "object": "video.generation.task",
  "model": "doubao-seedance-2.0",
  "status": "queued",
  "created": 1719900000
}

Tạo video là bất đồng bộ — hãy thăm dò trạng thái cho đến khi hoàn tất.

bash
# Poll task status using the task_id from creation response
curl https://tokenhub.store/api/v1/videos/generations/YOUR_TASK_ID \
  -H "Authorization: Bearer th-your-api-key"

Tác vụ đang xử lý:

json
{
  "id": "YOUR_TASK_ID",
  "object": "video.generation.task",
  "model": "doubao-seedance-2.0",
  "status": "running",
  "created": 1719900000
}

Tác vụ đã hoàn tất (đã nhận được URL video):

json
{
  "id": "YOUR_TASK_ID",
  "object": "video.generation.task",
  "model": "doubao-seedance-2.0",
  "status": "succeeded",
  "created": 1719900000,
  "data": [
    {
      "video_url": "https://tokenhub-data.tos-cn-hongkong.volces.com/user_sd_file/YOUR_TASK_ID.mp4",
      "cover_image_url": "https://tokenhub-data.tos-cn-hongkong.volces.com/user_sd_file/YOUR_TASK_ID_cover.jpg"
    }
  ],
  "usage": {
    "video_duration": 5
  }
}
💡 Khoảng thời gian thăm dò khuyến nghị: mỗi 3-5 giây. Giá trị trạng thái: queued → waiting, running → generating, succeeded → done, failed → error

7Ví dụ đầy đủ bằng Python

python
import requests
import time

API_BASE = "https://tokenhub.store/api/v1"
API_KEY = "th-your-api-key"

headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# Step 1: Create video generation task
payload = {
    "model": "doubao-seedance-2.0",
    "prompt": "A majestic eagle soaring over snow-capped mountains, golden hour lighting, cinematic aerial shot",
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "watermark": False
}

resp = requests.post(f"{API_BASE}/videos/generations", json=payload, headers=headers)
task = resp.json()
task_id = task["id"]
print(f"Task created: {task_id}, status: {task['status']}")

# Step 2: Poll for result
while True:
    resp = requests.get(f"{API_BASE}/videos/generations/{task_id}", headers=headers)
    result = resp.json()
    status = result["status"]
    print(f"Status: {status}")

    if status == "succeeded":
        video_url = result["data"][0]["video_url"]
        duration = result["usage"]["video_duration"]
        print(f"Video ready! Duration: {duration}s")
        print(f"URL: {video_url}")
        break
    elif status == "failed":
        print(f"Failed: {result.get('error', {}).get('message', 'Unknown error')}")
        break

    time.sleep(5)

8Ví dụ đầy đủ bằng JavaScript / Node.js

javascript
const API_BASE = "https://tokenhub.store/api/v1";
const API_KEY = "th-your-api-key";

const headers = {
  "Authorization": `Bearer ${API_KEY}`,
  "Content-Type": "application/json"
};

// Step 1: Create task
const createResp = await fetch(`${API_BASE}/videos/generations`, {
  method: "POST",
  headers,
  body: JSON.stringify({
    model: "doubao-seedance-2.0",
    prompt: "A majestic eagle soaring over snow-capped mountains, cinematic aerial shot",
    duration: 5,
    resolution: "720p",
    aspect_ratio: "16:9",
    watermark: false,
  }),
});
const task = await createResp.json();
console.log("Task created:", task.id);

// Step 2: Poll for result
const poll = async () => {
  while (true) {
    const resp = await fetch(`${API_BASE}/videos/generations/${task.id}`, { headers });
    const result = await resp.json();
    console.log("Status:", result.status);

    if (result.status === "succeeded") {
      console.log("Video URL:", result.data[0].video_url);
      console.log("Duration:", result.usage.video_duration, "seconds");
      return result;
    }
    if (result.status === "failed") {
      console.error("Failed:", result.error?.message);
      return result;
    }
    await new Promise(r => setTimeout(r, 5000));
  }
};

await poll();

9Ví dụ Python image-to-video

python
import requests, time

API_BASE = "https://tokenhub.store/api/v1"
headers = {
    "Authorization": "Bearer th-your-api-key",
    "Content-Type": "application/json"
}

# Image-to-Video with a single reference image
payload = {
    "model": "doubao-seedance-2.0",
    "prompt": "The woman in the photo turns to face the camera and smiles warmly, her hair gently blowing in the wind",
    "duration": 5,
    "resolution": "720p",
    "image_url": "https://your-bucket.com/portrait.jpg",
    "watermark": False
}

resp = requests.post(f"{API_BASE}/videos/generations", json=payload, headers=headers)
task_id = resp.json()["id"]
print(f"Task: {task_id}")

# Poll for result
while True:
    r = requests.get(f"{API_BASE}/videos/generations/{task_id}", headers=headers).json()
    if r["status"] == "succeeded":
        print(f"Done: {r['data'][0]['video_url']}")
        break
    elif r["status"] == "failed":
        print(f"Error: {r.get('error', {}).get('message')}")
        break
    time.sleep(5)

10Chuyển ảnh người thật thành video

Khi ảnh đầu vào của bạn chứa một người thật, TokenHub tự động chuyển yêu cầu sang upstream hỗ trợ tạo nội dung cho người thật. Không cần thay đổi ở client.

Tự động kích hoạt khi bộ lọc nội dung của upstream phát hiện một người thật trong ảnh đầu vào.

Cấu trúc request giống hệt image-to-video thông thường — cùng body POST /v1/videos/generations.

Hai dạng response có thể có

  • Thông thường: { "id": "cgt-...", "status": "queued" } (hành vi hiện tại)
  • Nhánh người thật: { "id": "pat-...", "status": "queued" } — xử lý asset bổ sung, dự kiến độ trễ thêm 10-90 giây

Việc polling GET là giống nhau — gọi /v1/videos/generations/{id} với id mà POST trả về, cho đến khi status là succeeded hoặc failed. Việc rewrite id được xử lý ở phía server; bạn luôn thấy cùng một id trong suốt vòng đời của request.

Lỗi: unsupported_real_person_input

Trả về với status 400 khi account của bạn chưa cấu hình provider hỗ trợ người thật. Hãy liên hệ quản trị viên để bật một provider được hỗ trợ.

Lỗi: Xử lý asset hết thời gian chờ

Trả về qua GET với status: failed khi chuẩn bị asset của upstream vượt quá 5 phút. Có thể thử lại request một cách an toàn.

Ví dụ vòng đời hoàn chỉnh

pat-id là giá trị ẩn đối với client của bạn — tiếp tục polling cho đến khi status thay đổi.

bash
# POST
curl -X POST https://tokenhub.store/api/v1/videos/generations \
  -H "Authorization: Bearer $TH_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "doubao-seedance-2.0",
    "prompt": "let her dance and spin",
    "duration": 8,
    "resolution": "480p",
    "content": [
      { "type": "image_url", "image_url": { "url": "https://example.com/portrait.png" }, "role": "first_frame" }
    ]
  }'
# → {"id":"pat-abc123","status":"queued"}

# GET (asset still uploading)
curl https://tokenhub.store/api/v1/videos/generations/pat-abc123 -H "Authorization: Bearer $TH_KEY"
# → {"id":"pat-abc123","status":"queued"}

# GET (upstream task running)
# → {"id":"pat-abc123","status":"running"}

# GET (complete — id stays pat-, video_url in data)
# → {"id":"pat-abc123","status":"succeeded","data":[{"video_url":"..."}]}

11Mẹo viết prompt

Cấu trúc cơ bản

Định dạng khuyến nghị: [Chủ thể] + [Hành động] + [Môi trường/Nền] + [Camera/Phong cách]

Ví dụ prompt tốt

  • "A young woman walking through a cherry blossom garden, petals falling in slow motion, soft natural lighting, cinematic 35mm film look"
  • "Close-up of hands pouring latte art into a ceramic cup, steam rising, warm cafe ambiance, shallow depth of field"
  • "Aerial drone shot of a winding river through autumn forest, golden and red leaves, morning mist, 4K cinematic"

Mẹo cho hình ảnh/video tham chiếu

  • Dùng "image 1", "image 2", "video 1", "audio 1" trong prompt để tham chiếu đến tài nguyên của bạn
  • Chỉ định nội dung theo từng đoạn thời gian (ví dụ: "0-2s: xxx, 2-4s: xxx")
  • Chỉ định khung bắt đầu/kết thúc (ví dụ: "first frame is image 1", "end frame freezes on image 2")
  • Chỉ định nguồn bố cục camera (ví dụ: "use video 1 POV throughout")
  • Chỉ định cách dùng âm thanh (ví dụ: "use audio 1 as background music throughout")

Mẹo

  • Prompt bằng tiếng Anh thường cho kết quả tốt hơn; tiếng Trung cũng được hỗ trợ
  • Mô tả càng cụ thể, sinh động thì kết quả càng tốt
  • Tránh mô tả quá trừu tượng (ví dụ: "một video hay")
  • Ngôn ngữ camera cải thiện chất lượng đáng kể (slow motion, close-up, aerial shot, tracking shot...)

12Câu hỏi thường gặp

Sẵn sàng bắt đầu?

Đăng ký TokenHub và bắt đầu dùng API tạo video Seedance 2.0 ngay hôm nay

© 2026 TokenHub · Powered by ByteDance Seedance 2.0 · support@tokenhub.store