Skip to contentOceanToken

13 min read

Seedance API in Production: Queue & Retry

Seedance API production guide: polling instead of webhooks, per-key rate limits and 429s, safe retries with an Idempotency-Key, and storing clips in time.

By OceanToken Team

Seedance API in Production: Queue & Retry

Editor's note: The first Seedance call is easy. The production problems show up later: a user who refreshes and starts a second render, a worker that dies mid-poll, a burst of signups that hits the rate limit, a clip whose download link expired overnight. None of those are model problems. They are bookkeeping problems, and you solve them with a database row and a few strict rules before launch.

Short answer: For a Seedance API production setup, save each request in your own database first, submit POST /v1/videos with an Idempotency-Key, and poll GET /v1/videos/{id} from a background worker every 10 to 20 seconds. Retry only 408, 429 and 5xx with backoff, and copy the MP4 to your storage within 24 hours.

OceanToken serves bytedance/seedance-2.5 and bytedance/seedance-2.0 on the same create, poll and download calls as its other video models, and its docs state that a failed job is not charged, which matters when your retry logic runs unattended. Everything below comes from the docs' video guide, errors, limits and retries pages and the Seedance API page, read on November 22, 2026. We have not load-tested the setup in this article; the limits that depend on your account end in tests you can run.

01 · What a Seedance API production setup has to handle

A Seedance clip takes minutes, so it never fits inside one web request. The video guide describes it as a job: create it, poll it until it is done, then download the file. The job moves through four states, and your app needs its own state on top of them.

Job status What it means What your app does
queued Accepted, waiting to render Show "in queue", keep polling
in_progress Rendering Show "rendering", keep polling
completed content_url is set, valid for 24 hours Download, store, notify the user
failed error.code and error.message are set Decide: resubmit, fix input or give up

How long is "minutes"? The Seedance API page publishes timings from OceanToken's own timed test jobs between October 15 and November 12, 2026: Seedance 2.5 Upscaled took a median of 239 seconds for a 4-second 720p clip (11 runs), and 9 in 10 finished within 336 seconds. The page has no 1080p timings yet, and the video guide says a 4K clip takes longer than a 1080p one, so poll a little longer. Those numbers are useful for one thing in particular: setting the point at which your app stops saying "almost done" and starts treating a job as stuck.

Diagram: Lifecycle of one Seedance job in a production app

The scope here is one user's click turning into one clip. If you are rendering hundreds of shots from a script overnight, the concerns are throughput and ordering, and our Seedance batch generation pipeline covers that. If this is your very first call, start with the Seedance API quickstart in Python and come back.

02 · Seedance API webhook vs polling

Polling. The video guide, the errors page and the full docs text describe create, poll and download, and none of them documents a webhook, a callback URL or a push notification for video jobs. So build on polling and do not send a callback_url field in the hope it does something.

That is less of a loss than it sounds. Even with webhooks you would want a polling sweep, because a callback can be lost when your endpoint is down or slow. With polling, the sweep is the whole system, and it is easy to reason about: every unfinished row in your table gets checked on a timer until it reaches a final state.

Design choice Recommended Why
Where polling runs A background worker A web request should return the job row at once
Interval 10 to 20 s, as the guide suggests Clips take minutes; faster polling only spends requests
First poll After about 20 to 30 s The fastest median on the /seedance-api timing table is close to three minutes, so earlier polls only return an unfinished status
Jitter Add a few random seconds Jobs created together do not poll in lockstep
Stuck threshold Several times your typical render Then mark for review, not silent retry
Lost video id GET /v1/videos, newest first Lists your jobs, limit up to 100, paged with after

The browser side is a separate loop. Your frontend asks your own backend for the row's status, perhaps every few seconds, and your backend answers from the database. The browser never calls the video API directly, which keeps your key off the client and means a thousand open tabs produce a thousand cheap database reads rather than a thousand API polls.

Polls use requests from your key's per-minute allowance too, which is the link to the next section. A worker polling 200 jobs every 2 seconds sends 100 requests a second of mostly unchanged answers. At a 15-second interval the same 200 jobs need about 13 a second.

03 · Seedance API rate limits and concurrency

Limits on our endpoint come in two layers, and they fail differently. The limits page says rate limits are per key, as requests per minute and tokens per minute, and are set for your account. A second layer is the model's own capacity, shared by everyone calling it.

Limit Where you see it Error What to do
Your key's requests per minute x-oceantoken-key-rpm-limit header 429 rate_limited Wait for Retry-After or back off
Your key's tokens per minute x-oceantoken-key-tpm-limit header 429 rate_limited Same
Every channel of the model busy No header 429 provider_overloaded Back off, or switch models
Model busy after the job was accepted Job error.code rate_limited on a failed job Submit again in a minute
Key's own credit limit x-oceantoken-key-spend / -budget 400 key_budget_exceeded Raise the limit; do not retry
Balance cannot cover the estimate Create call 400 insufficient_credits or request_exceeds_balance Add credits; do not retry

The docs do not publish a fixed number of concurrent Seedance jobs per account, and we will not invent one. What they do give you is the headers: read x-oceantoken-key-rpm-limit from any response and pace your worker below it. Then cap concurrency yourself with a semaphore around job creation, sized so that creates plus polls stay under the per-minute limit with room to spare. If your product needs more sustained throughput than your key allows, the limits page says to contact OceanToken to raise it.

Note the two kinds of 429. A rate_limited from your own key goes away when the minute window resets, and the response carries Retry-After with the seconds left, though the errors page warns it may be absent. A provider_overloaded means the model is at capacity on every channel; waiting helps, and so does falling back to another Seedance id the user would accept, such as bytedance/seedance-2.0 instead of bytedance/seedance-2.5. The fields are the same across the Seedance series, so that is a change of model id, provided the clip is 15 seconds or shorter, the 2.0 limit.

Balance errors deserve a separate path in your code. A 400 for credits is not something a retry loop should touch, because it will fail the same way until someone tops up. Route it to an alert for whoever owns billing, and show the user a clear message rather than an endless spinner.

04 · Retry failed Seedance video jobs safely

To retry failed Seedance video jobs safely, separate two different retries: retrying the create call when you did not get an answer, and resubmitting a job that reached failed. They need different idempotency handling, and mixing them up is how apps either double-render or never retry at all.

The errors page lists what can succeed on a second try: 408, 429, any 5xx except 501, a 409 idempotency_key_in_progress after its Retry-After, and network failures. Every other 4xx will fail the same way until the request or the account changes. It recommends exponential backoff with jitter, starting around one second and capping at about thirty.

Diagram: What to do with each Seedance error

Error Where Retry? Action
Network timeout on create Your client Yes, same key The replay returns the job already created
409 idempotency_key_in_progress Create Yes, same key Wait for Retry-After
429 or 5xx on create Create Yes, same key Backoff; these responses are not stored
400 invalid_request Create or job No Fix the value; the message names what the model takes
content_filtered Create or job No Change prompt or media; read error.reason
rate_limited, timeout, temporarily_unavailable Job Yes, new key Resubmit after a pause
generation_failed Job Once or twice, new key If it repeats, contact support with the job id
409 idempotency_key_reused Create No Your code sent a different body under an old key

Here is the idempotency detail that matters. An Idempotency-Key on POST /v1/videos stores the first successful response for 24 hours, and a retry with the same key and body gets that response back with Idempotency-Replayed: true, without running or charging anything. That is exactly what you want after a network timeout. But a create call that succeeded and then rendered into a failed job is a stored success, so resubmitting it under the same key hands you the same failed job id. For a deliberate resubmission, use a new key, such as the row id plus an attempt number.

On cost, the docs are direct. A job holds its estimated cost when created and is charged the actual cost when it finishes; a failed job is not charged and its hold is released. Once accepted, a job runs to the end on one channel, so failover happens only at submission. The thing that could double-charge you is a second successful create, which the key prevents. For failures caused by prompts, faces or parameters, our Seedance generation failed fixes go through the usual causes.

05 · A queue worker in Python

This is one way to put the rules together with asyncio and httpx. Rows live in a database table (SQLite here for brevity); the web handler only inserts a row, and the worker does everything else. A restarted worker picks up where it left off, because the state is in the table, not in memory.

import asyncio, json, os, random, sqlite3, uuid
import httpx

BASE = "https://api.oceantoken.ai/v1"
H = {"Authorization": f"Bearer {os.environ['OCEANTOKEN_API_KEY']}"}
db = sqlite3.connect("jobs.db", isolation_level=None)
db.execute("""create table if not exists jobs(id text primary key, body text,
  attempt int default 0, video_id text, status text default 'new', error text)""")
CREATE_SLOTS = asyncio.Semaphore(4)          # size this under your key's rpm
POLL_SLOTS = asyncio.Semaphore(8)            # size this under your key's rpm too
RETRY_JOB = {"rate_limited", "timeout", "temporarily_unavailable", "generation_failed"}

def enqueue(prompt, model="bytedance/seedance-2.5"):
    row = str(uuid.uuid4())                   # called from your web handler
    body = json.dumps({"model": model, "prompt": prompt, "duration": 5, "resolution": "720p"})
    db.execute("insert into jobs(id, body) values(?, ?)", (row, body))
    return row

def retryable(r):
    if r.status_code == 409:                  # only "still running" is worth a retry
        return r.json().get("error", {}).get("code") == "idempotency_key_in_progress"
    return r.status_code in (408, 429) or (r.status_code >= 500 and r.status_code != 501)

async def call(client, method, url, headers=None, **kw):
    hdrs = {**H, **(headers or {})}           # same headers, same key, on every attempt
    r = None
    for n in range(6):
        try:
            r = await client.request(method, url, headers=hdrs, **kw)
            if not retryable(r):
                return r
            wait = r.headers.get("retry-after")
        except httpx.TransportError:
            wait = None
        await asyncio.sleep(float(wait) if wait else min(30, 2 ** n) + random.random())
    return r

async def submit(client, row, body, attempt):
    async with CREATE_SLOTS:
        r = await call(client, "POST", f"{BASE}/videos", content=body,
                       headers={"Idempotency-Key": f"{row}:{attempt}",
                                "Content-Type": "application/json"})
    if r is None or retryable(r):
        return                                # leave the row new; next pass retries with the same key
    if r.status_code >= 400:
        db.execute("update jobs set status='error', error=? where id=?", (r.text, row))
        return
    db.execute("update jobs set video_id=?, status='queued' where id=?", (r.json()["id"], row))

async def poll(client, row, vid, attempt):
    async with POLL_SLOTS:
        r = await call(client, "GET", f"{BASE}/videos/{vid}")
    if r is None or r.status_code >= 400:
        return                                # try again on the next pass
    job = r.json()
    if job["status"] == "completed":
        mp4 = await client.get(f"{BASE}/videos/{vid}/content", headers=H, timeout=300)
        mp4.raise_for_status()
        open(f"store/{row}.mp4", "wb").write(mp4.content)   # replace with your object storage
        db.execute("update jobs set status='done' where id=?", (row,))
    elif job["status"] == "failed":
        code = (job.get("error") or {}).get("code")
        if code in RETRY_JOB and attempt < 2:
            db.execute("update jobs set status='new', attempt=attempt+1, video_id=null "
                       "where id=?", (row,))
        else:
            db.execute("update jobs set status='failed', error=? where id=?",
                       (json.dumps(job.get("error")), row))

async def worker():
    os.makedirs("store", exist_ok=True)
    async with httpx.AsyncClient(timeout=60) as client:
        while True:
            rows = db.execute("select id, body, attempt, video_id, status from jobs "
                              "where status in ('new', 'queued')").fetchall()
            tasks = [submit(client, i, b, a) if s == "new" else poll(client, i, v, a)
                     for i, b, a, v, s in rows]
            await asyncio.gather(*tasks)
            await asyncio.sleep(15 + random.random() * 5)

if __name__ == "__main__":
    asyncio.run(worker())

A few choices are deliberate. The row is written before anything is sent, so a crash between your insert and the API call leaves a new row the worker submits on its next pass, and a crash after the call is covered by the same Idempotency-Key on the next attempt. The key is row:attempt, and call sends the same headers on every attempt, so a network retry reuses the key and a resubmission after a failed job gets a new one.

A 409 is retried only when its code is idempotency_key_in_progress; a 409 idempotency_key_reused means a bug in your code and should stop. Job-level failures that the docs say to "submit again" get at most two more attempts; content and parameter failures go straight to failed for a person to look at. For the full list of request fields, see our Seedance API parameters guide.

If you prefer the same pattern on another model, our Kling API async tasks tutorial walks through a create and poll flow there.

06 · After completion: store the file and tell the user

content_url is valid for 24 hours, and the limits page lists image and video download URLs as kept for that long. Treat it as a pickup ticket, not an address. Download the MP4 in the worker the moment the job completes and write it to your own storage, then hand your users your own URL. A job whose file you never fetched is a bug that only appears a day later, which is why it slips through testing.

The user-facing side benefits from the same table. Because each row has a status and a created time, you can show an honest queue message: "In queue" while queued, "Rendering, usually a few minutes" while in_progress, and a gentle "taking longer than usual" once the job passes your typical render time. Avoid a percentage progress bar; the job reports a status, not a percentage, and a bar that sits near the end for two minutes erodes trust faster than a plain message does.

Log the x-oceantoken-request-id header from create calls next to the row. The errors page says it finds the request in the console's Logs and is what to quote when you write to support. When a user reports a broken clip, you can trace the exact request in seconds.

07 · Launch checklist

Check Why
Row written before the create call A crash never loses or duplicates a request
Idempotency-Key on every create, row:attempt Network retries replay; resubmissions run fresh
Polling in a worker, 10 to 20 s with jitter Web requests stay fast; polls stay under the rpm limit
Retry only 408, 429, 5xx (not 501), 409 in progress Other errors fail the same way again
Separate alert for 400 credit and budget errors A retry loop cannot fix billing
MP4 copied to your storage on completion content_url expires after 24 hours
Stuck-job threshold and review queue Something should notice a job that never finishes
x-oceantoken-request-id stored per row Fast support and debugging
Fallback model id agreed in advance provider_overloaded has somewhere to go

On signup, the docs describe no approval step: an account created with email is active the moment you set a password, and the Seedance API page says an account is created on first sign-in. You can run this checklist against your real key the same day.

How to test this on your workload

We have not load-tested this worker for this article. These checks show how it behaves on your account and your traffic:

  1. Read x-oceantoken-key-rpm-limit from a response and set the semaphore and poll interval so creates plus polls stay below it.
  2. Submit more jobs at once than that limit allows and confirm your code backs off on 429 rate_limited, and whether Retry-After was present.
  3. Kill the worker while jobs are in_progress, restart it, and check every job completes exactly once.
  4. Cut the network during a create call, retry, and confirm the response carries Idempotency-Replayed: true and no second job appears in Media.
  5. Send a value the model does not take, such as a duration outside 4 to 30 on bytedance/seedance-2.5, and confirm the create call is refused with 400 and the row is marked error with no retries.
  6. Leave one completed job undownloaded for a day and confirm your storage copy is the one your app serves.
  7. Check the console's Logs: failed jobs should show no charge.

Our take: Treat every Seedance request as a database row with a state, not as an API call. Write the row first, key every create by row and attempt, poll from a worker at a calm interval, retry only what the docs say can succeed, and store the file the moment it exists. With no webhook to wait for, that sweep is your whole reliability story, and it is a simple one.

Running it on OceanToken

bytedance/seedance-2.5 and bytedance/seedance-2.0 run at the OpenAI-compatible base URL https://api.oceantoken.ai/v1 on POST /v1/videos, with the same fields across the Seedance series, so a fallback from 2.5 to 2.0 is a change of model id, as long as the clip is 15 seconds or shorter, the 2.0 limit. The same key and prepaid balance, with no subscription, also cover the other video and text models your app may call, and each key can carry its own credit limit, which is a simple guard for a production worker.

A value the model does not take is refused before anything runs or is charged, a failed job is not charged and its hold is released, and an Idempotency-Key keeps a retried create from running twice. Seedance is billed per video token; see the current rate on /seedance-api, and model details on the Seedance 2.5 and Seedance 2.0 pages.

FAQ

Does the Seedance API support webhooks? Not on our endpoint, as of November 22, 2026: the docs describe create, poll and download, with no callback field. Poll GET /v1/videos/{id} every 10 to 20 seconds.

What is the Seedance API rate limit? It is set per key, as requests and tokens per minute, and shown in the x-oceantoken-key-rpm-limit and x-oceantoken-key-tpm-limit response headers. Exceeding it returns 429 rate_limited.

Am I charged for a failed Seedance job? No. The docs say a failed job is not charged and its hold on your balance is released.

Can a retry create a second video? Not if you send the same Idempotency-Key and body; the stored response is returned for 24 hours. Use a new key only when you mean to resubmit.

How long is the download link valid? 24 hours. Copy the MP4 to your own storage as soon as the job completes.

Sources

  1. OceanToken docs: Video guide  (checked 2026-11-22)
  2. OceanToken docs: Errors  (checked 2026-11-22)
  3. OceanToken docs: Limits  (checked 2026-11-22)
  4. OceanToken docs: Retries and failover  (checked 2026-11-22)
  5. OceanToken docs: Seedance 2.5 spec (JSON)  (checked 2026-11-22)
  6. OceanToken docs: Create an account  (checked 2026-11-22)
  7. OceanToken: Seedance API page (checked 2026-11-22)

Get your OceanToken API key

  1. Create an OceanToken account and an API key.
  2. Copy the snippet below, paste your key, and run it.
  3. Check the current rate on /seedance-api.
curl https://api.oceantoken.ai/v1/videos \
  -H "Authorization: Bearer $OCEANTOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042:0" \
  -d '{"model": "bytedance/seedance-2.5", "prompt": "A paper boat drifting down a rain gutter, close up, soft light", "duration": 5, "resolution": "720p"}'

Get API Key 

  • Seedance
  • AI video
  • Tutorial
  1. 11 min read

    Veo 3.1 Reference Images API Guide

    How to send reference images to Veo 3.1 through the API: input_references vs first frame, which tiers take them, two-shot Python script and a consistency test.

    • Veo
    • AI video
    • Tutorial
  2. 12 min read

    LLM Function Calling API Across Models

    Write one LLM function calling API loop that works across GPT, Claude, Gemini, Qwen, GLM and DeepSeek: tool_choice, streaming and the silent no-call trap.

    • LLM API
    • Tutorial
  3. 10 min read

    LLM Image Input API: Screenshots and Scans

    Send screenshots, photos and scans to a chat model with one LLM image input API: URL vs base64 data URL, per-model image limits, the 400 error and token costs.

    • LLM API
    • Tutorial