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

# HappyHorse 任务查询

> 查询 HappyHorse 1.0 视频生成任务的状态和结果。

创建 HappyHorse 1.0 视频生成任务后（`t2v` / `i2v` / `r2v` / `video-edit` 任一种），使用此端点轮询状态并获取结果。

## 端点

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

## 快速示例

<CodeGroup>
  ```bash cURL theme={null}
  curl https://www.anyfast.com.cn/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.com.cn/v1/video/generations/{task_id}",
          headers={"Authorization": "Bearer YOUR_API_KEY"}
      ).json()
      status = r["data"]["status"]
      if status == "SUCCESS":
          print("视频 URL:", r["data"]["result_url"])
          break
      if status == "FAILURE":
          print("失败:", r["data"]["fail_reason"])
          break
      time.sleep(15)
  ```
</CodeGroup>

## 任务状态

| `data.status` | 含义                         | 后续动作                         |
| ------------- | -------------------------- | ---------------------------- |
| `NOT_START`   | 任务已接收，尚未开始                 | 继续轮询                         |
| `QUEUED`      | 排队中                        | 继续轮询                         |
| `IN_PROGRESS` | 处理中（`progress` 从 50% 开始递进） | 继续轮询，建议 15s 间隔               |
| `SUCCESS`     | 完成                         | 读取 `data.result_url`         |
| `FAILURE`     | 失败                         | 读取 `data.fail_reason`，平台自动退费 |

视频生成约需 1-5 分钟。`result_url` 有效期 **24 小时**——请立即下载或转存。

## 顶层响应字段

| 字段                 | 类型     | 说明                                                                            |
| ------------------ | ------ | ----------------------------------------------------------------------------- |
| `data.task_id`     | string | 平台任务 ID（`asyntask_xxx` 格式）                                                    |
| `data.action`      | string | 任务子类型：`generate` / `firstTailGenerate` / `referenceGenerate` / `omniGenerate` |
| `data.status`      | string | 任务状态（见上表）                                                                     |
| `data.result_url`  | string | 预签名下载 URL，**有效期 24 小时**。失败任务此字段省略                                             |
| `data.fail_reason` | string | 成功时复制 `result_url`（兼容老客户端）；失败时为错误信息                                           |
| `data.submit_time` | int64  | 提交时间戳（Unix 秒）                                                                 |
| `data.start_time`  | int64  | 上游开始时间戳；未开始为 `0`                                                              |
| `data.finish_time` | int64  | 完成时间戳                                                                         |
| `data.progress`    | string | 进度百分比文本，如 `"50%"`、`"100%"`                                                    |
| `data.request_id`  | string | 请求溯源 ID                                                                       |
| `data.data`        | object | 上游 DashScope 原始 output + usage（见下文）                                           |

## `data.data` — 上游 DashScope 输出

| 字段                                                   | 说明                                                                           |
| ---------------------------------------------------- | ---------------------------------------------------------------------------- |
| `output.task_id`                                     | 上游 DashScope 任务 ID（与外层 `task_id` 不同）                                         |
| `output.task_status`                                 | 上游状态：`PENDING` / `RUNNING` / `SUCCEEDED` / `FAILED` / `CANCELED` / `UNKNOWN` |
| `output.video_url`                                   | 上游交付的视频 URL（与外层 `result_url` 一致）                                             |
| `output.orig_prompt`                                 | 原始 prompt 回显                                                                 |
| `output.submit_time` / `scheduled_time` / `end_time` | 上游各阶段时间（字符串日期格式）                                                             |
| `usage.SR`                                           | 实际生成的分辨率档位（数字 `720` / `1080`）                                                |
| `usage.duration`                                     | 计费总时长                                                                        |
| `usage.input_video_duration`                         | 输入视频时长（t2v / i2v / r2v 是 0；video-edit 才有）                                    |
| `usage.output_video_duration`                        | 实际生成视频时长                                                                     |
| `usage.ratio`                                        | 实际宽高比（仅 t2v / r2v 返回；i2v / video-edit 不返回）                                   |
| `usage.video_count`                                  | 视频数量（恒为 `1`）                                                                 |

## 成功响应

```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": "一只猫在草地上奔跑",
        "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
      }
    }
  }
}
```

## 失败响应

```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"
  }
}
```

平台**自动退还**预扣额度——无需调用方操作。

<Card title="API 参考" icon="code" href="/zh/api-reference/model-api/alibaba/happyhorse-task-query">
  HappyHorse 任务查询 交互式 Playground。
</Card>

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