DEV Community

vvvvking
vvvvking

Posted on • Originally published at aiapi-pro.com

ByteDance Seedance 2.0 video generation through an OpenAI-compatible API (Python)

Disclosure: I run NovAI, the API gateway used in the examples below. Everything shown works with a free $2 trial credit (no card required), and the same submit→poll pattern applies to any async video API.

TL;DR

Seedance 2.0 is ByteDance's video generation model. Unlike chat completions, video generation is asynchronous: you submit a job, get a task ID, then poll until the video is ready. Here's the whole flow in ~30 lines of Python:

import os, time, requests

BASE = "https://aiapi-pro.com/v1"
HEADERS = {
    "Authorization": f"Bearer {os.environ['NOVAI_API_KEY']}",
    "Content-Type": "application/json",
}

# 1) Submit the generation job
job = requests.post(
    f"{BASE}/video/generations",
    headers=HEADERS,
    json={
        "model": "doubao-seedance-2.0",
        "prompt": "a paper plane flying over a neon city at night, cinematic",
        "resolution": "720p",
        "duration": 5,
    },
).json()
task_id = job["id"]

# 2) Poll until ready
for _ in range(90):
    r = requests.get(
        f"{BASE}/video/generations/{task_id}",
        headers=HEADERS,
        params={"model": "doubao-seedance-2.0"},
    ).json()
    if r.get("status") == "succeeded":
        print("video URL:", r["video_url"])
        break
    time.sleep(5)
Enter fullscreen mode Exit fullscreen mode

Swap model to doubao-seedance-2.0-fast when iteration speed matters more than fidelity.

Why async is the right shape for video

A 5-second 720p clip takes roughly 1–3 minutes to render. Holding an HTTP connection open that long is fragile (proxies time out, serverless functions hit limits). The submit→poll pattern means:

  • Your submit call returns in milliseconds
  • Polling is idempotent and retry-safe
  • You can fan out N jobs in parallel and poll them concurrently
# Fan-out: submit several prompts at once, poll them together
prompts = [
    "a lighthouse in a storm, drone shot",
    "ink-wash koi swimming through clouds",
    "timelapse of a city intersection at dusk",
]
task_ids = [
    requests.post(f"{BASE}/video/generations", headers=HEADERS,
                  json={"model": "doubao-seedance-2.0-fast", "prompt": p,
                        "resolution": "720p", "duration": 5}).json()["id"]
    for p in prompts
]
Enter fullscreen mode Exit fullscreen mode

One endpoint, text + image + video

The same base_url and key also cover chat (DeepSeek, Qwen, GLM, Kimi) and image generation (Seedream 5.0), so a single integration handles a full multimodal pipeline — e.g. LLM writes the storyboard → Seedream renders keyframes → Seedance animates them. The public model list is at GET /v1/models if you want to see everything available (43 models at time of writing).

Runnable examples

Full scripts (submit, poll, download, plus image and chat variants):

Pricing is per generation and listed on the pricing page — I won't quote numbers here since they change; the $2 signup credit is enough to run several test clips.


Cross-posted from the NovAI blog. NovAI is not affiliated with ByteDance; Seedance is a trademark of its respective owner.

Top comments (0)