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

# HappyHorse query video task

> Query the status and result of a HappyHorse-compatible video task

Use the `output.task_id` returned at creation to query the task. The response preserves the HappyHorse-compatible structure, with the video URL in `output.video_url` after success.

<Warning>
  The task and `video_url` are retained for only 24 hours. Download and store the video promptly after success.
</Warning>

## Polling example

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

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

while True:
    result = requests.get(url, headers=headers).json()
    output = result.get("output", {})
    status = output.get("task_status")
    if status == "SUCCEEDED":
        print(output["video_url"])
        break
    if status in ("FAILED", "CANCELED", "UNKNOWN"):
        print(output.get("code"), output.get("message"))
        break
    time.sleep(5)
```


## OpenAPI

````yaml en/api-reference/video/happyHorse/openapi.json GET /v1/alibaba/video/generations/{taskId}
openapi: 3.0.1
info:
  title: Default Module
  description: ''
  version: 1.0.0
servers: []
security: []
tags: []
paths:
  /v1/alibaba/video/generations/{taskId}:
    get:
      tags: []
      summary: Query task (HappyHorse compatible protocol)
      description: |-
        <p>
        Query the result of a video task
      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/AlibabaQueryTaskResponse'
          headers: {}
      deprecated: false
      security: []
components:
  schemas:
    AlibabaQueryTaskResponse:
      type: object
      properties:
        request_id:
          type: string
          description: >-
            Unique request identifier, can be used for request tracing and
            troubleshooting
        output:
          $ref: '#/components/schemas/TaskOutput1'
          description: Task output information
        usage:
          $ref: '#/components/schemas/Usage'
          description: Output information statistics (returned only when the task succeeds)
    TaskOutput1:
      type: object
      properties:
        task_id:
          type: string
          description: Task ID, queryable for 24 hours
        task_status:
          type: string
          description: >-
            Task status: PENDING / RUNNING / SUCCEEDED / FAILED / CANCELED /
            UNKNOWN
        submit_time:
          type: string
          description: 'Task submission time (UTC+8, format: YYYY-MM-DD HH:mm:ss.SSS)'
        scheduled_time:
          type: string
          description: 'Task execution time (UTC+8, format: YYYY-MM-DD HH:mm:ss.SSS)'
        end_time:
          type: string
          description: 'Task completion time (UTC+8, format: YYYY-MM-DD HH:mm:ss.SSS)'
        video_url:
          type: string
          description: >-
            Video URL (returned only when task_status is SUCCEEDED), valid for
            24 hours, in MP4 format (H.264 codec)
        orig_prompt:
          type: string
          description: Original input prompt
        code:
          type: string
          description: Error code (returned only when the task fails)
        message:
          type: string
          description: Detailed error information (returned only when the task fails)
    Usage:
      type: object
      properties:
        input_video_duration:
          type: integer
          description: Input video duration (seconds)
        output_video_duration:
          type: integer
          description: Output video duration (seconds)
        video_count:
          type: integer
          description: Number of output videos, fixed at 1
        SR:
          type: integer
          description: Resolution tier of the output video (e.g. 720, 1080)
        ratio:
          type: string
          description: Aspect ratio of the output video (e.g. 16:9, 9:16, 1:1)
        duration:
          type: integer
          description: Total video duration (seconds), used for billing

````