Public Task Contract
Create responses can include:| Field | Meaning | What to do |
|---|---|---|
id | Public TokenLab task ID | Store it with your own job record |
task_id | Compatibility alias for the same public task identity | Treat it as equivalent to id |
status | Current public task status | Start polling when it is not terminal |
poll_url | Preferred status URL | Use this first when present |
model | Model requested or resolved by the endpoint | Store it for support and billing reconciliation |
/v1/tasks/{id} is the canonical fixed status endpoint for public async media jobs. Media-specific status routes may exist for compatibility, but new integrations should prefer poll_url or /v1/tasks/{id}.
Recommended Flow
- Validate the user request and send the create call with an explicit
model. - Persist
id/task_id,poll_url, endpoint, model, user ID, and your own job ID before returning control to the UI. - Poll every
5-10sfor long-running media tasks. - Stop only when the task is
completedorfailed. - On
completed, read the media-specific result fields and store final URLs or metadata. - On
failed, store the public error and offer retry only as a new user-visible job.
Polling Example
pending, processing, completed, and failed. Cancelled tasks are represented as failed with cancelled: true and cancellation_status: "cancelled" so older status handling keeps working.
Client Retry Rules
Network timeouts are the most common source of duplicate jobs. Use this rule:| Where timeout happens | Safer behavior |
|---|---|
| Before your server receives a create response | Check server logs for request_id; retry only if no task was created |
| After a create response was stored | Resume polling the stored task_id |
| During polling | Retry the status request with backoff |
| After terminal status | Do not poll again unless the user explicitly refreshes the record |
Billing And Settlement
Async jobs can reserve an estimated amount when the create request is accepted. Final settlement happens after terminal status. When available, task status responses can exposebilling_transaction_id and the X-Billing-Transaction-ID header.
For reconciliation, join these identifiers in your logs:
request_idfrom the create request.task_id/idfrom the task.billing_transaction_idwhen present.- Your own user ID, project ID, or job ID.
Cancellation
DELETE /v1/tasks/{id} is intentionally narrow. It currently supports queued Volcengine Seedance video tasks such as seedance-1.5-pro, seedance-2.0, and seedance-2.0-fast.
Unsupported tasks return 400 unsupported_task_cancel. Tasks that are already running or terminal return 409 task_not_cancellable. Build cancellation UI as “request cancellation” rather than a guaranteed stop button.
Troubleshooting
| Symptom | Likely cause | What to check |
|---|---|---|
async_task_not_found | Task is unknown, expired, inaccessible to this API key, or not a public async task | Confirm API key ownership and the stored public task_id |
| Task never appears to finish | Client keeps polling the wrong URL or stopped before terminal status | Use poll_url or /v1/tasks/{id} and inspect the latest status |
| Final media URL missing | Task is not completed, or the upstream job completed without usable output | Keep polling until terminal, then handle missing output as failed |
| User sees duplicates | Retry path created a new task after timeout or refresh | Deduplicate by your own job ID and stored task_id |
| Billing mismatch | Settlement is async or client is comparing provider IDs | Compare request_id, task_id, and billing_transaction_id |
Support Packet
When contacting support, includerequest_id, task_id, billing_transaction_id when present, endpoint, model, timestamp, and a sanitized request shape. Do not include API keys, private media, signed URLs, or full prompts unless support asks for a redacted sample.
API Reference
| Topic | Reference |
|---|---|
| Get Task Status | Get Task Status |
| Cancel Task | Cancel Task |
| Image Generation | Image Generation |
| Video Generation | Video Generation |
| Music Generation | Music Generation |
| 3D Generation | 3D Generation |
| Billing & Pricing | Billing & Pricing |