Skip to main content
POST
/
kling
/
v1
/
images
/
generations
Image to Image
curl --request POST \
  --url https://gptproto.com/kling/v1/images/generations \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model_name": "<string>",
  "prompt": "<string>",
  "negative_prompt": "<string>",
  "image": "<string>",
  "image_reference": "<string>",
  "image_fidelity": 123,
  "human_fidelity": 123,
  "resolution": "<string>",
  "n": 123,
  "aspect_ratio": "<string>",
  "callback_url": "<string>"
}'
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}

Overview

This endpoint provides image generation functionality.

Authentication

This endpoint requires authentication using a Bearer token.
Authorization
string
default:"sk-***********"
required
Your API key in the format: YOUR_API_KEY

Request Body

model_name
string
default:"kling-v1"
Model Name
  • Enum values:​kling-v1​, ​kling-v1-5​, ​kling-v2​, ​kling-v2-new​, kling-v2-1
prompt
string
default:"The plane flew over the head"
required
Positive text prompt
  • Cannot exceed 2500 characters
negative_prompt
string
default:""
Negative text prompt
  • Cannot exceed 2500 characters
Note: In the Image-to-Image scenario (when the “image” field is not empty), negative prompts are not supported.a
image
string
Reference Image
  • Support inputting image Base64 encoding or image URL (ensure accessibility)
Please note, if you use the Base64 method, make sure all image data parameters you pass are in Base64 encoding format. When submitting data, do not add any prefixes to the Base64-encoded string, such as data:image/png;base64. The correct parameter format should be the Base64-encoded string itself.Example: Correct Base64 encoded parameter:
iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
Incorrect Base64 encoded parameter (includes the data: prefix):
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==
Please provide only the Base64-encoded string portion so that the system can correctly process and parse your data.
  • Supported image formats include.jpg / .jpeg / .png
  • The image file size cannot exceed 10MB, and the width and height dimensions of the image shall not be less than 300px, and the aspect ratio of the image should be between 1:2.5 ~ 2.5:1
  • the image_reference parameter is not empty, the current parameter is required
image_reference
string
Image reference type
  • Enum values:subject(character feature reference), face(character appearance reference)
  • When using face(character appearance reference), the uploaded image must contain only one face.
  • When using kling-v1-5 and the image parameter is not empty, the current parameter is required
Only kling-v1-5 supports the current parameter
image_fidelity
float
default:"0.5"
Face reference intensity for user-uploaded images during generation
  • Value range:[0,1],The larger the value, the stronger the reference intensity
human_fidelity
float
default:"0.45"
Facial reference intensity, refers to the similarity of the facial features of the person in the reference image
  • Only image_reference parameter is subject is available
  • Value range:[0,1],The larger the value, the stronger the reference intensity
resolution
string
default:"1k"
Image generation resolution
  • Enum values:1k, 2k
    • 1k:1K standard
    • 2k:2K high-res
The support range for different model versions. For more details, please refer to the current document’s “2-0 Capability Map”
n
int
default:"1"
Number of generated images
  • Value range:[1,9]
aspect_ratio
string
default:"16:9"
Aspect ratio of the generated images (width:height)
  • Enum values:16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9
Different model versions support varying ranges. For details, refer to the Capability Map
callback_url
string
default:""
The callback notification address for the result of this task. If configured, the server will actively notify when the task status changes
  • The specific message schema of the notification can be found in “Callback Protocol”

Request Example

curl -X POST "https://gptproto.com/kling/v1/images/generations" \
  -H "Authorization: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "prompt": "There is a happy cat on the beach.",
  "image":"iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDI..."
}'

Response

data.task_id
string
{
  "code": 0, //Error Codes;Specific definitions can be found in Error codes
  "message": "string", //Error information
  "request_id": "string", //Request ID, generated by the system, is used to track requests and troubleshoot problems
  "data":{
  	"task_id": "string", //Task ID, generated by the system
    "task_status": "string", //Task status, Enum values:submitted、processing、succeed、failed
    "created_at": 1722769557708, //Task creation time, Unix timestamp, unit ms
    "updated_at": 1722769557708 //Task update time, Unix timestamp, unit ms
  }
}
{
  "error": {
    "message": "Invalid signature",
    "type": "401"
  }
}