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

# Kling 图像生成 kling-v2-new

> 通过 `/kling/v1/images/generations` 提交 Kling 原生异步图像生成或图生图任务。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/kling/kling-v2-new-image-generations.json POST /kling/v1/images/generations
openapi: 3.0.1
info:
  title: Kling 图像生成任务 - 提交任务
  version: 1.0.0
  description: 通过 `/kling/v1/images/generations` 提交 Kling 原生异步图像生成或图生图任务。
servers:
  - url: https://api.powertokens.ai
    description: ''
security: []
tags:
  - name: Kling
    description: Kling 原生异步任务端点
paths:
  /kling/v1/images/generations:
    post:
      tags:
        - Kling
      summary: Kling 图像生成任务
      description: 通过 `/kling/v1/images/generations` 提交 Kling 原生异步图像生成或图生图任务。
      operationId: createKlingImageGeneration
      parameters:
        - name: Content-Type
          in: header
          required: true
          schema:
            type: string
            default: application/json
          description: 数据交换格式
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KlingRequest'
            examples:
              request:
                summary: 请求示例
                value:
                  model_name: kling-v2-new
                  prompt: 生成皮克斯风格的小狗
                  negative_prompt: ''
                  image: >-
                    https://p1-kling.klingai.com/kcdn/cdn-kcdn112452/kling-qa-test/dog.png
                  'n': 2
                  external_task_id: ''
                  callback_url: ''
      responses:
        '200':
          description: 任务已受理。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubmitResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    KlingRequest:
      type: object
      required:
        - model_name
        - prompt
        - image
      properties:
        model_name:
          type: string
          description: 模型名称
          enum:
            - kling-v2-new
        prompt:
          type: string
          description: |-
            正向文本提示词
            不能超过 2500 个字符
          maxLength: 2500
        negative_prompt:
          type: string
          description: |-
            负向文本提示词
            不能超过 2500 个字符
            注：图生图（即 image 字段不为空时）场景下，不支持负向提示词
          maxLength: 2500
        image:
          type: string
          description: >-
            参考图像


            - 支持传入图片 Base64 编码或图片 URL（确保可访问）


            Base64 编码说明：

            请注意，若您使用base64的方式，请确保您传递的所有图像数据参数均采用Base64编码格式。使用 Base64
            时，请不要添加任何前缀如 data:image/png;base64,，只需提供 Base64 编码字符串本身。


            正确示例：

            `iVBORw0KGgoAAAANSUhEUgAAAAUA...`


            错误示例:

            `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA...`


            - 图片格式支持 .jpg / .jpeg / .png

            - 图片文件大小不能超过 10MB，图片宽高尺寸不小于 300px，图片宽高比介于 1:2.5 ~ 2.5:1 之间

            - image_reference 参数不为空时，当前参数必填
        image_reference:
          type: string
          enum:
            - subject
            - face
          description: |-
            图片参考类型。

            - subject（角色特征参考）, face（人物长相参考）
            - 使用 face（人物长相参考）时，上传图片需仅含 1 张人脸
        element_list:
          type: array
          items:
            type: object
            required:
              - element_id
            properties:
              element_id:
                type: integer
                format: int64
                description: 主体库中的主体 ID。
          description: |-
            主体参考列表，基于主体库中的主体 ID 配置。
            用 key:value 承载，格式如上：
            `"element_list":[{ "element_id": long },{ "element_id": long }]`
            参考主体数量与参考图片数量有关，参考主体数量和参考图片数量之和不得超过 10
          maxItems: 10
        resolution:
          type: string
          enum:
            - 1k
          default: 1k
          description: 生成图片的清晰度。
        'n':
          type: integer
          minimum: 1
          maximum: 9
          default: 1
          description: 生成图片数量。
        aspect_ratio:
          type: string
          description: 生成图片的画面纵横比（宽:高）
          default: '16:9'
          enum:
            - '1:1'
            - '16:9'
            - '4:3'
            - '3:2'
            - '2:3'
            - '3:4'
            - '9:16'
            - '21:9'
        watermark_info:
          type: object
          description: |-
            是否同时生成含水印的结果。
            - 通过enabled参数定义，具体格式如下：

            ```json
             "watermark_info": { "enabled": boolean }
            ```

            - true 为生成，false 为不生成
            - 暂不支持自定义水印
          properties:
            enabled:
              type: boolean
              description: true 表示生成含水印结果，false 表示不生成。
        callback_url:
          type: string
          description: 本次任务结果回调通知地址，如果配置，服务端会在任务状态发生变更时主动通知。
        external_task_id:
          type: string
          description: |-
            自定义任务ID。
            - 传入不会覆盖系统生成的任务ID，但支持通过该ID进行任务查询。
            - 请注意，单用户下需要保证唯一性。
    SubmitResponse:
      type: object
      properties:
        code:
          type: integer
          description: 错误码；具体定义见错误码
          example: 0
        message:
          type: string
          description: 错误信息
          example: string
        request_id:
          type: string
          description: 请求ID，系统生成，用于跟踪请求、排查问题
          example: string
        data:
          type: object
          properties:
            task_id:
              type: string
              description: 任务ID，系统生成
              example: string
            task_info:
              type: object
              description: 任务创建时的参数信息
              properties:
                external_task_id:
                  type: string
                  description: 客户自定义任务ID
                  example: string
            task_status:
              type: string
              description: 任务状态，枚举值：submitted（已提交）、processing（处理中）、succeed（成功）、failed（失败）
              enum:
                - submitted
                - processing
                - succeed
                - failed
              example: submitted
            created_at:
              type: integer
              format: int64
              description: 任务创建时间，Unix时间戳、单位ms
              example: 1722769557708
            updated_at:
              type: integer
              format: int64
              description: 任务更新时间，Unix时间戳、单位ms
              example: 1722769557708
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````