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

# 查询视频 · Ark / Seedance

> 查询任务状态、判断成功或失败，并获取视频下载地址。

## 查询与状态判断

将 `<TASK_ID>` 替换为返回的 `id`，每 10 到 15 秒查询一次：

```bash theme={"system"}
curl "https://api.aiohub.org/v1/contents/generations/tasks/<TASK_ID>" \
  -H "Authorization: Bearer <AIOHUB_API_KEY>"
```

| `status` | 处理 |
| - | - |
| `queued` / `running` | 继续查询 |
| `succeeded` | 下载视频 |
| `failed` / `cancelled` / `expired` | 停止查询，读取 `error.message`（如有） |

生成可能需要数分钟；查询成功返回 HTTP 200 时，也要检查任务状态。

## 读取成功结果

成功响应的关键字段如下，下载地址以实际响应为准：

```json theme={"system"}
{
  "id": "task_example",
  "status": "succeeded",
  "content": {
    "video_url": "https://api.aiohub.org/v1/videos/task_example/content"
  }
}
```

任务成功后，按 [下载视频](/cn/api/video-content) 保存文件。

## 失败与重试

查询断线后使用原 `id` 继续查询。任务记录保留 7 天；找不到任务时，请确认任务标识和 API 令牌所属账号。`failed`、`cancelled`、`expired` 都应停止轮询。

收到 429 或临时不可用错误时，等待后重试查询，不要重新创建任务。查询不到任务时，确认任务标识和 API 令牌所属账号。


## OpenAPI

````yaml openapi/relay.json GET /v1/contents/generations/tasks/{task_id}
openapi: 3.0.1
info:
  title: AIOHub API
  description: AIOHub 公开 API
  version: 1.0.0
servers:
  - url: https://api.aiohub.org
security:
  - BearerAuth: []
tags:
  - name: 获取模型列表
  - name: OpenAI Chat
  - name: OpenAI Responses
  - name: 图片生成
  - name: OpenAI 图像
  - name: 视频生成
  - name: Claude Messages
  - name: Gemini API
  - name: OpenAI Embeddings
  - name: 文本补全
  - name: OpenAI 音频
  - name: Realtime API
paths:
  /v1/contents/generations/tasks/{task_id}:
    get:
      tags:
        - 视频生成
      summary: 查询视频任务
      description: >
        返回任务的当前状态。建议每 10 到 15 秒轮询一次；状态为 `succeeded` 时 `content.video_url`
        可下载，成功后 72 小时内有效。任务记录保留 7 天。
      operationId: getSeedanceVideoTask
      parameters:
        - name: task_id
          in: path
          required: true
          example: task_ADQ5XK6AKWg36WePoJ3sZRyDvWl1ogGZ
          schema:
            type: string
          description: 创建任务时返回的 `id`
      responses:
        '200':
          description: 任务对象
          headers: {}
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceTask'
              example:
                id: task_ADQ5XK6AKWg36WePoJ3sZRyDvWl1ogGZ
                model: doubao-seedance-2-5-260628
                status: succeeded
                error: null
                content:
                  video_url: >-
                    https://api.aiohub.org/v1/videos/task_ADQ5XK6AKWg36WePoJ3sZRyDvWl1ogGZ/content
                usage:
                  completion_tokens: 87300
                  total_tokens: 87300
                output_format: mp4
                framespersecond: 24
                resolution: 720p
                ratio: '16:9'
                duration: 4
                generate_audio: true
                priority: 0
                service_tier: default
                execution_expires_after: 172800
                created_at: 1791275108
                updated_at: 1791275315
        '404':
          description: 任务不存在，或属于其他 API 令牌。`code` 为 `task_not_exist`。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceTaskError'
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    SeedanceTask:
      type: object
      description: 视频任务对象。
      properties:
        id:
          type: string
          description: 任务 ID
          example: task_ADQ5XK6AKWg36WePoJ3sZRyDvWl1ogGZ
        model:
          type: string
          example: doubao-seedance-2-5-260628
        status:
          type: string
          enum:
            - queued
            - running
            - succeeded
            - failed
            - cancelled
            - expired
          description: 任务状态
        error:
          nullable: true
          allOf:
            - $ref: '#/components/schemas/SeedanceTaskError'
          description: 任务未成功时的错误，成功时为 `null`。
        content:
          type: object
          nullable: true
          description: 状态为 `succeeded` 时的产物地址，下载时携带同一个 API 令牌。
          properties:
            video_url:
              type: string
              example: >-
                https://api.aiohub.org/v1/videos/task_ADQ5XK6AKWg36WePoJ3sZRyDvWl1ogGZ/content
            last_frame_url:
              type: string
              description: '仅在创建任务时设置了 `return_last_frame: true` 才返回。'
        usage:
          type: object
          properties:
            completion_tokens:
              type: integer
              description: 已交付视频的计费 token 数，计算方式见 [视频模型与计费](/cn/api/video-models#计费)。
            total_tokens:
              type: integer
        output_format:
          type: string
          example: mp4
        framespersecond:
          type: integer
          example: 24
        resolution:
          type: string
          description: 运行中为请求值，成功后为实际交付值。
        ratio:
          type: string
          description: 运行中为请求值，成功后为实际交付值。
        duration:
          type: integer
          description: 运行中为请求值，成功后为实际交付值。
        generate_audio:
          type: boolean
        priority:
          type: integer
        service_tier:
          type: string
          example: default
        execution_expires_after:
          type: integer
          example: 172800
        safety_identifier:
          type: string
        created_at:
          type: integer
          description: 创建时间（Unix 秒）
        updated_at:
          type: integer
          description: 最近更新时间（Unix 秒）
    SeedanceTaskError:
      type: object
      description: 视频任务接口的错误响应。
      properties:
        code:
          type: string
          description: 错误码
          example: invalid_duration
        message:
          type: string
          description: 错误信息
          example: duration must be between 4 and 30 seconds for this model
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key (sk-xxx)

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.