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

# Kling Image 4.0

> Kling Image 4.0 API 可根据提示词生成图像，也可以编辑最多 10 张参考图。支持用元素保持主体一致、生成画面连贯的组图，以及 2K、4K 或 8K 输出。

> [!TIP]
>
> 1. 提交后会返回 `task_id`。如果提供了 `callback_url`，当任务状态变为 `finished` 或 `failed` 时，系统会向 `callback_url` 发送 POST 请求。
> 2. 无论是否提供 `callback_url`，都可以通过统一的[查询任务状态](https://docs.poyo.ai/zh/api-manual/task-management/status.md)接口获取结果。

使用 `kling-4.0-image` 根据提示词制作照片、海报、产品图和分镜，也可以用同一个 model ID 传入参考图进行编辑与合成。Kling Image 4.0 是快手 Kling 4.0 系列的图像模型，最高可输出 8K。

## 模型

* **kling-4.0-image** — 不传 `image_urls` 时为文生图；传入 1 到 10 张参考图的 `image_urls` 时为图生图

## 功能

* 根据最多 50,000 个字符的提示词生成图像。
* 支持图生图编辑和多参考图合成，最多 10 张参考图，在提示词中用 `@Image1`、`@Image2` 等依次指代。
* 元素：最多 7 个人物或物体，每个用 2 到 4 个角度的图片描述，在提示词中用 `@Element1`、`@Element2` 等指代，用于保持主体一致。
* 组图：一次请求生成 2 到 10 张主体与风格一致、画面连贯的图片，按顺序返回。
* 每次请求最多生成 9 张相互独立的图片。
* 支持 `2K`、`4K` 或 `8K` 输出，提供 8 种宽高比，也可以用 `auto` 由模型选择。
* 输出 PNG。

## 输入模式

* **文生图** — 不传 `image_urls`。在 `prompt` 中描述整幅画面。
* **图生图** — 在 `image_urls` 中传入 1 到 10 个 URL。第一个 URL 是 `@Image1`，第二个是 `@Image2`，依此类推。该模式下还可以在 `kling_elements` 中传入最多 7 个元素，第一个元素是 `@Element1`。在提示词中用这些标记说明要保留、修改或合成的内容。`image_urls` 与 `kling_elements` 合计最多 10 项。

## 必填参数

* `prompt` (string)：描述图像或所需编辑的提示词，1–50,000 个字符，必须包含非空白文本。图生图时用 `@Image1`、`@Image2` … 指代参考图，用 `@Element1`、`@Element2` … 指代元素。

## 可选参数

* `image_urls` (array of strings)：1 到 10 个可公开访问的 HTTP(S) 参考图 URL。传入后进入图生图模式。每张图片不超过 30 MB，宽和高至少 300 像素，宽高比（宽 / 高）在 0.4 到 2.5 之间。
* `kling_elements` (array of objects)：图生图模式下的元素，与 `image_urls` 一起使用，最多 7 个。每个元素为 `{"element_input_urls": [...]}`，包含同一人物或物体的 2 到 4 张图片 URL：第一张为正面图，其后为 1 到 3 张其他角度的图片。`image_urls` 张数加元素个数最多 10。
* `size` (string)：`auto`、`16:9`、`9:16`、`1:1`、`4:3`、`3:4`、`3:2`、`2:3` 或 `21:9`。默认为 `auto`，根据提示词和参考图选择宽高比。
* `resolution` (string)：`2K`、`4K` 或 `8K`。默认为 `2K`。参见[分辨率](#分辨率)。
* `enable_sequential` (boolean)：默认为 `false`，生成 `n` 张相互独立的图片。为 `true` 时生成 `n` 张画面连贯的组图，按顺序返回。
* `n` (integer)：图片数量。`enable_sequential` 为 `false` 时为 1–9，默认 1；`enable_sequential` 为 `true` 时为 2–10，默认 4。

## 分辨率

| `resolution` | 输出示例 | PNG 文件大小（参考） |
| - | - | - |
| `2K` | `1:1` 时为 2048×2048 | 约 7.5 MB |
| `4K` | `16:9` 时为 5440×3072 | 约 27 MB |
| `8K` | `1:1` 时为 8192×8192 | 约 100 MB |

## 输出

* 图片以 PNG 格式在 `files` 中返回。组图按顺序返回。

## 示例

### 文生图

一张 4K、16:9 的时尚大片：

```json theme={"dark"}
{
  "model": "kling-4.0-image",
  "input": {
    "prompt": "High fashion model wearing a dress made of living moss, standing in an abandoned greenhouse, shafts of light, editorial photography",
    "size": "16:9",
    "resolution": "4K"
  }
}
```

### 带元素的图生图

把用三个角度描述的人物放进参考图中的房间：

```json theme={"dark"}
{
  "model": "kling-4.0-image",
  "input": {
    "prompt": "Place @Element1 sitting on the sofa in @Image1, reading a book in warm evening light. Keep the room layout of @Image1 unchanged.",
    "image_urls": ["https://example.com/living-room.png"],
    "kling_elements": [
      {
        "element_input_urls": [
          "https://example.com/character-front.png",
          "https://example.com/character-side.png",
          "https://example.com/character-back.png"
        ]
      }
    ],
    "resolution": "2K"
  }
}
```

### 组图

讲述同一个故事的四张连贯画面：

```json theme={"dark"}
{
  "model": "kling-4.0-image",
  "input": {
    "prompt": "A four-panel story of a paper boat drifting from a rainy city gutter to a calm sunny lake, same boat in every panel, watercolor style",
    "size": "3:2",
    "enable_sequential": true,
    "n": 4
  }
}
```

## 注意事项

* 即使只有一张图，`image_urls` 也必须是数组。
* 使用 `kling_elements` 时，需同时在 `image_urls` 中传入至少一张图片。
* 参考图和元素按在 `image_urls`、`kling_elements` 中的顺序编号。为获得更好的效果，请在提示词中写明每一项的作用。
* 从提交到 `finished` 的常见耗时：单张 2K 约 45 秒，单张 4K 1 分钟出头，单张 8K 约 2.5 分钟。图生图约 1 到 2.5 分钟，3 张 2K 组图约 3.5 分钟，9 张 8K 图片约 10 分钟，10 张 8K 组图约 30 分钟。请求较大时，请使用 `callback_url` 或轮询[查询任务状态](https://docs.poyo.ai/zh/api-manual/task-management/status.md)直到任务完成。
* 如需设计完整的网页或电商详情页长图，请使用 [Kling Image 4.0 Long Image](https://docs.poyo.ai/zh/api-manual/image-series/kling-4-0-long-image.md)。


## OpenAPI

````yaml zh/api-manual/image-series/kling-4-0-image.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: PoYo AI - Kling Image 4.0 API
  description: >-
    Kling Image 4.0 API 可根据提示词生成图像，也可以编辑最多 10 张参考图。支持用元素保持主体一致、生成画面连贯的组图，以及
    2K、4K 或 8K 输出。
  version: 1.0.0
servers:
  - url: https://api.poyo.ai
    description: 生产环境
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - Kling Image 4.0
      summary: 提交 Kling Image 4.0 任务
      description: Kling Image 4.0 文生图与图生图，支持最多 10 张参考图、元素和组图。
      operationId: submitKlingImage40Task
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              text-to-image:
                summary: 文生图
                value:
                  model: kling-4.0-image
                  input:
                    prompt: >-
                      High fashion model wearing a dress made of living moss,
                      standing in an abandoned greenhouse, shafts of light,
                      editorial photography
                    size: '16:9'
                    resolution: 4K
              image-to-image-with-elements:
                summary: 带元素的图生图
                value:
                  model: kling-4.0-image
                  input:
                    prompt: >-
                      Place @Element1 sitting on the sofa in @Image1, reading a
                      book in warm evening light. Keep the room layout of
                      @Image1 unchanged.
                    image_urls:
                      - https://example.com/living-room.png
                    kling_elements:
                      - element_input_urls:
                          - https://example.com/character-front.png
                          - https://example.com/character-side.png
                          - https://example.com/character-back.png
                    resolution: 2K
              image-series:
                summary: 组图
                value:
                  model: kling-4.0-image
                  input:
                    prompt: >-
                      A four-panel story of a paper boat drifting from a rainy
                      city gutter to a calm sunny lake, same boat in every
                      panel, watercolor style
                    size: '3:2'
                    enable_sequential: true
                    'n': 4
      responses:
        '200':
          description: 任务提交成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: 请求参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权：API Key 无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: false
      properties:
        model:
          type: string
          enum:
            - kling-4.0-image
          description: Kling Image 4.0 模型标识。不传 image_urls 为文生图；传入 1–10 张 image_urls 为图生图。
        callback_url:
          type: string
          format: uri
          description: 可选的 Webhook URL，用于任务完成或失败时的通知。
        input:
          type: object
          additionalProperties: false
          required:
            - prompt
          description: 根据提示词生成图像。传入 image_urls 时编辑或合成参考图。
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 50000
              description: >-
                描述图像或所需编辑的提示词，必须包含非空白文本。图生图时用 @Image1、@Image2 等指代参考图，用
                @Element1、@Element2 等指代元素。
            image_urls:
              type: array
              minItems: 1
              maxItems: 10
              items:
                type: string
                format: uri
              description: >-
                可选，1–10 个参考图 URL。传入后进入图生图模式。即使只有一张图也必须是数组。图片按在数组中的顺序编号：第一个 URL 为
                @Image1，第二个为 @Image2，依此类推。每个 URL 必须是可公开访问的 HTTP 或 HTTPS 地址，图片不超过
                30 MB，宽和高至少 300 像素，宽高比（宽 / 高）在 0.4 到 2.5 之间。image_urls 张数加
                kling_elements 个数最多 10。
              example:
                - https://example.com/living-room.png
            kling_elements:
              type: array
              minItems: 1
              maxItems: 7
              items:
                type: object
                additionalProperties: false
                required:
                  - element_input_urls
                description: 一个元素：一个人物或物体。
                properties:
                  element_input_urls:
                    type: array
                    minItems: 2
                    maxItems: 4
                    items:
                      type: string
                      format: uri
                    description: >-
                      该元素的 2–4 张可公开访问的 HTTP 或 HTTPS 图片：第一张为正面图，其后为 1–3
                      张其他角度的图片。每张图片的尺寸要求与 image_urls 相同。
              description: >-
                可选，用于图生图模式的元素（与 image_urls 一起传），最多 7
                个。每个元素是一个人物或物体的多角度图片，在提示词中按位置用 @Element1、@Element2
                等指代。image_urls 张数加元素个数最多 10。
            size:
              type: string
              enum:
                - auto
                - '16:9'
                - '9:16'
                - '1:1'
                - '4:3'
                - '3:4'
                - '3:2'
                - '2:3'
                - '21:9'
              default: auto
              description: 输出图像的宽高比。auto 会根据提示词和参考图选择宽高比。
            resolution:
              type: string
              enum:
                - 2K
                - 4K
                - 8K
              default: 2K
              description: >-
                输出分辨率。例如 2K 在 1:1 时为 2048x2048，4K 在 16:9 时为 5440x3072，8K 在 1:1
                时为 8192x8192。
            enable_sequential:
              type: boolean
              default: false
              description: 为 true 时生成画面连贯的组图：n 张主体与风格一致的相关图片，按顺序返回。为 false 时生成 n 张相互独立的图片。
            'n':
              type: integer
              minimum: 1
              maximum: 10
              description: >-
                图片数量。enable_sequential 为 false 时为 1–9，默认 1；enable_sequential 为
                true 时为 2–10，默认 4。
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
          description: >-
            业务状态码。`200` 表示成功，其他值都表示请求失败。请务必检查这个字段：部分参数校验错误会以 HTTP 200 返回，响应体里的
            `code` 为 `400`。


            - `200`：成功

            - `400`：请求参数无效

            - `401`：API Key 缺失或无效

            - `402`：积分不足

            - `403`：没有权限

            - `404`：资源不存在

            - `408`：请求超时

            - `429`：请求频率超限

            - `500`：服务器内部错误

            - `502`：上游服务错误

            - `503`：服务暂不可用


            详见[错误码](/zh/api-manual/error-codes)。
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-unified-1794470400-abcd1234
              description: 任务唯一标识，用于查询任务状态
            status:
              type: string
              enum:
                - not_started
                - running
                - finished
                - failed
              example: not_started
              description: >-
                任务状态。提交后立即返回时始终为
                `not_started`。后续状态请通过[查询任务状态](/zh/api-manual/task-management/status)接口或
                `callback_url` 获取。


                - `not_started`：排队中，等待处理

                - `running`：生成中

                - `finished`：已完成，结果在 `files` 或 `output` 中

                - `failed`：失败，详情见 `error_message`
            created_time:
              type: string
              format: date-time
              example: '2026-11-12T10:30:00'
              description: 任务创建时间，ISO 8601 格式
    ErrorResponse:
      type: object
      required:
        - code
        - error
      properties:
        code:
          type: integer
          example: 400
          enum:
            - 200
            - 400
            - 401
            - 402
            - 403
            - 404
            - 408
            - 429
            - 500
            - 502
            - 503
          description: >-
            业务状态码。`200` 表示成功，其他值都表示请求失败。请务必检查这个字段：部分参数校验错误会以 HTTP 200 返回，响应体里的
            `code` 为 `400`。


            - `200`：成功

            - `400`：请求参数无效

            - `401`：API Key 缺失或无效

            - `402`：积分不足

            - `403`：没有权限

            - `404`：资源不存在

            - `408`：请求超时

            - `429`：请求频率超限

            - `500`：服务器内部错误

            - `502`：上游服务错误

            - `503`：服务暂不可用


            详见[错误码](/zh/api-manual/error-codes)。
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              example: Invalid request parameters
            type:
              type: string
              example: invalid_request_error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >-
        所有 API 接口都需要 Bearer Token 认证。


        创建 API Key：登录 PoYo，进入 **仪表盘 → API
        密钥**（[poyo.ai/zh/dashboard/api-key](https://poyo.ai/zh/dashboard/api-key)），点击创建
        Key。


        在请求头中添加：


        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````

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