> ## Documentation Index
> Fetch the complete documentation index at: https://docs.haitoken.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Query video generation task

> Query the status and result of a common video generation task

Use the `task_id` returned when creating a video task to query its status. After the task succeeds, the response includes the video URL.

<Tip>
  Poll every 10-15 seconds. Video generation typically takes from tens of seconds to a few minutes.
</Tip>

## Polling example

```python Python theme={null}
import time
import requests

task_id = "cgt-20260730120000-a1b2c3"
url = f"https://api.haitoken.ai/v1/video/generations/{task_id}"
headers = {"Authorization": "Bearer YOUR_API_KEY"}

while True:
    result = requests.get(url, headers=headers).json()
    if result["status"] == "succeeded":
        print(result["video_url"])
        break
    if result["status"] in ("failed", "cancelled", "expired"):
        break
    time.sleep(5)
```


## OpenAPI

````yaml en/api-reference/video/generation/openapi.json GET /v1/video/generations/{taskId}
openapi: 3.0.1
info:
  title: Default Module
  description: ''
  version: 1.0.0
servers: []
security: []
tags: []
paths:
  /v1/video/generations/{taskId}:
    get:
      tags: []
      summary: Query video generation task status
      parameters:
        - name: taskId
          in: path
          description: ''
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: API Key token (Bearer sk-xxx)
          required: true
          example: 'Bearer '
          schema:
            type: string
        - name: Content-Type
          in: header
          description: ''
          example: application/json
          schema:
            type: string
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoTaskStatusResponse'
                description: Generic video task status query response
      deprecated: false
      security: []
components:
  schemas:
    VideoTaskStatusResponse:
      type: object
      properties:
        task_id:
          type: string
          description: Task ID
        video_url:
          type: string
          description: Video URL (on success; upstream address)
        video_duration:
          type: number
          description: Video duration (seconds, on success)
        error_code:
          type: string
          description: Error code (on failure)
        error_message:
          type: string
          description: Error message (on failure)
        status:
          type: string
          description: >-
            Task status: queued / running / succeeded / failed / cancelled /
            expired
        resolution:
          type: string
          description: 'Generated video resolution: 480p / 720p / 1080p / 4k'
        ratio:
          type: string
          description: 'Generated video aspect ratio: 16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9'
        model:
          type: string
          description: >-
            Platform model number (model_no, used to replace the upstream model
            name during protocol pass-through)
        created:
          type: integer
          description: Creation time (epoch milliseconds) - UTC
          format: int64
        updated:
          type: integer
          description: Update time (epoch milliseconds) - UTC
          format: int64
        usage:
          $ref: '#/components/schemas/Usage'
          description: >-
            Usage statistics (on success; duration fields from Wan usage, token
            fields from seedance usage)
    Usage:
      type: object
      properties:
        input_video_duration:
          type: integer
          description: Input video duration (seconds)
        output_video_duration:
          type: integer
          description: Output video duration (seconds)
        total_tokens:
          type: integer
          description: Total number of tokens for this request.
          format: int64
        duration:
          type: integer
          description: >-
            Total video duration (seconds), used for billing. Formula: duration
            = input_video_duration + output_video_duration

````