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

# Kling Image 4.0 文生图

> Kling Image 4.0 文生图 API 根据提示词生成 1–9 张图片或 2–10 张连贯组图，支持 2K、4K 和原生 8K 分辨率。

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

Kling Image 4.0 文生图根据提示词生成高分辨率图片，支持 2K 到原生 8K。每次请求最多生成 9 张独立图片，或生成 2–10 张主体和风格一致的连贯组图，适合分镜、产品套图和分步骤示意图。

如需编辑或组合参考图，请使用 [Kling Image 4.0 图像编辑](https://docs.vidgo.ai/zh/api-manual/image-series/kwaivgi-kling-image-v4-0-edit.md)。如需设计整页网页或电商详情页长图，请使用 [Kling Image 4.0 长图](https://docs.vidgo.ai/zh/api-manual/image-series/kwaivgi-kling-image-v4-0-long-image.md)。

## 模型

* **kwaivgi/kling-image-v4.0/text-to-image** — Kling Image 4.0 文生图，每次 1–9 张图片或 2–10 张组图。

## 功能

* 原生 2K、4K、8K 输出。
* 每次请求最多 9 张独立图片。
* 连贯组图（`enable_sequential`）：2–10 张主体和风格一致的图片，按顺序返回。
* 9 种宽高比，或用 `auto` 由模型选择。

## 必填参数

* `prompt` (string)：图片描述。1–50,000 个字符的文本。

## 可选参数

* `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)：为 `true` 时生成 `n` 张主体和风格一致的连贯组图。默认 `false`。
* `n` (integer)：图片数量。`enable_sequential` 为 `false` 时为 1–9（默认 1），为 `true` 时为 2–10（默认 4）。

## 分辨率

| `resolution` | 尺寸示例 |
| - | - |
| `2K` | `1:1` 下为 2048x2048 |
| `4K` | `16:9` 下为 5440x3072 |
| `8K` | `1:1` 下为 8192x8192 |

输出图片为 PNG 文件。8K 单张可能超过 100 MB，4K 约 25–30 MB，下载需要预留更长时间。

## 示例

* **一张 4K 图片**：`16:9`、`4K` 的时尚大片。
* **多张独立图片**：用 `n: 3` 生成同一产品图的三个版本。
* **连贯组图**：`enable_sequential: true`、`n: 4` 生成四格水彩故事。

## 注意事项

* `n` 取值 1–9（`enable_sequential: true` 时为 2–10），`resolution` 取值 `2K`、`4K`、`8K`，其他值返回 400。使用参考图请用 [Kling Image 4.0 图像编辑](https://docs.vidgo.ai/zh/api-manual/image-series/kwaivgi-kling-image-v4-0-edit.md)。
* `enable_sequential: true` 时由模型决定组图的最终构成，偶尔返回的图片少于 `n` 张。
* `model` 和 `callback_url` 放在请求根级，与 `input` 并列。`input` 接收上文列出的字段，其他字段返回 400。
* 积分取决于 `resolution` 和图片数量（`n`）。组图实际返回的图片少于 `n` 时，任务完成后退还缺少图片的积分。任务失败会全额退还。当前费率见[定价页](https://vidgo.ai/apis/api-pricing)。


## OpenAPI

````yaml zh/api-manual/image-series/kwaivgi-kling-image-v4-0-text-to-image.json POST /api/generate/submit
openapi: 3.0.0
info:
  title: Vidgo API - Kling Image 4.0 文生图
  description: Kling Image 4.0 文生图 API 根据提示词生成 1–9 张图片或 2–10 张连贯组图，支持 2K、4K 和原生 8K 分辨率。
  version: 1.0.0
servers:
  - url: https://api.vidgo.ai
    description: 生产环境服务器
security:
  - BearerAuth: []
paths:
  /api/generate/submit:
    post:
      tags:
        - Kling Image 4.0 Text to Image
      summary: 提交 Kling Image 4.0 文生图 任务
      operationId: submitKlingImage40TextToImageTask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitRequest'
            examples:
              single-4k:
                summary: 一张 4K 图片
                value:
                  model: kwaivgi/kling-image-v4.0/text-to-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
              multiple-images:
                summary: 多张独立图片
                value:
                  model: kwaivgi/kling-image-v4.0/text-to-image
                  input:
                    prompt: >-
                      Minimalist ceramic coffee mug on a stone counter, morning
                      light, product photography
                    size: '1:1'
                    'n': 3
              image-series:
                summary: 连贯组图
                value:
                  model: kwaivgi/kling-image-v4.0/text-to-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: 任务提交结果。任务 ID 标识一项异步任务；生成可能仍在进行中。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
        '400':
          description: 请求参数无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SubmitRequest:
      type: object
      required:
        - model
        - input
      additionalProperties: false
      properties:
        model:
          type: string
          example: kwaivgi/kling-image-v4.0/text-to-image
        callback_url:
          type: string
          format: uri
          description: 可选的 Webhook URL，用于接收完成或失败通知。
          example: https://your-domain.com/callback
        input:
          type: object
          required:
            - prompt
          additionalProperties: false
          properties:
            prompt:
              type: string
              minLength: 1
              maxLength: 50000
              description: |-
                要生成的图片描述。

                至少包含一个非空白字符。
            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；为 true 时为 2–10，默认
                4。
    SubmitResponse:
      type: object
      required:
        - code
        - data
      properties:
        code:
          type: integer
          example: 200
        data:
          type: object
          required:
            - task_id
            - status
            - created_time
          properties:
            task_id:
              type: string
              example: task-example-001
            status:
              type: string
              example: not_started
            created_time:
              type: string
              format: date-time
              example: '2026-11-19T10:30:00'
    ErrorResponse:
      type: object
      required:
        - detail
      properties:
        detail:
          type: string
          description: 错误信息。参见[错误码](/zh/api-manual/error-codes)。
          example: prompt is required
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '使用 `Authorization: Bearer VIDGO_API_KEY`。'

````

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