> ## 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.

# 通用视频任务查询

> 查询通用视频生成任务的状态与生成结果

使用创建视频任务时返回的 `task_id` 查询生成状态。任务成功后，响应中会包含视频地址。

<Tip>
  建议每 10-15 秒轮询一次。视频生成通常需要几十秒到数分钟。
</Tip>

## 轮询示例

```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 zh/api-reference/video/generation/openapi.json GET /v1/video/generations/{taskId}
openapi: 3.0.1
info:
  title: 默认模块
  description: ''
  version: 1.0.0
servers: []
security: []
tags: []
paths:
  /v1/video/generations/{taskId}:
    get:
      tags: []
      summary: 查询视频生成任务状态
      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: 通用视频任务状态查询响应
      deprecated: false
      security: []
components:
  schemas:
    VideoTaskStatusResponse:
      type: object
      properties:
        task_id:
          type: string
          description: 任务ID
        video_url:
          type: string
          description: 视频地址（成功时；上游地址）
        video_duration:
          type: number
          description: 视频时长（秒，成功时）
        error_code:
          type: string
          description: 错误码（失败时）
        error_message:
          type: string
          description: 错误信息（失败时）
        status:
          type: string
          description: 任务状态：queued / running / succeeded / failed / cancelled / expired
        resolution:
          type: string
          description: 生成视频分辨率：480p / 720p / 1080p / 4k
        ratio:
          type: string
          description: 生成视频宽高比：16:9 / 4:3 / 1:1 / 3:4 / 9:16 / 21:9
        model:
          type: string
          description: 平台模型编号（model_no，用于协议透传时替换上游 model 名称）
        created:
          type: integer
          description: 创建时间（epoch 毫秒）-UTC标准时间
          format: int64
        updated:
          type: integer
          description: 更新时间（epoch 毫秒）-UTC标准时间
          format: int64
        usage:
          $ref: '#/components/schemas/Usage'
          description: 用量统计（成功时；时长类取自万相 usage，token 类取自 seedance usage）
    Usage:
      type: object
      properties:
        input_video_duration:
          type: integer
          description: 输入视频时长（秒）
        output_video_duration:
          type: integer
          description: 输出视频时长（秒）
        total_tokens:
          type: integer
          description: 此请求的令牌总数。
          format: int64
        duration:
          type: integer
          description: >-
            总的视频时长（秒），用于计费:计算公式：duration = input_video_duration +
            output_video_duration

````