Video Generation
Async video task API: submit a task, poll progress, cancel — billed per call or per second with a hold.
Submit a task
- Auth: header
Authorization: Bearer sk-tp-...(create an API Key in the console) - Content-Type:
application/json
Request body
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | Platform video model name, see Models |
| prompt | string | Yes | Generation prompt, must not be empty |
| duration | number | Depends | Required for per-second models (duration or seconds), 1-600 seconds, rounded up, defaults to 5 |
| quantity | number | Depends | Number of videos for per-call models, positive integer, defaults to 1 |
| resolution | string | No | Resolution preference: 480p / 720p / 1080p / 4k; mapped to the vendor's field when needed (e.g. Kling mode), explicit mode wins |
| seed | number | No | Random seed; only some upstream models support it, ignored otherwise |
| watermark | boolean | No | Watermark toggle, upstream default when omitted; mapped to Kling watermark_info.flag |
| media | array | No | First / middle / last frame plus reference image / video / audio, see Media |
| vendorOptions | object | No | Vendor-native passthrough: key-values submitted as-is to the upstream protocol (e.g. camera_control); cannot override core fields like model / prompt / duration / callback_url / external_task_id |
| Other params | - | No | negativePrompt, multiShot, mode, etc. are passed through per model |
Media (first / middle / last frame + references)
The media array describes frame control and reference assets in one place; the platform maps it to the upstream fields of the model's protocol.
| Field | Type | Required | Description |
|---|---|---|---|
| media[].role | string | Yes | first_frame / middle_frame / last_frame / reference_image / reference_video / reference_audio; type is also accepted |
| media[].url | string | Yes | Asset URL; image_url.url / video_url.url / audio_url.url are also accepted |
Roles supported per protocol:
| Protocol | Supported roles | Notes |
|---|---|---|
| seedance (Volcengine Ark / haoee seedance family) | All 6 | First/last frames and references are mutually exclusive; asset count limits are enforced upstream |
| Wan / HappyHorse (DashScope) | All 6 | Same as above; array order is the "image 1 / video 1 / audio 1" order used in the prompt |
| MiniMax (hailuo family) | first_frame / last_frame | References not supported yet |
| Kling (native / Omni) | None | The unified media array is unavailable; use vendorOptions to pass upstream-native fields |
Notes:
- Middle frame: no upstream has a native middle-frame field today, so the platform maps middle frames to keyframe reference images (
reference_image) in order; refer to them as "image 1 … image N" in the prompt. Kling and MiniMax protocols do not support middle frames. - A role the model does not support returns
400at submit time; no task is created and nothing is held. - The legacy single-field forms (
image_url/first_frame_image/last_frame_image) keep working.
Optional header
| Header | Description |
|---|---|
| Idempotency-Key | Idempotency key. Re-submitting with the same key returns the original task — no duplicate task or hold is created |
Response
Returns a platform task object. Only the platform task ID is exposed; upstream task IDs are never revealed:
Query a task
Returns the task object, same structure as above. When the task succeeds, result.url is the video download URL. It is provided by the upstream provider and is usually valid for 24 hours; download and store it promptly. Expired URLs cannot be regenerated.
Cancel a task
Only in-progress tasks (pending / submitted / running) can be canceled; calling cancel on a finished task returns it as-is without error.
Task statuses
| Status | Description |
|---|---|
| pending | Created, waiting to be submitted upstream |
| submitted | Submitted upstream, waiting for generation |
| running | Generating; progress is the percentage |
| succeeded | Done; result.url is the video URL |
| failed | Failed; error.code / error.message give the reason |
| timeout | Task timed out |
| canceled | Canceled |
Billing
- On successful submission the platform holds an amount of unit price × quantity (per call) or duration in seconds (per second). Held funds count against available balance but produce no billing ledger entry yet.
- On success the hold is settled into a real charge and written to the billing ledger; on failure, timeout, or cancellation the hold is released at no cost.
- Per-second models:
durationis rounded up to billed seconds, 1-600 seconds. - Per-token models (seedance):
outputPriceis CNY per million tokens. On submit, an estimate from resolution × duration is held (with 10% headroom); after success, settlement uses the upstream's actual token usage, and any difference is automatically refunded to your balance.
Pre-checks
The platform validates in order; any failure returns the corresponding error:
- Key valid and not revoked (including all parents), account active → otherwise
401 - Model exists and is live (
LIVE), priced per call/second with a unit price, and has a usable upstream route → otherwise400 promptnot empty,duration(per-second models) within 1-600 seconds → otherwise400mediawell-formed and every role supported by the model's protocol → otherwise400- Available balance (balance minus holds) covers this hold → otherwise
402 - Key chain quota not exhausted → otherwise
402
Notes
- Tasks are bound to the API Key that created them: query and cancel must use the same Key.
- The platform polls upstream progress automatically; no need to resubmit repeatedly. A 5-10 second polling interval is recommended.
- If an upstream channel is degraded due to credit exhaustion,
503is returned; the platform does not automatically switch vendors.
Errors
For error response format and troubleshooting see FAQ · Error codes. Upstream model errors are reported in normalized form via the task's error field.