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

# 获取视频生成任务状态

> 轮询通用视频生成任务，获取进度和最终视频 URL

## 任务状态说明

| 状态            | 含义                     |
| ------------- | ---------------------- |
| `queued`      | 排队等待处理                 |
| `in_progress` | 生成中                    |
| `completed`   | 已完成，可从 `url` 字段获取视频    |
| `failed`      | 生成失败，查看 `error` 字段了解原因 |

## 轮询建议

任务通常在 30 秒至数分钟内完成，具体取决于模型和时长。
建议每 5–10 秒轮询一次，并设置合理超时时间（如 10 分钟）。


## OpenAPI

````yaml /openapi/videos.zh.yaml get /v1/video/generations/{task_id}
openapi: 3.1.0
info:
  title: InfinityBlue API — 视频（Videos）
  version: 1.0.0
  summary: 统一的 AI 视频生成接口
  description: |
    视频生成类接口，采用**异步任务模型**：提交任务 → 轮询状态 → 获取结果。

    InfinityBlue 提供两套视频接口：

    - **通用视频接口** (`/v1/video/generations`)：支持 Kling、Veo 等多厂商模型，
      参数风格与 OpenAI Images API 接近，适合跨模型场景。
    - **Seedance 2.0 接口** (`/v1/videos`)：专为字节豆包 Seedance 2.0 系列优化，
      提供更丰富的 Seedance 专属参数（`seconds`、`resolution`、`ratio`、
      `generate_audio`、`camera_fixed` 等），以及首尾帧、视频参考等多模态素材支持。

    ## 典型调用流程

    1. `POST /v1/video/generations` 或 `POST /v1/videos` — 提交任务，获取 `task_id`
    2. `GET /v1/video/generations/{task_id}` 或 `GET /v1/videos/{task_id}` —
       轮询状态，直到 `status` 为 `completed` 或 `failed`
    3. 从响应的 `url` / `metadata.url` 字段或 `GET /v1/videos/{task_id}/content`
       下载视频文件

    ## 认证

    所有请求需在请求头中携带 API Key：
    ```
    Authorization: Bearer YOUR_API_KEY
    ```
  contact:
    name: InfinityBlue
    url: https://getinfinityblue.com
servers:
  - url: https://api.getinfinityblue.com
    description: 生产环境
security:
  - bearerAuth: []
tags:
  - name: 视频（Videos）
    description: |
      通用视频生成接口，支持 Kling、Veo 等多厂商模型，
      采用"提交 → 轮询 → 取结果"的异步任务模型。
  - name: Seedance 2.0
    description: |
      字节豆包 Seedance 2.0 专属视频接口，参数更丰富，
      支持首尾帧、视频参考、音频参考等多模态素材。
paths:
  /v1/video/generations/{task_id}:
    get:
      tags:
        - 视频（Videos）
      summary: 获取视频生成任务状态
      description: |
        查询通用视频生成任务的状态和结果。
        建议每 5–10 秒轮询一次，直到 `status` 变为 `completed` 或 `failed`。
      operationId: getVideoGeneration
      parameters:
        - name: task_id
          in: path
          description: 任务 ID，由创建接口返回。
          required: true
          schema:
            type: string
          example: abcd1234efgh
      responses:
        '200':
          description: 成功获取任务状态
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationTaskStatus'
              examples:
                in_progress:
                  summary: 生成中
                  value:
                    task_id: abcd1234efgh
                    status: in_progress
                completed:
                  summary: 已完成
                  value:
                    task_id: abcd1234efgh
                    status: completed
                    url: https://example.com/generated-video.mp4
                    format: mp4
                    metadata:
                      duration: 5
                      fps: 30
                      width: 1280
                      height: 720
                      seed: 20231234
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: API Key 无效或缺失
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: 任务不存在、尚未完成或内容已过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    VideoGenerationTaskStatus:
      type: object
      description: 通用视频生成任务状态响应。
      properties:
        task_id:
          type: string
          description: 任务 ID。
          examples:
            - abcd1234efgh
        status:
          type: string
          description: 任务状态。
          enum:
            - queued
            - in_progress
            - completed
            - failed
          examples:
            - completed
        url:
          type: string
          description: 视频文件 URL，任务 `completed` 时返回。
          examples:
            - https://example.com/generated-video.mp4
        format:
          type: string
          description: 视频格式。
          examples:
            - mp4
        metadata:
          $ref: '#/components/schemas/VideoGenerationMetadata'
        error:
          $ref: '#/components/schemas/VideoGenerationError'
    ErrorResponse:
      type: object
      description: 标准错误响应。
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: 错误信息。
              examples:
                - 无效的时长。支持的范围为 4 到 15 秒。
            type:
              type: string
              description: 错误类型。
              examples:
                - invalid_request_error
            param:
              type:
                - string
                - 'null'
              description: 相关参数。
              examples:
                - seconds
            code:
              type:
                - string
                - 'null'
              description: 错误代码。
              examples:
                - invalid_duration
    VideoGenerationMetadata:
      type: object
      description: 视频生成任务元数据，包含实际生成的视频规格信息。
      properties:
        duration:
          type: number
          description: 实际生成的视频时长（秒）。
          examples:
            - 5
        fps:
          type: integer
          description: 实际帧率（fps）。
          examples:
            - 30
        width:
          type: integer
          description: 实际视频宽度（像素）。
          examples:
            - 1280
        height:
          type: integer
          description: 实际视频高度（像素）。
          examples:
            - 720
        seed:
          type: integer
          description: 实际使用的随机种子。
          examples:
            - 20231234
    VideoGenerationError:
      type: object
      description: 视频任务错误信息。
      properties:
        code:
          type: integer
          description: 错误码。
        message:
          type: string
          description: 错误信息。
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        使用 Bearer Token 认证，格式：`Authorization: Bearer sk-xxxxxx`。
        在 [控制台](https://api.getinfinityblue.com/console) 获取 API Key。

````