Skip to content
Seedance 2.5 in Python: 30-Second AI Video, One Pass — ContentBuffer guide

Seedance 2.5 in Python: 30-Second AI Video, One Pass

K
Kodetra Technologies··8 min read Intermediate

Summary

Generate a 30-second AI video with synced audio using ByteDance's Seedance 2.5 API in Python.

Seedance 2.5 Just Opened Its API. Here's How to Drive It From Python.

On August 7, 2026, ByteDance opened the public developer API for Seedance 2.5, and the AI video crowd hasn't stopped talking about it since. The headline feature is the one that actually changes how you write code: a single API call now returns up to 30 seconds of video with synchronized audio baked in — dialogue, ambient sound, and effects generated together in one pass, instead of stitching a silent clip to a separate audio track afterward.

That "one pass" detail matters. Earlier pipelines forced you to generate short silent segments, glue them together, then bolt on TTS and hope the lip-sync held. Seedance 2.5 collapses that into one asynchronous job. You send a prompt, poll a task ID, and download a finished MP4 with sound. It also accepts a large stack of multimodal references — images, video, and audio — so you can pin down characters, style, and motion instead of rolling the dice on a text prompt alone.

This guide walks you through the whole loop in Python against ByteDance's official ModelArk (BytePlus Ark) API: authenticate, submit a text-to-video task with audio, poll until it finishes, and download the result. Then we push into a real worked example with reference images and first/last frame control, and cover the gotchas that will bite you on the first run — the human-face rejection, model-specific credits, and the 720p-not-4K reality.

What actually changed in 2.5

Before you write code, it helps to know which capabilities are new, because they map directly to request parameters you'll set.

  • Single-pass 30-second clips. One task can produce up to 30 seconds of continuous video instead of a few seconds per call.
  • Native synchronized audio. Set generate_audio=True and the model produces dialogue, sound effects, and ambience timed to the visuals in the same job.
  • Up to 720p, not 4K. ByteDance's original teaser promised native 4K; what shipped tops out at 720p (the two options are 480p and 720p). Plan for 720p.
  • Deep multimodal references. You can attach many image, video, and audio references to steer character identity, style, and motion.
  • Director-grade control. Camera direction, region-level local editing, and timestamp-level instructions can be expressed in the prompt text.

Prerequisites

  • Python 3.10+ and basic comfort with async job/polling patterns.
  • A BytePlus account with an ModelArk API key (BytePlus Ark console → API keys).
  • The Seedance 2.5 model activated in your ModelArk console. Activation requires purchasing model-specific credits — there is no free tier, and credits do not transfer between the base, fast, and mini variants.
  • Three Python packages: the official Ark SDK, a dotenv loader, and requests.
pip install byteplussdkarkruntime python-dotenv requests

Store your key in a .env file next to your scripts so it never lands in source control:

# .env
ARK_API_KEY=your_modelark_api_key_here

Step 1 — Initialize the Ark client

The Ark client points at ModelArk's international base URL. If you're on the China-region endpoint your base URL will differ, but the international host below is the right default for most readers.

import os
from byteplussdkarkruntime import Ark
from dotenv import load_dotenv

load_dotenv()

client = Ark(
    api_key=os.getenv("ARK_API_KEY"),
    base_url="https://ark.ap-southeast.bytepluses.com/api/v3",
)

# Copy the EXACT model ID from your console's model-activation page.
# ModelArk IDs are date-suffixed and version-specific, e.g.:
MODEL_ID = "dreamina-seedance-2-5-260731"

A note that saves an hour of confusion: the model string is not a friendly name like "seedance-2.5". ModelArk gives you a concrete, date-suffixed ID on the activation page. Copy it verbatim. If you get a 404 or "model not found," this is almost always why.

Step 2 — Submit a text-to-video task with audio

Video generation is asynchronous. You create a task and immediately get back a task ID — not the video. The content field is a list of typed parts; for pure text-to-video you send one text part. Everything else (audio, aspect ratio, duration, resolution, watermark) rides as top-level keyword arguments.

prompt = """
A cinematic close-up of a lighthouse keeper on a storm-battered cliff at dusk.
Rain streaks across his weathered face lit by the rotating beam. He turns to
camera and says, steady and tired: "Forty years. She's never gone dark on my watch."
Waves crash below; the foghorn sounds twice, low and mournful.
"""

response = client.content_generation.tasks.create(
    model=MODEL_ID,
    content=[
        {"type": "text", "text": prompt},
    ],
    generate_audio=True,   # dialogue + SFX + ambience, synced in one pass
    ratio="16:9",
    duration=10,            # seconds; 2.5 supports up to 30
    resolution="720p",     # 480p or 720p
    watermark=True,
)

task_id = response.id
print(f"Task submitted. Task ID: {task_id}")

Example output:

Task submitted. Task ID: cgt-20260811-8f3a1c9d2b7e

Step 3 — Poll the task until it finishes

Retrieve status with tasks.get(). A task moves through queued / running and lands on either succeeded or failed. On success, the finished asset URL is on task.content.video_url. Here's a small polling helper that returns that URL:

import time

def poll_task(client, task_id, poll_interval=5, timeout=900):
    """Block until the video task finishes; return its download URL."""
    start = time.time()
    while True:
        if time.time() - start > timeout:
            raise TimeoutError(f"Task {task_id} did not finish in {timeout}s")
        task = client.content_generation.tasks.get(task_id=task_id)
        status = getattr(task, "status", None)
        if status == "succeeded":
            print("\nDone.")
            return task.content.video_url
        if status == "failed":
            raise RuntimeError(f"Task failed: {getattr(task, 'error', 'unknown error')}")
        print(".", end="", flush=True)
        time.sleep(poll_interval)

Example output while it runs:

..........
Done.
https://ark-content.../seedance/cgt-20260811-8f3a1c9d2b7e/output.mp4?...expires...

Step 4 — Download the MP4 before the link expires

The returned URL is a temporary, signed link — typically valid for about 24 hours. Download it right away and save locally rather than storing the URL:

import requests

def download_video(url, output_path="video.mp4"):
    with requests.get(url, stream=True, timeout=120) as r:
        r.raise_for_status()
        with open(output_path, "wb") as f:
            for chunk in r.iter_content(chunk_size=8192):
                f.write(chunk)
    print(f"Saved {output_path}")

video_url = poll_task(client, task_id)
download_video(video_url, "lighthouse.mp4")

The full text-to-video script

Putting the pieces together, this is a complete, runnable program. Fill in your MODEL_ID and API key and it produces a narrated 10-second clip end to end.

import os, time, requests
from byteplussdkarkruntime import Ark
from dotenv import load_dotenv

load_dotenv()
client = Ark(
    api_key=os.getenv("ARK_API_KEY"),
    base_url="https://ark.ap-southeast.bytepluses.com/api/v3",
)
MODEL_ID = "dreamina-seedance-2-5-260731"  # copy exact ID from console

def poll_task(client, task_id, poll_interval=5, timeout=900):
    start = time.time()
    while True:
        if time.time() - start > timeout:
            raise TimeoutError(f"Task {task_id} timed out")
        task = client.content_generation.tasks.get(task_id=task_id)
        status = getattr(task, "status", None)
        if status == "succeeded":
            return task.content.video_url
        if status == "failed":
            raise RuntimeError(f"Task failed: {getattr(task, 'error', 'unknown')}")
        print(".", end="", flush=True)
        time.sleep(poll_interval)

def download_video(url, output_path="video.mp4"):
    with requests.get(url, stream=True, timeout=120) as r:
        r.raise_for_status()
        with open(output_path, "wb") as f:
            for chunk in r.iter_content(chunk_size=8192):
                f.write(chunk)
    print(f"Saved {output_path}")

prompt = "A lighthouse keeper on a storm-battered cliff at dusk turns to camera: \"Forty years. She's never gone dark on my watch.\" Waves crash; the foghorn sounds twice."

resp = client.content_generation.tasks.create(
    model=MODEL_ID,
    content=[{"type": "text", "text": prompt}],
    generate_audio=True, ratio="16:9", duration=10, resolution="720p", watermark=True,
)
print("Task ID:", resp.id)
url = poll_task(client, resp.id)
download_video(url, "lighthouse.mp4")

Worked example: two-character scene with reference images

Text prompts alone can't guarantee that the same character looks consistent across a clip. The fix is reference images. You attach them as extra content parts with a role, and refer to them in the prompt as @Image1, @Image2, and so on, in the order you pass them. Seedance supports several image roles — reference_image for identity/style, and first_frame / last_frame to pin the exact opening and closing frames.

Local images must be sent as base64 data URIs (only video references require a hosted URL). A tiny helper handles the encoding:

import base64, mimetypes

def load_image(path):
    mime, _ = mimetypes.guess_type(path)
    mime = mime or "image/png"
    with open(path, "rb") as f:
        b64 = base64.b64encode(f.read()).decode("utf-8")
    return f"data:{mime};base64,{b64}"

scene = """
A cozy independent bookshop. The barista @Image1 leans on the counter and asks
the customer @Image2: "First time here? The sci-fi section is upstairs."
@Image2 smiles and replies: "Actually, I wrote half of it." Warm afternoon light,
light jazz, the soft clink of a cup on a saucer.
"""

resp = client.content_generation.tasks.create(
    model=MODEL_ID,
    content=[
        {"type": "text", "text": scene},
        {"type": "image_url",
         "image_url": {"url": load_image("./characters/barista.png")},
         "role": "reference_image"},
        {"type": "image_url",
         "image_url": {"url": load_image("./characters/author.png")},
         "role": "reference_image"},
    ],
    generate_audio=True, ratio="16:9", duration=12, resolution="720p", watermark=True,
)
print("Task ID:", resp.id)

To interpolate between two exact frames instead — an empty room filling with furniture, say — pass a first_frame and a last_frame and let the model animate the transition between them:

content=[
    {"type": "text", "text": "Furniture pops into existence piece by piece, snappy and energetic."},
    {"type": "image_url", "image_url": {"url": load_image("./room-empty.png")},
     "role": "first_frame"},
    {"type": "image_url", "image_url": {"url": load_image("./room-furnished.png")},
     "role": "last_frame"},
]

One rule to remember: last_frame is only valid when you also supply a first_frame in the same request — you're asking the model to fill the gap between them.

Gotchas that will bite you on the first run

  • Realistic human faces get rejected. Reference images containing a real (or even realistic AI-generated) person often return "the input image may contain a real person." Stylized or cartoon characters pass reliably. Design around this from the start if you need consistent people.
  • Credits are model-specific and there's no free tier. Tokens bought for the base model won't run the fast or mini variants. Activate exactly the variant your MODEL_ID points to.
  • It's 720p, not 4K. Requesting a resolution above 720p will fail or silently clamp. The valid values are 480p and 720p.
  • Output URLs expire. The signed video_url is short-lived (around 24 hours). Download immediately; never persist the URL as if it were permanent.
  • Video references must be hosted URLs. Unlike images and audio, you can't base64 a local video file — host it and pass a reference_video URL.
  • Audio only appears when you ask for it. If generate_audio is omitted or False you'll get a silent clip, no matter how much sound your prompt describes.
  • Don't hammer the poll. A 3–6 second interval is plenty; 30-second 720p jobs can take minutes, so set a sensible timeout and keep the interval polite.

Quick reference

ItemValue / usage
SDK packagebyteplussdkarkruntime (pip install byteplussdkarkruntime)
ClientArk(api_key=..., base_url='https://ark.ap-southeast.bytepluses.com/api/v3')
Create taskclient.content_generation.tasks.create(model, content, generate_audio, ratio, duration, resolution, watermark)
Poll taskclient.content_generation.tasks.get(task_id=...).status
Result URLtask.content.video_url (expires ~24h)
durationseconds; up to 30 in one pass
resolution480p or 720p
ratioe.g. 16:9, 9:16, 1:1
generate_audioTrue for synced dialogue/SFX/ambience
image rolesreference_image, first_frame, last_frame
media rolesreference_video (URL only), reference_audio (base64 ok)
Terminal statessucceeded, failed

Next steps

Once the basic loop works, a few extensions are worth building. Wrap the create/poll/download cycle in a small queue so you can fan out several prompts concurrently and collect finished MP4s as they land. Add a reference_audio track (a recorded voice line) and let the model drive lip movement to it. And if you're producing a series, standardize on a small set of cartoon character references so identity stays locked across every clip.


Verify everything against the official BytePlus ModelArk video-generation docs before you ship, since model IDs and parameter defaults change between releases. The async pattern here — create, poll, download — is the same one you'll reuse for image and 3D generation on the same platform.

Comments

Subscribe to join the conversation...

Be the first to comment

Found this useful?

Get new AI guides for builders by email. Free.

Join 3,605 newsletter subscribers.

Also get