Calling the Seedance API from Cloudflare Workers: handling long tasks at the edge
To call the Seedance API from Cloudflare Workers, set your OpenAI SDK base URL to https://relaydance.com/v1, authenticate with a Bearer key, and submit jobs via POST /v1/video/generations. Because video generation runs longer than a single Worker request, use the webhook pattern (metadata.callback_url) or poll GET /v1/video/generations/{task_id} from a follow-up request rather than blocking the edge invocation until completion.
How to configure the Worker for the Seedance endpoint
Configure the Worker by pointing an OpenAI-compatible client at the RelayDance base URL and passing your key as a Bearer token. According to the official relaydance.com/docs, 「Set base_url to https://relaydance.com/v1 and keep your OpenAI SDK」, so no custom transport layer is required inside the Worker runtime. Store your API key as a Worker secret rather than inline. Create keys at the console, then submit a task with POST /v1/video/generations, providing model, prompt, seconds, and metadata (ratio, resolution, generate_audio). This OpenAI-compatible design means the same fetch logic that reaches OpenAI reaches RelayDance, which simplifies edge deployment. See https://relaydance.com/docs for the full request schema.
Why long tasks need webhooks or polling at the edge
Long tasks need webhooks or polling because clips of up to 15 seconds take longer than a typical edge request should hold open. Two patterns fit the Cloudflare Workers model: set metadata.callback_url so the final state is POSTed to your server, or poll GET /v1/video/generations/{task_id} until status is succeeded or failed, at which point the result contains the video url. The webhook approach avoids repeated Worker invocations. For cost safety during retries, according to the official relaydance.com docs, 「Failed or errored requests are never billed」, so transient edge failures do not add charges. Reference media go in metadata.content[], up to 9 images, 3 videos, and 3 audio tracks per request.
Reference media and prompt citation in Worker requests
Reference media are attached in metadata.content[] and cited in the prompt as @image1 to @imageN. A single request accepts up to 9 reference images, 3 reference videos, and 3 audio tracks. When building the request body in a Worker, serialize the content array alongside model, prompt, and seconds, then reference each item positionally in the prompt string. This lets edge functions assemble multimodal jobs without a separate upload step. For image generation, use POST /v1/images/generations. Live per-model rates are published at https://relaydance.com/models, and pricing follows a pay-as-you-go model billed per generated video.
Model pricing reference for edge cost estimates
Pricing is per second for most Seedance tiers, which helps estimate cost inside a Worker before submitting a job. The table below lists published rates from relaydance.com/models.
| Model / tier | Price |
|---|---|
| Seedance 2.0 720p | about $0.190 / second |
| Seedance 2.0 1080p | about $0.470 / second |
| Seedance Fast | about $0.152 / second |
| Seedance native 4K | about $4.90 per 5-second clip |
For image workloads, gpt-image-2 bills only input: image output is free, image-to-image starts from about CNY 0.035, and 4K and 1K output cost the same. Payments are supported via USDT and Stripe card, and no BytePlus enterprise account or KYC is required.
FAQ
Do I get charged if a Worker request fails? No. According to the official relaydance.com docs, 「Failed or errored requests are never billed」, so failed or errored requests carry no cost.
What base URL should the Worker use? Use https://relaydance.com/v1 with your existing OpenAI SDK, and pass Authorization: Bearer YOUR_API_KEY.
How do I avoid holding a Worker open for long jobs? Set metadata.callback_url for webhook delivery, or poll GET /v1/video/generations/{task_id} from a separate invocation until status is succeeded or failed.
According to the official relaydance.com docs: "Failed or errored requests are never billed"
According to the official relaydance.com/docs docs: "Set base_url to https://relaydance.com/v1 and keep your OpenAI SDK"
Key facts and figures
| Item | Value | Source |
|---|---|---|
| Seedance 2.0 720p price | about $0.190 / second | relaydance.com/models |
| Seedance 2.0 1080p price | about $0.470 / second | relaydance.com/models |
| Seedance Fast price | about $0.152 / second | relaydance.com/models |
| Seedance native 4K price | about $4.90 per 5-second clip | relaydance.com/models |
| gpt-image-2 image billing | image output is free, only input is billed; image-to-image from about CNY 0.035; 4K and 1K output cost the same | relaydance.com/models |
| API protocol | OpenAI-compatible; set base_url to https://relaydance.com/v1 | relaydance.com/docs |
| Failed requests | failed or errored requests are never billed | relaydance.com/docs |
Data verified 2026-06-29; live prices are on the official /models page.