Skip to content

图像生成 ​

接口与可灵官网一致;支持文生图、图生图、角色/人脸参考

  • 路径 POST /kling/v1/images/generations
  • 与官网一致:本页所有请求体、字段命名与返回结构与可灵官网保持一致
  • 字段详解:请参考官网权威文档

请求参数

参数类型必填说明
model_namestring否模型名称,默认 kling-v1。可选:kling-image-o1、kling-v1、kling-v1-5、kling-v2、kling-v2-new、kling-v2-1、kling-v3
promptstring是正向文本提示词
negative_promptstring否负向文本提示词(图生图场景不支持)
imagestring否参考图像 URL 或 Base64
image_referencestring否图片参考类型:subject(角色特征)、face(人物长相),仅 kling-v1-5 支持
image_fidelitynumber否图片参考强度 [0, 1]
human_fidelitynumber否面部参考强度 [0, 1]
resolutionstring否清晰度:1k(标清)、2k(高清),默认 1k
nint否生成图片数量 [1, 9],默认 1
aspect_ratiostring否纵横比:16:9、9:16、1:1、4:3、3:4、3:2、2:3、21:9,默认 16:9
watermark_infoobject否是否生成含水印结果
callback_urlstring否回调通知地址
external_task_idstring否自定义任务ID

注意:使用 kling-v1-5 且 image 参数不为空时,image_reference 参数必填。非 kling-v1-5 模型不支持 image_reference。

补充约束:prompt 长度 ≤ 2500;图生图场景(image 非空)不支持 negative_prompt。

模型边界:kling-v3-omni 仅通过 /kling/v1/images/omni-image 放行;kling-v2-5-turbo 等视频模型不能用于 /images/generations。

场景一:文生图 ​

bash
curl --request POST \
  --url https://aiapi.fhddos.com/kling/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model_name": "kling-v1",
    "prompt": "A beautiful sunset over the ocean, vibrant colors, high detail",
    "resolution": "2k",
    "n": 1,
    "aspect_ratio": "16:9"
  }'

场景二:角色特征参考 ​

bash
curl --request POST \
  --url https://aiapi.fhddos.com/kling/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model_name": "kling-v1-5",
    "prompt": "The character holding a magic wand in a fantasy forest",
    "image": "https://example.com/character-reference.jpg",
    "image_reference": "subject",
    "image_fidelity": 0.8,
    "resolution": "2k",
    "aspect_ratio": "3:4"
  }'

场景三:人脸参考 ​

bash
curl --request POST \
  --url https://aiapi.fhddos.com/kling/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model_name": "kling-v1-5",
    "prompt": "A professional headshot portrait, business attire, studio lighting",
    "image": "https://example.com/face-photo.jpg",
    "image_reference": "face",
    "human_fidelity": 0.9,
    "resolution": "2k",
    "aspect_ratio": "1:1"
  }'

场景四:批量生成 ​

bash
curl --request POST \
  --url https://aiapi.fhddos.com/kling/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model_name": "kling-v2",
    "prompt": "Abstract colorful artwork, modern style",
    "n": 4,
    "resolution": "1k",
    "aspect_ratio": "1:1"
  }'

示例响应

json
{
  "code": 0,
  "message": "success",
  "request_id": "req_1735558800_img123",
  "data": {
    "task_id": "task_01JGHP...",
    "task_status": "submitted",
    "created_at": 1735558800000,
    "updated_at": 1735558800000
  }
}

任务成功响应

json
{
  "code": 0,
  "message": "success",
  "data": {
    "task_id": "task_01JGHP...",
    "task_status": "succeed",
    "task_result": {
      "images": [
        {"index": 0, "url": "https://..."},
        {"index": 1, "url": "https://..."}
      ]
    }
  }
}

OpenAPI ​

yaml
openapi: 3.0.3
info:
  title: Fhddos Core API
  version: '1.0'
  description: >-
    Core OpenAI-compatible and model-family endpoints used by the Fhddos user
    docs.
servers:
  - url: https://aiapi.fhddos.com
security:
  - BearerAuth: []
paths:
  /kling/v1/images/generations:
    post:
      tags:
        - Kling
      summary: Kling image generation
      requestBody:
        $ref: '#/components/requestBodies/JsonObject'
      responses:
        '200':
          $ref: '#/components/responses/JsonObject'
components:
  requestBodies:
    JsonObject:
      required: true
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GenericObject'
  responses:
    JsonObject:
      description: OK
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/GenericObject'
  schemas:
    GenericObject:
      type: object
      additionalProperties: true
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: 'Authorization: Bearer <token>'

Fhddos AI 用户文档