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

# HappyHorse Task Query

> Query the status and result of HappyHorse 1.0 video generation tasks.

After creating a HappyHorse 1.0 video generation task (any of `t2v` / `i2v` / `r2v` / `video-edit`), use this endpoint to poll status and retrieve the result.

## Endpoint

```
GET /v1/video/generations/{task_id}
```

## Quick example

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.ai/v1/video/generations/asyntask_jwgfhsG0m2aDjLmiiELRf74eoWmss6ya \
    -H 'Authorization: Bearer YOUR_API_KEY'
  ```

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

  task_id = "asyntask_jwgfhsG0m2aDjLmiiELRf74eoWmss6ya"
  while True:
      r = requests.get(
          f"https://www.anyfast.ai/v1/video/generations/{task_id}",
          headers={"Authorization": "Bearer YOUR_API_KEY"}
      ).json()
      status = r["data"]["status"]
      if status == "SUCCESS":
          print("Video URL:", r["data"]["result_url"])
          break
      if status == "FAILURE":
          print("Failed:", r["data"]["fail_reason"])
          break
      time.sleep(15)
  ```
</CodeGroup>

## Status values

| `data.status` | Meaning                                         | Action                                       |
| ------------- | ----------------------------------------------- | -------------------------------------------- |
| `NOT_START`   | Task accepted, not yet started                  | Keep polling                                 |
| `QUEUED`      | Queued                                          | Keep polling                                 |
| `IN_PROGRESS` | Processing (`progress` field advances from 50%) | Keep polling, \~15s interval                 |
| `SUCCESS`     | Done                                            | Read `data.result_url`                       |
| `FAILURE`     | Failed                                          | Read `data.fail_reason`; quota auto-refunded |

Total generation time is typically 1–5 minutes. The `result_url` is valid for **24 hours** — download or transfer it immediately.

## Top-level response fields

| Field              | Type   | Description                                                                                     |
| ------------------ | ------ | ----------------------------------------------------------------------------------------------- |
| `data.task_id`     | string | Platform task ID (`asyntask_xxx`)                                                               |
| `data.action`      | string | Sub-type: `generate` / `firstTailGenerate` / `referenceGenerate` / `omniGenerate`               |
| `data.status`      | string | Task status (see table above)                                                                   |
| `data.result_url`  | string | Pre-signed download URL, **valid 24 hours**. Omitted on failure                                 |
| `data.fail_reason` | string | On success: copies `result_url` (backward compat for legacy clients). On failure: error message |
| `data.submit_time` | int64  | Submit timestamp (Unix seconds)                                                                 |
| `data.start_time`  | int64  | Upstream start timestamp; `0` if not started                                                    |
| `data.finish_time` | int64  | Finish timestamp                                                                                |
| `data.progress`    | string | Progress text, e.g. `"50%"`, `"100%"`                                                           |
| `data.request_id`  | string | Request trace ID                                                                                |
| `data.data`        | object | Upstream DashScope raw output + usage (see below)                                               |

## `data.data` — upstream DashScope output

| Field                                                | Description                                                                         |
| ---------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `output.task_id`                                     | Upstream DashScope task ID (different from outer `task_id`)                         |
| `output.task_status`                                 | Upstream status: `PENDING`, `RUNNING`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNKNOWN` |
| `output.video_url`                                   | Upstream-delivered video URL (same as outer `result_url`)                           |
| `output.orig_prompt`                                 | Original prompt echo                                                                |
| `output.submit_time` / `scheduled_time` / `end_time` | Upstream timestamps (string date format)                                            |
| `usage.SR`                                           | Actual resolution tier (number `720` / `1080`)                                      |
| `usage.duration`                                     | Billed total duration                                                               |
| `usage.input_video_duration`                         | Input video duration (`0` for t2v / i2v / r2v; only `video-edit` has this)          |
| `usage.output_video_duration`                        | Actual generated video duration                                                     |
| `usage.ratio`                                        | Actual aspect ratio (returned for t2v / r2v only; not for i2v / video-edit)         |
| `usage.video_count`                                  | Number of videos (always `1`)                                                       |

## Success response

```json theme={null}
{
  "code": "success",
  "message": "",
  "data": {
    "task_id": "asyntask_jwgfhsG0m2aDjLmiiELRf74eoWmss6ya",
    "action": "generate",
    "status": "SUCCESS",
    "fail_reason": "https://dashscope-a717.oss-accelerate.aliyuncs.com/.../xxx_refiner.mp4?Expires=...",
    "result_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/.../xxx_refiner.mp4?Expires=...",
    "submit_time": 1777343862,
    "start_time": 1777343866,
    "finish_time": 1777343961,
    "progress": "100%",
    "request_id": "20260428023742441081000FMrSbjcs",
    "data": {
      "output": {
        "task_id": "e45a6a1b-6f05-43e5-ab06-ddfdc97587a7",
        "task_status": "SUCCEEDED",
        "submit_time": "2026-04-28 10:37:42.625",
        "scheduled_time": "2026-04-28 10:37:42.652",
        "end_time": "2026-04-28 10:39:04.185",
        "orig_prompt": "A cat running on grass",
        "video_url": "https://dashscope-a717.oss-accelerate.aliyuncs.com/.../xxx_refiner.mp4?Expires=..."
      },
      "request_id": "53121cad-c008-9b96-af1d-4289a4fc714b",
      "usage": {
        "SR": 720,
        "duration": 5,
        "input_video_duration": 0,
        "output_video_duration": 5,
        "ratio": "16:9",
        "video_count": 1
      }
    }
  }
}
```

## Failure response

```json theme={null}
{
  "code": "success",
  "message": "",
  "data": {
    "task_id": "asyntask_xxx",
    "action": "generate",
    "status": "FAILURE",
    "fail_reason": "task failed, code: InvalidParameter, message: Field required: input.prompt",
    "submit_time": 1777291928,
    "start_time": 0,
    "finish_time": 1777291932,
    "progress": "100%",
    "request_id": "20260427121207756348000PWNdDIZK"
  }
}
```

The platform **automatically refunds** any pre-deducted quota for failed tasks — no caller action needed.

<Card title="API Reference" icon="code" href="/api-reference/model-api/alibaba/happyhorse-task-query">
  Interactive playground for HappyHorse Task Query.
</Card>

<script src="/feedback.js" />
