Create task
Creates a unified async task.
POST /v1/tasks
Used to submit async tasks directly in advanced scenarios. For regular video generation, prefer /v1/videos/generations.
Back to Task endpoint listRequest parameters
| Field | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Task type, such as video_generation or audio_generation. |
model | string | Yes | Model ID used by the task. |
capability | string | No | Task capability tag. |
input | object | Yes | Task input; fields vary by task type. |
options | object | No | Task options. |
response_mode | object | No | Response mode, such as webhook configuration. |
routing | object | No | Routing preference, such as provider or strategy tags. |
webhook_url | string | No | Callback URL after the task ends. |
metadata | object | No | Application metadata. |
priority | integer | No | Task priority from 0 to 10. |
idempotency_key | string | No | Idempotency key in the request body; the Idempotency-Key header may also be used. |
Idempotency-Key | header | No | Idempotency key to avoid duplicate task creation during client retries. |
Request examples
curl "https://api.globalrouter.com/v1/tasks" \
-H "Authorization: Bearer $GR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "video_generation",
"model": "seedance-video",
"capability": "video_generation",
"input": { "prompt": "城市天台日落", "duration": 5 },
"options": { "aspect_ratio": "16:9" },
"response_mode": {
"webhook": { "url": "https://example.com/webhooks/gr-task" }
},
"routing": { "provider": "doubao" },
"webhook_url": "https://example.com/webhooks/gr-task",
"metadata": { "project": "docs-demo" },
"priority": 5,
"idempotency_key": "task-demo-001"
}'Response fields
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Task ID. |
object | string | Yes | Always task. |
status | string | Yes | Task status. |
progress | number | Yes | Task progress, from 0 to 1. |
progress_detail | object | No | Detailed progress information. |
type | string | Yes | Task type. |
capability | string | No | Task capability tag. |
model | string | Yes | Model ID used by the task. |
input | object | Yes | Task input snapshot. |
output | array | No | Artifact list after task success. |
result | object | No | Provider result summary. |
error | object | No | Error information when the task fails. |
usage | object | No | Usage and billing details. |
attempt | object | Yes | Retry count summary, including current and max. |
links | object | No | Query, cancellation, or event subscription URL. |
provider | string | No | Provider that executed the task. |
cost_usd | number | No | Task cost. |
billing_model_key | string | No | Billing model key. |
discount_id | string | No | Discount ID. |
discount_factor | number | Yes | Discount factor. |
list_cost | number | Yes | List-price cost before discounts. |
discount_amount | number | Yes | Discount amount. |
actual_cost | number | Yes | Actual charge. |
webhook_url | string | No | Task callback URL. |
metadata | object | No | Application metadata. |
priority | integer | Yes | Task priority. |
started_at | string | No | Task start time. |
finished_at | string | No | Task end time. |
completed_at | string | No | Task completion time. |
canceled_at | string | No | Task cancellation time. |
created_at | string | Yes | Task creation time. |
updated_at | string | Yes | Task update time. |
Response example
{
"id": "task_01HV...",
"object": "task",
"type": "video_generation",
"status": "queued",
"progress": 0,
"progress_detail": {},
"model": "seedance-video",
"input": { "prompt": "城市天台日落", "duration": 5 },
"output": null,
"result": null,
"error": null,
"usage": null,
"attempt": { "current": 1, "max": 3 },
"links": { "self": "/v1/tasks/task_01HV..." },
"provider": "doubao",
"metadata": { "project": "docs-demo" },
"priority": 5,
"created_at": "2026-06-26T10:00:00Z",
"updated_at": "2026-06-26T10:00:00Z"
}Errors
| HTTP | Code | Description |
|---|---|---|
| 401 | UNAUTHORIZED | Missing or invalid Authorization Bearer token. |
| 403 | FORBIDDEN | The current API key is not allowed to call this scope or model. |
| 429 | RATE_LIMITED | Requests are too frequent or the asynchronous task queue is full; reduce concurrency or retry later. |