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

# 查询视频生成任务

> 查询异步视频生成任务的状态、视频结果和用量信息。
建议轮询间隔不少于 3 秒，生产环境建议 5–10 秒。
任务成功后从 `content.video_url` 获取生成视频，请及时下载转存。


查询异步视频生成任务的状态、视频结果和用量信息。

```
GET /v1/videos/generations/{id}
Authorization: Bearer <API_KEY>
```

`id` 为 [创建视频生成任务](/api/videos/create-task) 返回的任务 ID，格式通常以 `vidtask_` 开头。

<Warning>
  不要高频轮询。建议间隔 **5–10 秒**，最短不低于 3 秒。视频生成通常需要 30 秒至数分钟。
</Warning>

***

## 示例

```bash theme={null}
curl "https://{your-domain}/v1/videos/generations/vidtask_3cb6299b32d24f93a82e8a74b3e06161" \
  -H "Authorization: Bearer $API_KEY"
```

***

## 响应字段

| 字段                             | 类型             | 说明                                            |
| ------------------------------ | -------------- | --------------------------------------------- |
| `id`                           | string         | 平台任务 ID。                                      |
| `object`                       | string         | 固定为 `video.generation.task`。                  |
| `created`                      | integer        | 任务创建时间，Unix 秒。                                |
| `created_at`                   | integer        | 任务创建时间，Unix 秒（同 `created`）。                   |
| `updated_at`                   | integer        | 任务状态最后更新时间，Unix 秒。                            |
| `model`                        | string         | 平台模型名称。                                       |
| `status`                       | string         | 任务状态，见下方说明。                                   |
| `billing_status`               | string         | 平台账务状态，见下方说明。                                 |
| `content`                      | object         | 视频生成结果，任务成功时返回。                               |
| `content.video_url`            | string         | 生成视频 URL，**请及时下载和转存**，URL 有有效期。               |
| `content.video_url_expires_at` | string         | 视频 URL 过期时间，RFC3339 格式。                       |
| `error`                        | object         | 失败任务的错误信息，`status=failed` 时返回。                |
| `error.code`                   | string         | 错误码，例如 `OutputVideoSensitiveContentDetected`。 |
| `error.message`                | string         | 错误说明。                                         |
| `usage`                        | object         | Token 用量，任务完成后返回。                             |
| `usage.completion_tokens`      | integer        | 输出 Token 数。                                   |
| `usage.total_tokens`           | integer        | 总 Token 数。                                    |
| `seed`                         | integer        | 实际使用的随机种子，存在时返回。                              |
| `resolution`                   | string         | 实际生成视频的分辨率，存在时返回。                             |
| `ratio`                        | string         | 实际生成视频的宽高比，存在时返回。                             |
| `duration`                     | integer/string | 实际生成视频时长（秒），存在时返回。                            |
| `frames`                       | integer        | 生成视频总帧数，存在时返回。                                |
| `framespersecond`              | integer        | 生成视频帧率，存在时返回。                                 |
| `generate_audio`               | boolean        | 是否包含同步音频，存在时返回。                               |
| `service_tier`                 | string         | 任务服务等级，存在时返回。                                 |

***

## 任务状态

| `status`    | 说明                                  | 下一步操作                      |
| ----------- | ----------------------------------- | -------------------------- |
| `queued`    | 排队中，等待处理。                           | 继续轮询                       |
| `running`   | 视频正在生成中。                            | 继续轮询                       |
| `succeeded` | 任务成功。                               | 读取 `content.video_url` 并下载 |
| `failed`    | 任务失败。                               | 查看 `error` 字段排查原因          |
| `cancelled` | 任务已取消。                              | 无需处理                       |
| `expired`   | 任务超时，已超过 `execution_expires_after`。 | 重新提交任务                     |

***

## 账务状态

| `billing_status` | 说明                |
| ---------------- | ----------------- |
| `frozen`         | 已冻结预估费用，任务尚未最终结算。 |
| `settling`       | 结算处理中。            |
| `settled`        | 已成功结算。            |
| `refunded`       | 任务失败、取消或超时后已退款。   |
| `settle_failed`  | 结算失败，请联系平台处理。     |
| `refund_failed`  | 退款失败，请联系平台处理。     |

***

## 响应示例

<CodeGroup>
  ```json 排队中 theme={null}
  {
    "id": "vidtask_3cb6299b32d24f93a82e8a74b3e06161",
    "object": "video.generation.task",
    "created": 1779782400,
    "created_at": 1779782400,
    "updated_at": 1779782400,
    "model": "seedance-2.0",
    "status": "queued",
    "billing_status": "frozen"
  }
  ```

  ```json 生成中 theme={null}
  {
    "id": "vidtask_3cb6299b32d24f93a82e8a74b3e06161",
    "object": "video.generation.task",
    "created": 1779782400,
    "created_at": 1779782400,
    "updated_at": 1779782420,
    "model": "seedance-2.0",
    "status": "running",
    "billing_status": "frozen"
  }
  ```

  ```json 成功 theme={null}
  {
    "id": "vidtask_3cb6299b32d24f93a82e8a74b3e06161",
    "object": "video.generation.task",
    "created": 1779782400,
    "created_at": 1779782400,
    "updated_at": 1779782488,
    "model": "seedance-2.0",
    "status": "succeeded",
    "billing_status": "settled",
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 5,
    "framespersecond": 24,
    "generate_audio": true,
    "service_tier": "default",
    "content": {
      "video_url": "https://example.com/generated-video.mp4",
      "video_url_expires_at": "2026-05-27T12:00:00Z"
    },
    "usage": {
      "completion_tokens": 540900,
      "total_tokens": 540900
    }
  }
  ```

  ```json 失败 theme={null}
  {
    "id": "vidtask_3cb6299b32d24f93a82e8a74b3e06161",
    "object": "video.generation.task",
    "created": 1779782400,
    "created_at": 1779782400,
    "updated_at": 1779782488,
    "model": "seedance-2.0",
    "status": "failed",
    "billing_status": "refunded",
    "error": {
      "code": "OutputVideoSensitiveContentDetected",
      "message": "The request failed because the output video may contain sensitive information."
    }
  }
  ```
</CodeGroup>

***

## 错误码

| HTTP 状态码 | `error.type`     | 场景                      |
| -------- | ---------------- | ----------------------- |
| 404      | `task_not_found` | 任务不存在，或任务不属于当前 API Key。 |
| 401      | —                | API Key 缺失或无效。          |

| `status`    | 说明                                        |
| ----------- | ----------------------------------------- |
| `queued`    | 排队中，等待处理。                                 |
| `running`   | 视频正在生成中。                                  |
| `succeeded` | 任务成功，`content.video_url` 可用。              |
| `failed`    | 任务失败，`error` 字段包含错误信息。                    |
| `cancelled` | 任务已取消。                                    |
| `expired`   | 任务超时，已超过 `execution_expires_after` 设定的时间。 |

## 账务状态

| `billing_status` | 说明                |
| ---------------- | ----------------- |
| `frozen`         | 已冻结预估费用，任务尚未最终结算。 |
| `settling`       | 结算处理中。            |
| `settled`        | 已成功结算。            |
| `refunded`       | 任务失败、取消或超时后已退款。   |
| `settle_failed`  | 结算失败，需联系平台处理。     |
| `refund_failed`  | 退款失败，需联系平台处理。     |

## 响应示例

<CodeGroup>
  ```json 排队中 theme={null}
  {
    "id": "vidtask_3cb6299b32d24f93a82e8a74b3e06161",
    "object": "video.generation.task",
    "created": 1779782400,
    "created_at": 1779782400,
    "updated_at": 1779782400,
    "model": "seedance-2.0",
    "status": "queued",
    "billing_status": "frozen"
  }
  ```

  ```json 成功 theme={null}
  {
    "id": "vidtask_3cb6299b32d24f93a82e8a74b3e06161",
    "object": "video.generation.task",
    "created": 1779782400,
    "created_at": 1779782400,
    "updated_at": 1779782488,
    "model": "seedance-2.0",
    "status": "succeeded",
    "billing_status": "settled",
    "resolution": "720p",
    "ratio": "16:9",
    "duration": 5,
    "framespersecond": 24,
    "generate_audio": true,
    "service_tier": "default",
    "content": {
      "video_url": "https://example.com/generated-video.mp4",
      "video_url_expires_at": "2026-05-27T12:00:00Z"
    },
    "usage": {
      "completion_tokens": 540900,
      "total_tokens": 540900
    }
  }
  ```

  ```json 失败 theme={null}
  {
    "id": "vidtask_3cb6299b32d24f93a82e8a74b3e06161",
    "object": "video.generation.task",
    "created": 1779782400,
    "created_at": 1779782400,
    "updated_at": 1779782488,
    "model": "seedance-2.0",
    "status": "failed",
    "billing_status": "refunded",
    "error": {
      "code": "OutputVideoSensitiveContentDetected",
      "message": "The request failed because the output video may contain sensitive information."
    }
  }
  ```
</CodeGroup>


## OpenAPI

````yaml GET /v1/videos/generations/{id}
openapi: 3.1.0
info:
  title: WengaoCloud AI Gateway API
  version: 0.1.0
  description: WengaoCloud AI 聚合平台公开 API 契约草案，覆盖 OpenAI 兼容接口、Anthropic 原生接口和平台扩展接口。
servers:
  - url: https://xxx.wengaocloud.com
    description: 问高云 API 网关根域名。OpenAI SDK 的 base_url 使用 https://xxx.wengaocloud.com/v1。
  - url: https://{tenant}.wengaocloud.com
    description: 控制台展示的租户或 OEM API 网关根域名。
    variables:
      tenant:
        default: xxx
security:
  - bearerAuth: []
tags:
  - name: models
    x-group: 模型
  - name: openai-compatible
    x-group: OpenAI 兼容接口
  - name: anthropic-native
    x-group: Anthropic 原生接口
  - name: images-v3
    x-group: 图片（V3 同步）
  - name: volcengine-images
    x-group: 图片（火山直连）
  - name: images
    x-group: 图片（V1 兼容）
  - name: async-images
    x-group: 图片异步任务
  - name: aliwan-images
    x-group: 图片（百炼万相）
  - name: videos
    x-group: 视频
paths:
  /v1/videos/generations/{id}:
    get:
      tags:
        - videos
      summary: 查询视频生成任务
      description: |
        查询异步视频生成任务的状态、视频结果和用量信息。
        建议轮询间隔不少于 3 秒，生产环境建议 5–10 秒。
        任务成功后从 `content.video_url` 获取生成视频，请及时下载转存。
      operationId: getVideoGenerationTask
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: 创建接口返回的任务 ID，格式通常以 `vidtask_` 开头。
      responses:
        '200':
          description: 视频任务状态与结果。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationTaskResponse'
              examples:
                queued:
                  value:
                    id: vidtask_3cb6299b32d24f93a82e8a74b3e06161
                    object: video.generation.task
                    created: 1779782400
                    created_at: 1779782400
                    updated_at: 1779782400
                    model: seedance-2.0
                    status: queued
                    billing_status: frozen
                succeeded:
                  value:
                    id: vidtask_3cb6299b32d24f93a82e8a74b3e06161
                    object: video.generation.task
                    created: 1779782400
                    created_at: 1779782400
                    updated_at: 1779782488
                    model: seedance-2.0
                    status: succeeded
                    billing_status: settled
                    seed: 123456
                    resolution: 720p
                    ratio: '16:9'
                    duration: 5
                    framespersecond: 24
                    generate_audio: true
                    service_tier: default
                    content:
                      video_url: https://example.com/generated-video.mp4
                      video_url_expires_at: '2026-05-27T12:00:00Z'
                    usage:
                      completion_tokens: 540900
                      total_tokens: 540900
                failed:
                  value:
                    id: vidtask_3cb6299b32d24f93a82e8a74b3e06161
                    object: video.generation.task
                    created: 1779782400
                    created_at: 1779782400
                    updated_at: 1779782488
                    model: seedance-2.0
                    status: failed
                    billing_status: refunded
                    error:
                      code: OutputVideoSensitiveContentDetected
                      message: >-
                        The request failed because the output video may contain
                        sensitive information.
        '401':
          $ref: '#/components/responses/Unauthorized'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  schemas:
    VideoGenerationTaskResponse:
      type: object
      required:
        - id
        - object
        - status
      properties:
        id:
          type: string
          example: vidtask_3cb6299b32d24f93a82e8a74b3e06161
        object:
          type: string
          enum:
            - video.generation.task
        created:
          type: integer
          description: 任务创建时间，Unix 秒。
        created_at:
          type: integer
          description: 任务创建时间，Unix 秒。
        updated_at:
          type: integer
          description: 任务状态更新时间，Unix 秒。
        model:
          type: string
        status:
          type: string
          enum:
            - queued
            - running
            - succeeded
            - failed
            - cancelled
            - expired
          description: |
            任务状态：`queued`（排队中）、`running`（运行中）、`succeeded`（成功）、
            `failed`（失败）、`cancelled`（已取消）、`expired`（已超时）。
        billing_status:
          type: string
          enum:
            - frozen
            - settling
            - settled
            - refunded
            - settle_failed
            - refund_failed
          description: |
            账务状态：`frozen`（已冻结）、`settling`（结算中）、`settled`（已结算）、
            `refunded`（已退款）、`settle_failed`（结算失败）、`refund_failed`（退款失败）。
        content:
          type: object
          description: 视频生成结果，任务成功且存在视频地址时返回。
          properties:
            video_url:
              type: string
              description: 生成视频 URL，请及时下载和转存。
            video_url_expires_at:
              type: string
              description: 视频 URL 过期时间，RFC3339 格式。
        error:
          type: object
          properties:
            code:
              type: string
            message:
              type: string
        usage:
          type: object
          description: 用量信息，任务完成并完成用量统计后返回。Token 视频模型返回 token 字段；Grok Imagine 返回按秒计费字段。
          properties:
            completion_tokens:
              type: integer
            total_tokens:
              type: integer
            billing_unit:
              type: string
              description: 计费单位，例如 `video_second`。
            unit_name:
              type: string
              description: 单位名称，例如 `video_second`。
            requested_units:
              oneOf:
                - type: string
                - type: number
              description: 请求单位数。Grok Imagine 中通常为请求的视频秒数。
            billable_units:
              oneOf:
                - type: string
                - type: number
              description: 实际结算单位数。Grok Imagine 中通常为输出视频秒数。
            billable_input_images:
              oneOf:
                - type: string
                - type: number
              description: 实际计费的输入图张数，存在时返回。
            billable_output_seconds:
              oneOf:
                - type: string
                - type: number
              description: 实际计费的输出视频秒数，存在时返回。
            input_charge_amount:
              oneOf:
                - type: string
                - type: number
              description: 输入图费用，存在时返回。
            output_charge_amount:
              oneOf:
                - type: string
                - type: number
              description: 输出视频费用，存在时返回。
            charge_amount:
              oneOf:
                - type: string
                - type: number
              description: 本次任务总费用，存在时返回。
        seed:
          type: integer
        resolution:
          type: string
        ratio:
          type: string
        duration:
          oneOf:
            - type: integer
            - type: string
        frames:
          type: integer
        framespersecond:
          type: integer
        generate_audio:
          type: boolean
        service_tier:
          type: string
        expires_at:
          type: integer
      additionalProperties: true
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              example: invalid_request_error
            code:
              type: string
              example: model_endpoint_mismatch
            message:
              type: string
              example: 该模型不支持当前 endpoint。
  responses:
    Unauthorized:
      description: API Key 缺失或无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: 资源不存在。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      x-default: sk-your-api-key

````