블로그로 돌아가기

Seedance API Python Example (2026)

2026년 12월 1일

A runnable Python script for the Seedance 2.0 and 2.5 API: submit, poll, download. 480p costs $0.132 or $0.156 per second, so a 5-second clip is $0.66.

The script below sends one POST to /v1/generations with model bytedance/seedance-2.0, polls GET /v1/jobs/{id} every 3 seconds and saves the video file. A 5-second 480p clip costs $0.66 on Seedance 2.0 or $0.78 on Seedance 2.5. To compare the two versions and their specs before you pick one, see the Seedance API overview; every per-second rate is on the pricing page. It needs Python 3.8 or newer, the requests package and a FlowAPI key.

Everything here comes from the video generation docs and the jobs docs. If you don't have a key yet, the API key and free trial guide takes 4 steps.

Setup

pip install requests
export FLOWAPI_KEY="flow_sk_live_..."

Use a flow_sk_test_ key while you write your code: it goes through the same validation, returns a fixed sample file and charges $0.

The full script

Save it as seedance.py:

"""Generate a Seedance video with FlowAPI: submit, poll, download.

Usage: python seedance.py "A paper boat drifting down a stream"
"""
import os
import sys
import time
import uuid

import requests

API = "https://useflowapi.com/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['FLOWAPI_KEY']}"}
MODEL = "bytedance/seedance-2.0"  # or "bytedance/seedance-2.5"
FINAL = {"succeeded", "failed", "cancelled"}


def submit(prompt, seconds=5):
    """Create the job. Every retry reuses one Idempotency-Key, so it is charged once."""
    body = {
        "model": MODEL,
        "input": {"type": "text", "prompt": prompt},
        "parameters": {"resolution": "480p", "duration": seconds},
    }
    headers = {**HEADERS, "Idempotency-Key": f"seedance-{uuid.uuid4().hex}"}
    for attempt in range(4):
        try:
            res = requests.post(f"{API}/generations", headers=headers, json=body, timeout=30)
        except requests.RequestException as exc:
            print(f"network error, retrying: {exc}")
            time.sleep(2 ** attempt)
            continue
        if res.status_code in (429, 503):
            time.sleep(float(res.headers.get("Retry-After", 2 ** attempt)))
            continue
        if res.status_code >= 400:
            sys.exit(f"submit failed: {res.status_code} {res.text}")
        return res.json()
    sys.exit("submit failed after 4 attempts")


def wait(job_id, every=3):
    """Poll until the job is final. A video job ends within 90 minutes."""
    while True:
        res = requests.get(f"{API}/jobs/{job_id}", headers=HEADERS, timeout=30)
        res.raise_for_status()
        job = res.json()
        if job["status"] in FINAL:
            return job
        print(f"{job['status']}...")
        time.sleep(every)


def download(job):
    """Save the first result file. Result URLs need no key and last 30 days."""
    file = job["result"]["files"][0]
    path = f"{job['id']}.{file['media_type'].split('/')[-1]}"
    with requests.get(file["url"], stream=True, timeout=300) as res:
        res.raise_for_status()
        with open(path, "wb") as out:
            for chunk in res.iter_content(chunk_size=1 << 20):
                out.write(chunk)
    return path


if __name__ == "__main__":
    prompt = " ".join(sys.argv[1:]) or "A paper boat drifting down a stream"
    job = submit(prompt)
    price = job["price"]
    print(f"job {job['id']} {job['status']}, charged {price['amount']} {price['currency']}")
    done = wait(job["id"])
    if done["status"] != "succeeded":
        sys.exit(f"{done['status']}: {done.get('error')} (refunded: {done.get('refunded')})")
    print("saved", download(done))

Run it:

python seedance.py "A paper boat drifting down a stream"

A live key is charged when the job is accepted ($0.66 for this 5-second clip), and the job moves from queued to running to succeeded. If it ends failed or cancelled, the full price goes back to your balance.

How the script works

  1. submit() posts the request. The Idempotency-Key header is required. The script makes one key per job and reuses it on every retry, so a network error never creates a second paid job. A 429 or 503 waits for Retry-After and tries again; any other error stops with the API's message. More in the idempotency docs.
  2. wait() reads the job every 3 seconds. Reads allow 1,200 requests per minute per key, so this is far inside the limit. A video job still unfinished after 90 minutes is marked failed and refunded, so the loop always ends.
  3. download() streams result.files[0].url to disk. These URLs are public storage links (no key is sent to them) and expire after 30 days.

Parameters

FieldValueNotes
modelbytedance/seedance-2.0or bytedance/seedance-2.5
input.typetext, image or referencetext-to-video, image-to-video, reference-to-video
input.promptstringWhat happens in the clip
input.referencesarrayRoles: first_frame, last_frame, reference_image, reference_video, reference_audio
parameters.durationinteger, 1 to 60Required; the price is per second times this
parameters.resolution480pThe only size sold for both models, and the default

A combination of mode and roles the model does not accept is refused with 400 FLOW_INVALID_REQUEST before anything is charged. Each account can run 5 video jobs at once.

Cost per second and per video

Model (480p)Per second5 s10 s60 s
Seedance 2.0$0.132$0.66$1.32$7.92
Seedance 2.5$0.156$0.78$1.56$9.36

Prices come from the FlowAPI price table. To get the exact price of a body without paying, send it to POST /v1/quotes first. Neither Seedance model is covered by the $0.50 trial, which pays only for specs at $0.10 per unit or less. A run with too little balance is refused with 402 FLOW_INSUFFICIENT_BALANCE and nothing is charged.

For context, the fal.ai Seedance 2.0 page listed $0.3034 per second for 720p with audio and $0.682 per second for 1080p with audio on 2026-12-01. It printed no 480p price, so there is no like-for-like comparison with the 480p rows above. Image model prices against Google and fal.ai are in Nano Banana API pricing compared.

Image-to-video

Upload a picture with POST /v1/files (up to 20 MB, kept 24 hours; see input files), then change the body in submit():

body = {
    "model": MODEL,
    "input": {
        "type": "image",
        "prompt": "The camera slowly pushes in",
        "references": [{"role": "first_frame", "file_id": "file_..."}],
    },
    "parameters": {"resolution": "480p", "duration": 5},
}

A public https URL also works in place of file_id: {"role": "first_frame", "url": "https://..."}.

Errors you may see

ResponseCauseWhat to do
401 FLOW_UNAUTHORIZEDMissing, wrong, revoked or expired keyCheck FLOWAPI_KEY
400 FLOW_INVALID_REQUESTBad body, duration outside 1 to 60, unsupported mode or roleFix the body; nothing was charged
402 FLOW_INSUFFICIENT_BALANCEBalance below the quoted priceTop up in the console
429Too many requests or running jobsThe script waits Retry-After and retries

Every code is listed in the error docs, and all endpoints are in the API docs.

Boundaries

FlowAPI is not affiliated with or endorsed by ByteDance. Seedance is a ByteDance trademark. Only use reference images, video or audio that you have the rights or the subject's consent to use.

FAQ

How much does a Seedance API video cost?

On FlowAPI a 480p Seedance 2.0 clip costs $0.132 per second and Seedance 2.5 costs $0.156 per second, so 5 seconds is $0.66 or $0.78.

Can I use the free trial for Seedance?

No. The $0.50 trial pays only for specs priced at $0.10 per unit or less, and both Seedance models cost more per second.

Am I charged if the video fails?

No. Failed, timed-out and cancelled jobs are refunded in full, and the job shows "refunded": true.

Does the Seedance API send webhooks?

Yes. Pass webhook_url in the POST /v1/generations body and FlowAPI sends a signed job.succeeded, job.failed or job.cancelled event when the job ends. Each request carries FlowAPI-Webhook-Id, FlowAPI-Webhook-Timestamp and FlowAPI-Webhook-Signature headers, signed with the webhook secret shown on the console API keys page. Test keys get the webhook too. Polling GET /v1/jobs/{id} every 2 to 5 seconds also works.

How long can a Seedance video be?

parameters.duration takes a whole number of seconds from 1 to 60, and the price is the per-second price times that number.

Is FlowAPI affiliated with ByteDance?

No. FlowAPI is not affiliated with or endorsed by ByteDance. Seedance is a ByteDance trademark.