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

# 创建视频生成任务

> 提交文生视频或图生视频任务，支持 Kling、Veo 等多厂商模型

## 可用模型

在 `model` 中传入视频生成模型 ID，例如：

| 模型 ID               | 说明                       |
| ------------------- | ------------------------ |
| `kling-v2-5-turbo`  | Kling 最新 Turbo 版，速度与质量平衡 |
| `kling-v2-1-master` | Kling 旗舰 Master 版，最高画质   |
| `veo_3_1`           | Google Veo 3.1，顶级视频质量    |
| `veo_3_1-fast`      | Google Veo 3.1 快速版，成本更低  |

## 调用流程

1. `POST /v1/video/generations` — 提交任务，获取 `task_id`
2. `GET /v1/video/generations/{task_id}` — 轮询，直到 `status=completed`
3. 读取响应中的 `url` 字段下载视频文件

## 图生视频

设置 `image` 字段（URL 或 Base64）即可触发图生视频模式，
模型将把图片中的内容动态化。

## 扩展参数

对部分模型，`metadata` 中可传入 `negative_prompt`、`style`、`quality_level`
等模型特有参数；具体支持的字段因模型而异，请参阅对应模型文档。


## OpenAPI

````yaml /openapi/videos.zh.yaml post /v1/video/generations
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:
    post:
      tags:
        - 视频（Videos）
      summary: 创建视频生成任务
      description: |
        提交视频生成任务，支持文生视频（text-to-video）和图生视频（image-to-video）。
        成功后返回 `task_id`，使用 `GET /v1/video/generations/{task_id}` 轮询进度。
      operationId: createVideoGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/VideoGenerationRequest'
            examples:
              text_to_video_kling:
                summary: 文生视频（Kling）
                value:
                  model: kling-v2-5-turbo
                  prompt: 宇航员在月球上漫步，地球在背景中缓缓升起，电影感镜头，4K 超清
                  duration: 5
                  width: 1280
                  height: 720
              text_to_video_veo:
                summary: 文生视频（Veo）
                value:
                  model: veo_3_1
                  prompt: 未来城市夜景，霓虹灯倒映在雨后的街道上，低角度长镜头，画面稳定
                  duration: 8
                  width: 1920
                  height: 1080
              image_to_video:
                summary: 图生视频
                value:
                  model: kling-v2-1-master
                  prompt: 让图片中的人物缓缓转头，背景保持不变，镜头轻微推进
                  image: https://example.com/portrait.jpg
                  duration: 5
                  width: 1280
                  height: 720
      responses:
        '200':
          description: 成功创建视频生成任务
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoGenerationTask'
              example:
                task_id: abcd1234efgh
                status: queued
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: API Key 无效或缺失
          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:
    VideoGenerationRequest:
      type: object
      description: 通用视频生成请求。
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: |
            模型 ID。支持 Kling、Veo 等多厂商视频模型。
            例如 `kling-v2-5-turbo`、`kling-v2-1-master`、`veo_3_1`、`veo_3_1-fast`。
          examples:
            - kling-v2-5-turbo
        prompt:
          type: string
          description: 文本描述提示词，描述视频内容、场景、镜头语言、风格等。
          examples:
            - 宇航员在月球上漫步，地球在背景中缓缓升起，电影感镜头
        image:
          type: string
          description: |
            参考图片，URL 或 Base64 Data URI。设置后触发图生视频模式，
            模型将把图片内容动态化。
          examples:
            - https://example.com/image.jpg
        duration:
          type: number
          description: 视频时长，单位秒。
          examples:
            - 5
        width:
          type: integer
          description: 视频宽度（像素）。
          examples:
            - 1280
        height:
          type: integer
          description: 视频高度（像素）。
          examples:
            - 720
        fps:
          type: integer
          description: 视频帧率（fps）。
          examples:
            - 30
        seed:
          type: integer
          description: 随机种子。传入相同的种子和参数时，生成结果更接近。
          examples:
            - 20231234
        'n':
          type: integer
          description: 生成视频数量。异步任务建议为 1。
          examples:
            - 1
        response_format:
          type: string
          description: 响应格式，建议使用 `url`。
          examples:
            - url
        user:
          type: string
          description: 终端用户标识，用于业务侧审计和风控，不参与生成。
          examples:
            - user-1234
        metadata:
          type: object
          description: |
            扩展参数，可传入模型特有的参数，如 `negative_prompt`、`style`、
            `quality_level` 等。具体支持的字段因模型而异。
          additionalProperties: true
    VideoGenerationTask:
      type: object
      description: 通用视频生成任务提交响应。
      properties:
        task_id:
          type: string
          description: 任务 ID，用于后续轮询状态。
          examples:
            - abcd1234efgh
        status:
          type: string
          description: 初始任务状态，通常为 `queued`。
          examples:
            - queued
    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
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        使用 Bearer Token 认证，格式：`Authorization: Bearer sk-xxxxxx`。
        在 [控制台](https://api.getinfinityblue.com/console) 获取 API Key。

````