> ## 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.

# 获取 Seedance 视频任务状态

> 轮询 Seedance 视频任务，获取进度和最终视频 URL

## 任务状态说明

| 状态            | 含义                           |
| ------------- | ---------------------------- |
| `queued`      | 排队等待处理                       |
| `in_progress` | 生成中，`progress` 字段反映百分比进度     |
| `completed`   | 已完成，视频 URL 位于 `metadata.url` |
| `failed`      | 生成失败，查看 `error` 字段了解原因       |

## 轮询建议

Seedance 任务通常在 30 秒至数分钟内完成。
建议每 5–10 秒轮询一次，并结合 `progress` 字段提示用户进度。

## 获取视频

完成后有两种方式获取视频：

* 直接使用 `metadata.url` 中的 CDN 链接（有效期见 `expires_at`）
* 调用 `GET /v1/videos/{task_id}/content` 通过接口代理下载


## OpenAPI

````yaml /openapi/videos.zh.yaml get /v1/videos/{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/videos/{task_id}:
    get:
      tags:
        - Seedance 2.0
      summary: 获取 Seedance 视频任务状态
      description: |
        获取 Seedance 视频任务的状态、进度和结果。
        任务完成后，视频文件 URL 位于 `metadata.url` 字段。
      operationId: getSeedanceVideo
      parameters:
        - name: task_id
          in: path
          description: 视频任务 ID，由创建接口返回的 `id` 字段。
          required: true
          schema:
            type: string
          example: video_abc123
      responses:
        '200':
          description: 成功获取视频任务状态
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SeedanceVideoTask'
              examples:
                queued:
                  summary: 排队中
                  value:
                    id: video_abc123
                    object: video
                    model: doubao-seedance-2-0-fast-260128
                    status: queued
                    progress: 0
                    created_at: 1764347090922
                    seconds: '5'
                completed:
                  summary: 已完成
                  value:
                    id: video_abc123
                    object: video
                    model: doubao-seedance-2-0-fast-260128
                    status: completed
                    progress: 100
                    created_at: 1764347090922
                    completed_at: 1764347170000
                    seconds: '5'
                    size: 1280x720
                    metadata:
                      url: https://example.com/generated-video.mp4
        '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:
    SeedanceVideoTask:
      type: object
      description: Seedance 视频任务对象，兼容 OpenAI / Sora 视频任务格式。
      required:
        - id
        - object
        - model
        - status
        - progress
        - created_at
        - seconds
      properties:
        id:
          type: string
          description: 视频任务 ID。
          examples:
            - video_abc123
        object:
          type: string
          description: 对象类型，固定为 `video`。
          enum:
            - video
          examples:
            - video
        model:
          type: string
          description: 执行任务所用的模型。
          enum:
            - doubao-seedance-2-0-260128
            - doubao-seedance-2-0-fast-260128
          examples:
            - doubao-seedance-2-0-fast-260128
        status:
          type: string
          description: 任务状态。
          enum:
            - queued
            - in_progress
            - completed
            - failed
          examples:
            - queued
        progress:
          type: integer
          description: 任务进度百分比（0–100）。
          minimum: 0
          maximum: 100
          examples:
            - 0
        created_at:
          type: integer
          format: int64
          description: 任务创建时间戳（毫秒）。
          examples:
            - 1764347090922
        seconds:
          type: string
          description: 视频时长，单位秒。
          examples:
            - '5'
        completed_at:
          type: integer
          format: int64
          description: 任务完成时间戳（毫秒），完成后填充。
          examples:
            - 1764347170000
        expires_at:
          type: integer
          format: int64
          description: 任务及视频文件的过期时间戳（毫秒）。
          examples:
            - 1764433570000
        size:
          type: string
          description: 视频尺寸，格式如 `1280x720`。
          examples:
            - 1280x720
        error:
          $ref: '#/components/schemas/SeedanceVideoError'
        metadata:
          type: object
          description: 额外元数据，任务完成后通常包含 `url` 字段。
          additionalProperties: true
          properties:
            url:
              type: string
              format: uri
              description: 视频文件 URL。
              examples:
                - https://example.com/generated-video.mp4
    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
    SeedanceVideoError:
      type: object
      description: Seedance 视频任务错误信息。
      properties:
        message:
          type: string
          description: 错误信息。
          examples:
            - generation failed
        code:
          type: string
          description: 错误码。
          examples:
            - generation_failed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        使用 Bearer Token 认证，格式：`Authorization: Bearer sk-xxxxxx`。
        在 [控制台](https://api.getinfinityblue.com/console) 获取 API Key。

````