nexusflow
Online
Async Tasks / Async Tasks

Async Tasks API

Image and video generation use the unified /v1/tasks interface. Video models use asynchronous invocation (create a task to get a task_id, then poll for the result), while image models (such as wan2.6-t2i) use synchronous invocation, returning the result directly without polling. Video generation typically takes 1-5 minutes.

HTTP Invocation Workflow

1
Create task and get task_id
POSThttps://nexusflow.vip/v1/tasks
2
Poll result by task_id
GEThttps://nexusflow.vip/v1/tasks/{task_id}
Note:
  • After successful creation, use the returned id (i.e., task_id) to query results. Do not create duplicate tasks; just poll to retrieve results.
  • Image models (such as wan2.6-t2i) are synchronous; the creation request returns the result directly, no polling needed.
  • Video models polling recommended interval 10-15 seconds.
  • task_id query validity period 24 hours; it cannot be queried after expiration.
  • Output file URL validity period 24 hours; please download and save immediately after retrieval.
  • Only image and video models support the /v1/tasks interface; chat models use /v1/chat/completions.

Step 1: Create Task

Example Model:wan2.6-t2i

Request Parameters

ParametersTypeRequiredDescription
modelstring*Model ID, such as wan2.6-t2i. See the Models documentation for the full list.
promptstring*Text prompt, describing the desired image content.
negative_promptstring-Negative prompt, describing content you do not want in the output.
sizestring-Output image size, such as 1024x1024 (default), 720x1280, 1280x720, etc.
ninteger-Number of images to generate, default 1, up to 4.
seedinteger-Random seed; a fixed seed improves reproducibility.

Request Example

curl -X POST 'https://nexusflow.vip/v1/tasks' \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "wan2.6-t2i",
    "prompt": "An orange cat standing on the moon's surface, with Earth in the background, cyberpunk style, 4K ultra HD",
    "size": "1024x1024",
    "n": 1
  }'

Step 1 Response: Get task_id

After successful creation, task information is returned (HTTP 202). The id serves as the task_id for subsequent polling queries.

{
  "id": "task_0385dc79-5ff8-4d82-xxxx",
  "object": "task",
  "status": "running",
  "model": "wan2.6-t2i",
  "type": "image",
  "created_at": "2026-06-01T10:00:00.000Z"
}
FieldDescription
idTask ID (task_id). Used for polling video task results, valid for 24 hours.
objectFixed value "task".
statusVideo models start with status running; image models (such as wan2.6-t2i) are synchronous and return succeeded directly.
modelThe model ID used.
typeTask type: "image" (Image Generation) or "video" (Video Generation).
created_atTask creation time (ISO 8601 format).

Step 2: Poll Result by task_id

GEThttps://nexusflow.vip/v1/tasks/{task_id}

Query Request

curl https://nexusflow.vip/v1/tasks/task_0385dc79-5ff8-4d82-xxxx \
  -H "Authorization: Bearer $API_KEY"

Image task execution succeeded

{
  "id": "task_0385dc79-5ff8-4d82-xxxx",
  "object": "task",
  "status": "succeeded",
  "model": "wan2.6-t2i",
  "type": "image",
  "progress": 100,
  "output": {
    "image_url": "https://dashscope-result.oss-cn-beijing.aliyuncs.com/xxx.png"
  },
  "created_at": "2026-06-01T10:00:00.000Z",
  "completed_at": "2026-06-01T10:00:22.000Z"
}

Task Execution Failed

{
  "id": "task_0385dc79-5ff8-4d82-xxxx",
  "object": "task",
  "status": "failed",
  "model": "wan2.6-t2i",
  "type": "image",
  "error": "InvalidParameter: The parameter is invalid.",
  "created_at": "2026-06-01T10:00:00.000Z",
  "completed_at": "2026-06-01T10:00:05.000Z"
}

Response Parameters

FieldTypeDescription
idstringTask ID.
objectstringFixed value "task".
statusstringTask status: pending (queued) → running (processing) → succeeded / failed.
modelstringThe model ID used.
typestringTask type: "image" or "video".
progressintegerTask progress percentage 0-100.
outputobjectGeneration result (only returned on success). Image tasks include image_url; video tasks include video_url. Link valid for 24 hours.
errorstringFailure reason (only returned on failure).
created_atstringTask creation time (ISO 8601 format).
completed_atstringTask completion time (only returned for final states).

Query Task List

GEThttps://nexusflow.vip/v1/tasks?limit=20

Retrieve the current user's recent task list. Use the limit parameter to control the number of results returned (default 20, maximum 100).

curl 'https://nexusflow.vip/v1/tasks?limit=5' \
  -H "Authorization: Bearer $API_KEY"
{
  "object": "list",
  "data": [
    {
      "id": "task_0385dc79-5ff8-4d82-xxxx",
      "object": "task",
      "status": "succeeded",
      "model": "wan2.6-t2i",
      "type": "image",
      "progress": 100,
      "created_at": "2026-06-01T10:00:00.000Z",
      "completed_at": "2026-06-01T10:00:22.000Z"
    },
    {
      "id": "task_a1b2c3d4-e5f6-7890-yyyy",
      "object": "task",
      "status": "running",
      "model": "happyhorse-1.0-t2v",
      "type": "video",
      "progress": 45,
      "created_at": "2026-06-01T10:05:00.000Z",
      "completed_at": null
    }
  ]
}

Best Practices

Smart Polling Intervals
Poll image tasks every 5-10 seconds and video tasks every 10-15 seconds. Avoid sub-second polling to reduce unnecessary requests.
Separate Sync and Async
Chat requests go to /v1/chat/completions, image/video to /v1/tasks, reducing mutual interference.
Download Results Promptly
Output URLs are valid for 24 hours. Download and save files immediately after task completion.
Handle Failures and Retries
When a task fails, check the error field to determine the cause. Parameter errors require fixing before retrying; upstream timeouts can be retried by creating a new task.
HappyHorse API
View HappyHorse Video Generation dedicated documentation
Rate Limits
View limits and optimization tips for high concurrency
Full Pricing
View pricing for all models