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

# 创建图生视频任务

> 创建一个使用 KL 模型从图片生成视频的任务。

<a id="model-rules" />

### 模型参数详细规则

根据 `model` 的值，各参数的必填状态和有效范围如下：

<Tabs>
  <Tab title="Model KL">
    **名称**：标准模型-多参考图生视频

    **特性**：强制使用多参考图输入。

    | 参数                     | 是否必填 | 说明                       |
    | :--------------------- | :--- | :----------------------- |
    | **prompt**             | 是    | 图生视频提示词。                 |
    | **reference\_images**  | 是    | **必须**提供参考图列表。（最多 7 张图片） |
    | **aspect\_resolution** | 是    | 支持 `720p`、`1080p`。       |
    | **duration**           | 是    | 支持 `5`、`10` 秒。           |
    | **image\_url**         | 否    | 不支持。                     |
  </Tab>
</Tabs>

## 回调通知

视频生成任务处理完成后，服务将向发起请求中提供的 `callback_url` 发送一个 **POST** 请求。

### 结构

<ResponseField name="code" type="integer">
  响应状态码。`0` 表示回调发送成功。
</ResponseField>

<ResponseField name="msg" type="string">
  响应消息，通常为 "ok"。
</ResponseField>

<ResponseField name="task_type" type="string">
  任务类型。枚举值：`image_to_video`。
</ResponseField>

<ResponseField name="data" type="object">
  包含生成结果的数据载体。

  <Expandable title="展开属性">
    <ResponseField name="task_id" type="string">
      视频生成任务的唯一标识符。
    </ResponseField>

    <ResponseField name="status" type="string">
      任务的执行状态。枚举值：`SUCCEEDED`、`FAILED`。
    </ResponseField>

    <ResponseField name="video_url" type="string">
      生成视频的访问/下载链接（当 status 为 SUCCEEDED 时有效）。
    </ResponseField>

    <ResponseField name="thumbnail_url" type="string">
      生成视频的缩略图/封面图链接。
    </ResponseField>

    <ResponseField name="error_message" type="string">
      当任务状态为 FAILED 时的详细错误信息。
    </ResponseField>
  </Expandable>
</ResponseField>

### 回调示例

```json theme={null}
{
    "code": 0,
    "msg": "ok",
    "task_type": "image_to_video",
    "data": {
        "task_id": "i2v-d6b6472bcf724d0399e06d1390cb964e",
        "status": "SUCCEEDED",
        "video_url": "https://xiling-dh.bj.bcebos.com/tmp/image2video/kling/951742d2-bea1-4ccf-acfa-73cb7b073ae8/i2v-82b660e5aea44414a2a7b10c12b6bcbd/6544fe9d-0b2e-423e-9b2f-33303ff48c04.mp4",
        "thumbnail_url": "https://xiling-dh.cdn.bcebos.com/media/image2video/converted/93c9943d-3323-42ee-b7cc-6915517ec4dd_converted.jpg",
        "error_message": ""
    }
}
```


## OpenAPI

````yaml POST /v1/image_to_video
openapi: 3.1.1
info:
  title: Keevx API
  description: Keevx AI API，提供图片生成、图生视频和视频翻译服务。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.keevx.cn/
security:
  - bearerAuth: []
paths:
  /v1/image_to_video:
    post:
      summary: 创建图生视频任务
      description: 创建一个使用 KL 模型从图片生成视频的任务。
      operationId: createImageToVideoTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageToVideoRequest'
      responses:
        '200':
          description: 任务创建成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskCreatedResponse'
        '400':
          description: 请求错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    ImageToVideoRequest:
      type: object
      description: 创建图生视频任务，使用 KL 模型。
      required:
        - model
        - prompt
        - aspect_ratio
        - aspect_resolution
        - duration
      properties:
        model:
          type: string
          description: |-
            模型标识符。
            * `KL`：多参考图模式。
          enum:
            - KL
          example: KL
        prompt:
          type: string
          description: 视频生成提示词，限制 1000 字符。
          example: 一只金毛犬在草地上奔跑，阳光明媚，电影级光影
        reference_images:
          type: array
          description: 参考图片 URL 列表（必填）。每张图片最大 20MB。
          items:
            type: string
            format: uri
          maxItems: 5
          example:
            - https://example.com/ref1.jpg
            - https://example.com/ref2.jpg
        aspect_ratio:
          type: string
          description: 视频宽高比。
          enum:
            - '16:9'
            - '9:16'
          example: '16:9'
        aspect_resolution:
          type: string
          description: 视频分辨率。支持 720p、1080p。
          enum:
            - 720p
            - 1080p
          example: 1080p
        duration:
          type: integer
          description: 视频时长（秒）。支持 5 或 10。
          enum:
            - 5
            - 10
          example: 5
        generate_count:
          type: integer
          description: 生成视频数量（1-4）。
          default: 1
          minimum: 1
          maximum: 4
          example: 1
        callback_url:
          type: string
          format: uri
          description: 任务完成回调通知 URL。
          example: https://your-server.com/callback
    TaskCreatedResponse:
      type: object
      description: 任务创建响应
      required:
        - code
        - msg
        - data
      properties:
        code:
          type: integer
          description: 状态码（0 表示成功）
          example: 0
        msg:
          type: string
          description: 响应消息
          example: ok
        data:
          type: object
          description: 包含生成的任务 ID 的数据
          required:
            - task_ids
          properties:
            task_ids:
              type: array
              description: 生成的任务 ID 列表，用于查询状态
              items:
                type: string
                description: 唯一任务 ID
                example: i2v-d6b6472bcf724d0399e06d1390cb964e
              example:
                - i2v-d6b6472bcf724d0399e06d1390cb964e
                - i2v-fc654817587e435e937f1e1b80366c00
    Error:
      type: object
      required:
        - code
        - msg
      properties:
        code:
          type: integer
          format: int32
          example: 100001
        msg:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````