tencent cloud

LLM Service TokenHub

Kling Image Generation API Guide

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-11-25 14:35:51
Diterjemahkan oleh AI

Overview

Kling is a visual generation model series launched by Kuaishou. This document describes how to call the Kling image generation models through TokenHub, including kling-image-v3, kling-image-o1, kling-image-v3-omni, kling-image-v4, and kling-image-v4-long.

Prerequisites

You have registered a Tencent Cloud account and activated the TokenHub service.
You have obtained an API Key from the TokenHub console.
Enable postpaid billing for the corresponding model in Console - Online Inference - Vision Models.
Note:
In all examples below, YOUR_API_KEY must be replaced with your own API Key. The authentication method is the request header Authorization: Bearer YOUR_API_KEY.

Call Process

Image generation is a time-consuming task, so the API uses an asynchronous call mode, which is divided into two steps:
1. Submit a task: Call the image generation API, which returns a task ID upon success (for v3 / o1 / v3-omni, the field is data.task_id, and for v4 / v4-long, it is data.id).
2. Poll for results: Call the query task API with the task ID (recommended every 3 to 5 seconds) until the task succeeds. For v3 / o1 / v3-omni, success is indicated by task_status = succeed, and image URLs are obtained from task_result.images. For v4 / v4-long, success is indicated by status = succeeded, and image URLs are obtained from outputs[].
Note:
The submission API paths and request structures of Kling-Image-v4 / v4-long differ from those of the v3 series (the v4 series organizes parameters using contents + settings), but they share the same query API.

Model List

Model Name
model Parameter Value
Supported Capability
Prompt Limit
Resolution
Kling-Image-v3
kling-image-v3
Text-to-image generation/image-to-image generation (single-image reference)
2500 characters
1K / 2K
Kling-Image-o1
kling-image-o1
Text-to-image generation/image-to-image generation (multi-image reference)
2500 characters
1K / 2K
Kling-Image-v3-omni
kling-image-v3-omni
Text-to-image generation/image-to-image generation (multi-image reference)/series image generation
2500 characters
1K / 2K / 4K
Kling-Image-v4
kling-image-v4
Text-to-image generation/image-to-image generation (multi-image reference)/subject reference/series image generation
50,000 characters for English / 21,000 characters for non-English
2K / 4K / 8K
Kling-Image-v4-long
kling-image-v4-long
Long image generation: e-commerce detail pages/web design
166,000 characters for English / 71,000 characters for non-English
1K / 2K
Note:
Kling-Image-v3 / o1 / v3-omni all support 8 aspect ratios: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, and 21:9. kling-image-o1 and kling-image-v3-omni additionally support auto, which intelligently determines the aspect ratio based on the input content.
kling-image-v4 supports the 8 aspect ratios mentioned above as well as auto, with auto as the default.
kling-image-v4-long outputs a complete long image without setting an aspect ratio. Select the e-commerce detail page or web design scenario through settings.skill.

Image Generation (Kling-Image-v3)

1. API Description

The Kling-Image-v3 image generation API supports text-to-image and image-to-image (single-image reference) generation: if image is provided, image-to-image generation is performed. If not, text-to-image generation is performed based on text prompts. Both positive and negative prompts are supported.
API: POST https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling-image/generation

2. Input Parameters

Parameter Name
Required
Type
Description
model
Yes
string
Model ID. Valid values: kling-image-v3
prompt
Yes
string
Positive text prompt, with a maximum length of 2500 characters. If image is not passed, text-to-image generation is performed based on this text.
negative_prompt
No
string
Negative text prompt, with a maximum length of 2500 characters. It is supported only for text-to-image generation; negative prompts are not supported in image-to-image generation scenarios where image is not empty.
image
No
string
Reference image (single image). If a reference image is provided, image-to-image generation is used.
Supports image URL (ensure it is accessible) or Base64 encoding. For Base64, you do not need to add the data:image/png;base64, prefix; directly pass the Base64 string itself.
element_list
No
array
Subject reference list, configured based on subject IDs in the subject library. Format: "element_list": [{"element_id": subject ID}].
The total number of reference subjects and reference images must not exceed 10.
aspect_ratio
No
string
Aspect ratio of the generated image (width:height).
Valid values: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9. Default value: 16:9.
resolution
No
string
Resolution of the generated image.
Valid values: 1k (1K standard definition), 2k (2K high definition). Default value: 1k.
n
No
integer
Number of generated images. Value range: [1, 9]. Default value: 1.
watermark_info
No
object
Whether to simultaneously generate a watermarked result. Format: "watermark_info": {"enabled": boolean}.
true indicates that a watermarked result is generated, and false indicates that it is not. Custom watermarks are not supported.

3. Request Example

# Text-to-image / Image-to-image
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling-image/generation' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "kling-image-v3",
"prompt": "a small orange kitten sitting on a sunny windowsill",
"image": "https://example.com/input.jpg",
"aspect_ratio": "1:1",
"resolution": "2k",
"n": 3
}'
For text-to-image generation, simply omit the image field. In this case, you can also pass negative_prompt (negative prompts are not supported for image-to-image generation).

4. Output Parameters

Parameter Name
Type
Description
code
string
Error code.
message
string
Error message.
request_id
string
Request ID generated by the system, used for tracking requests and troubleshooting.
data.task_id
string
Task ID.
data.task_status
string
Task status, enumerated values: submitted (submitted), processing (processing), succeed (succeeded), failed (failed).
data.created_at
integer
Task creation time, Unix timestamp in ms.
data.updated_at
integer
Task update time, Unix timestamp in ms.

5. Response Example

{
"code": 0,
"message": "SUCCEED",
"request_id": "58b5fba6-b418-4cfa-9ecb-fa5e0406bc6d",
"data": {
"task_id": "251435731-WandImage-d59f0494e75a47d791135b1294892545",
"task_status": "submitted",
"created_at": 1790237643425,
"updated_at": 1790237643425,
"task_info": {}
}
}

Omni Image Generation (Kling-Image-o1 / Kling-Image-v3-omni)

1. API Description

The image generation APIs for Kling-Image-o1 and Kling-Image-v3-omni support text-to-image, multi-image reference image-to-image, and series image generation: if image_list (up to 10 images) is provided, multi-image reference is used, and specific reference images can be referenced in prompts via <<<image_N>>>. kling-image-v3-omni can enable series image generation through result_type and supports direct 4K ultra-high-definition output.
API: POST https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling-image/generation

2. Input Parameters

Parameter Name
Required
Type
Description
model
Yes
string
Model ID. Valid values: kling-image-o1, kling-image-v3-omni
prompt
Yes
string
Text prompt, which can contain positive and negative descriptions, with a maximum length of 2500 characters.
In multi-image reference scenarios, you can reference a specific reference image in the prompt using the <<<image_1>>> format, for example: blend the person from <<<image_1>>> into the scene of <<<image_2>>>. If image_list is not passed, text-to-image generation is performed based on this text.
image_list
No
array[string]
Reference image list (multiple images), up to 10 images. If a reference image list is provided, multi-image reference image-to-image generation is used.
Supports image URL (ensure it is accessible) or Base64 encoding. For Base64, you do not need to add the data:image/png;base64, prefix; directly pass the Base64 string itself.
element_list
No
array
Subject reference list, configured based on subject IDs in the subject library. Format: "element_list": [{"element_id": subject ID}].
The total number of reference subjects and reference images must not exceed 10.
aspect_ratio
No
string
Aspect ratio of the generated image (width:height).
Valid values: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9, auto (intelligently determines the aspect ratio based on the input content). Default value: auto.
Note: In text-to-image scenarios (when image_list is not passed), auto is not supported.
resolution
No
string
Resolution of the generated image.
Valid values: 1k (1K standard definition), 2k (2K high definition), 4k (4K ultra high definition). Default value: 1k.
4K is supported only by kling-image-v3-omni; kling-image-o1 supports 1K / 2K.
n
No
integer
Number of generated images. Value range: [1, 9]. Default value: 1.
This parameter is invalid when result_type is series.
result_type
No
string
Switch for toggling between single image / image series for generated results.
Valid values: single (single image, default), series (image series). Image series are supported only by kling-image-v3-omni.
series_amount
No
integer
Number of images in series mode. Takes effect only when result_type is series.
Valid values: 2 to 9, auto (intelligently selects the number based on the input content). Default value: 4.
watermark_info
No
object
Whether to simultaneously generate a watermarked result. Format: "watermark_info": {"enabled": boolean}.
true indicates that a watermarked result is generated, and false indicates that it is not. Custom watermarks are not supported.

3. Request Example

Multi-Image Reference (Kling-Image-o1)
# Text-to-image / Multi-image reference
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling-image/generation' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "kling-image-o1",
"prompt": "put the character in <<<image_1>>> into the scene of <<<image_2>>>",
"image_list": [
"https://example.com/character.jpg",
"https://example.com/scene.jpg"
],
"resolution": "2k",
"n": 1
}'
Multi-Image Reference + Series Image Generation (Kling-Image-v3-omni)
# Text-to-image / Multi-image reference / Image series
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling-image/generation' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "kling-image-v3-omni",
"prompt": "a small orange kitten sitting on a sunny windowsill",
"image_list": ["https://example.com/input.jpg"],
"result_type": "series",
"series_amount": 3
}'
The output parameters and response examples of the submission task are the same as those of Image Generation (Kling-Image-v3).

Image Generation (Kling-Image-v4)

1. API Description

Organize prompts and reference materials (supporting prompts, reference images, and subjects) in the contents array, and use settings to control output resolution, aspect ratio, and the number of single images / image sets. Images are generated asynchronously.
API: POST https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling/image-generation

2. Input Parameters

Parameter Name
Required
Type
Description
model
Yes
string
Model ID. Valid values: kling-image-v4
contents
Yes
array
A collection of reference materials. For details, see the field descriptions below. It must contain at least one type=prompt element.
contents[].type
Yes
string
Material type. Valid values: prompt (prompt), refer_image (reference image), element (subject library subject). The total number of images and subjects cannot exceed 10, and prompts do not count toward the reference quota.
contents[].text
No
string
Used only when type=prompt. Text prompt content, non-empty. Pure English: ≤ 50,000 characters. Pure non-English: ≤ 21,000 characters. Mixed input must satisfy English/50,000 + non-English/21,000 ≤ 1.
contents[].url
No
string
Used only when type=refer_image. Reference image URL or Base64 encoding. Supports .jpg / .jpeg / .png. Single image: ≤ 30 MB, width and height both ≥ 300 px, aspect ratio 2:5 to 5:2.
contents[].element_id
No
string
Used only when type=element. Subject ID in the subject library (only multi-image subjects are supported).
contents[].id
No
string
Material index ID, used to reference this material in prompts through @id; must be unique within the same task.
settings
No
object
Output settings. For details, see the fields below.
settings.result_type
No
string
Result type. Valid values: single (single image, default), series (image series, images in the same series share a group_id).
settings.n
No
integer
Number of images generated in single-image mode. Value range: [1, 9]. Default value: 1. Invalid when result_type=series.
settings.series_amount
No
integer / string
Number of images in series mode. Value range: [2, 10] or the string auto. Default value: 4. Takes effect only when result_type=series.
settings.resolution
No
string
Output resolution. Valid values: 2k (default), 4k, 8k.
settings.aspect_ratio
No
string
Output aspect ratio. Valid values: 16:9, 9:16, 1:1, 4:3, 3:4, 3:2, 2:3, 21:9, auto. Default value: auto.
options
No
object
General configuration.
options.watermark_info
No
object
Whether to simultaneously generate a watermarked result. Format: {"enabled": boolean}. Default value: false. Custom watermarks are not supported yet.
Note:
options.callback_url and options.external_task_id are not currently supported. Do not pass them.

3. Request Example

# Image-to-image (single image)
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling/image-generation' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "kling-image-v4",
"contents": [
{
"type": "prompt",
"text": "Using the puppy in @dog as reference, create a 3D animated-style character poster that keeps its fur color and appearance, with warm lighting and a clean background."
},
{
"type": "refer_image",
"url": "https://example.com/dog.png",
"id": "dog"
}
],
"settings": {
"result_type": "single",
"n": 1,
"resolution": "2k",
"aspect_ratio": "1:1"
}
}'

# Image series
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling/image-generation' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "kling-image-v4",
"contents": [
{
"type": "prompt",
"text": "With the puppy in @dog as the main character, create four consecutive 3D animated-style story images showing, in order: walking into a cafe, sitting by the window, smelling the coffee, and saying goodbye at the door"
},
{
"type": "refer_image",
"url": "https://example.com/dog.png",
"id": "dog"
}
],
"settings": {
"result_type": "series",
"series_amount": 4,
"resolution": "2k",
"aspect_ratio": "3:4"
},
"options": {
"watermark_info": {"enabled": false}
}
}'
For text-to-image generation, simply omit the refer_image field. To use subject reference, add an item with type set to element in contents (pass element_id and id), and reference it in the prompt using @id.

4. Output Parameters

Field
Type
Description
code
integer
Error code. 0 indicates success. If not 0, see message for troubleshooting.
message
string
API message.
request_id
string
Request ID generated by the system, used for tracking requests and troubleshooting.
data.id
string
Task ID, used for querying task results.
data.status
string
Task status. If the task is submitted successfully, the value is submitted.
data.message
string
Task status information.
data.create_time
integer
Task creation time, Unix timestamp in ms.
data.update_time
integer
Task update time, Unix timestamp in ms.

5. Response Example

{
"code": 0,
"message": "SUCCEED",
"request_id": "271d2cf5-1309-4af9-a890-604fa73048d6",
"data": {
"id": "251435731-kling_image_v4-30bfc3211f66479e8b14135fd1ed5bdc",
"status": "submitted",
"message": "",
"create_time": 1794984991920,
"update_time": 1794984991920
}
}
After obtaining data.id, poll for the final result by referring to the Query Task section.

Long Image Generation (Kling-Image-v4-long)

1. API Description

Used to generate long images for e-commerce detail pages or web design, ultimately returning a complete image. Switch scenarios through settings.skill: ecommerce is for e-commerce detail pages (paired with refer_image product reference images), and webpage is for web design (supporting style_refer_image style reference images and subject_refer_image subject reference images).
API: POST https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling/long-image-generation

2. Input Parameters

Parameter Name
Required
Type
Description
model
Yes
string
Model ID. Valid values: kling-image-v4-long
contents
Yes
array
A collection of reference materials. This field is required and cannot be empty. It must contain at least one type=prompt element.
contents[].type
Yes
string
Material type. Valid values: prompt, refer_image, style_refer_image, subject_refer_image. `element` is not supported.
contents[].text
No
string
Used only when type=prompt. Text prompt content, non-empty. Pure English: ≤ 166,000 characters. Pure non-English: ≤ 71,000 characters. Mixed input must satisfy English/166,000 + non-English/71,000 ≤ 1.
contents[].url
No
string
Used only when refer_image / style_refer_image / subject_refer_image. Reference image URL or Base64 encoding. Supports .jpg / .jpeg / .png. Single image: ≤ 30 MB, width and height both ≥ 300 px, aspect ratio 2:5 to 5:2.
contents[].id
No
string
Material index ID, used to reference this material in prompts through @id; must be unique within the same task.
settings
Yes
object
Output settings, required.
settings.skill
Yes
string
Skill used for generating long images: ecommerce (e-commerce detail page), webpage (web design).
settings.length
No
string
Page length. Valid values: short (about 2 to 5 feature pages), medium (about 6 to 10 feature pages, default), long (about 11 to 18 feature pages). Effective only when `skill=ecommerce`; invalid when webpage is used.
settings.resolution
No
string
Output resolution. Valid values: 1k (default), 2k.
options
No
object
General configuration.
options.watermark_info
No
object
Whether to simultaneously generate a watermarked result. Format: {"enabled": boolean}. Default value: false. Custom watermarks are not supported yet.
Note:
When skill=ecommerce, refer_image is required. You must provide 1 to 3 product reference images. Do not use style_refer_image / subject_refer_image.
When skill=webpage, pass reference images through style_refer_image (style reference) / subject_refer_image (subject reference). Do not use refer_image.
options.callback_url and options.external_task_id are not currently supported. Do not pass them.

3. Request Example

# E-commerce product detail page
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling/long-image-generation' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "kling-image-v4-long",
"contents": [
{
"type": "prompt",
"text": "Design a complete e-commerce product detail long image for the coffee machine in @product, including a hero visual, key selling points and usage scenarios; use only the provided product facts and do not invent specifications"
},
{
"type": "refer_image",
"url": "https://example.com/coffee_machine.png",
"id": "product"
}
],
"settings": {
"skill": "ecommerce",
"length": "medium",
"resolution": "1k"
}
}'

# Webpage design
curl -X POST 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling/long-image-generation' \\
-H 'Authorization: Bearer YOUR_API_KEY' \\
-H 'Content-Type: application/json' \\
-d '{
"model": "kling-image-v4-long",
"contents": [
{
"type": "prompt",
"text": "Design a long visual image for a specialty coffee brand website, including a brand hero section, product showcase, roasting philosophy, store information and footer; output one complete design image"
}
],
"settings": {
"skill": "webpage",
"resolution": "2k"
}
}'

4. Response Example

{
"code": 0,
"message": "SUCCEED",
"request_id": "17f2c8b0-e050-4b6c-8adc-9b4a5b9760c6",
"data": {
"id": "251435731-kling_image_v4_long-f965a34379a0448881077763957514f9",
"status": "submitted",
"message": "",
"create_time": 1794986040492,
"update_time": 1794986040492
}
}
The output parameter description is the same as that of Image Generation (Kling-Image-v4). After obtaining data.id, poll for the final result by referring to the Query Task section.

Querying Tasks

1. API Description

Query the status and results of image generation tasks. All five models share this API. After submitting a task, poll using the returned task ID (recommended every 3 to 5 seconds). The response structure falls into two categories based on the model:
For Kling-Image-v3 / o1 / v3-omni: poll until task_status = succeed. Single-image results are obtained from task_result.images. For series tasks where result_type is series, results are obtained from task_result.series_images.
For Kling-Image-v4 / v4-long: poll until status = succeeded or status = failed, then obtain results from data[].outputs[]. Long image generation ultimately returns only one complete image, while Kling-Image-v4 returns multiple entries based on the actual number of generated images.
API: GET https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling-image/tasks/{task_id}

2. Input Parameters

Parameter Name
Required
Type
Description
task_id
Yes
string
Task ID (path parameter), which is the task_id (v3 / o1 / v3-omni) or data.id (v4 / v4-long) returned when the task is submitted.

3. Request Example

curl -X GET 'https://tokenhub-intl.tencentcloudmaas.com/v1/wand/kling-image/tasks/YOUR_TASK_ID' \\
-H 'Authorization: Bearer YOUR_API_KEY'

4. Output Parameters

Kling-Image-v3 / Kling-Image-o1 / Kling-Image-v3-omni:
Field
Type
Description
code
integer
Error code.
message
string
Error message.
request_id
string
Request ID generated by the system, used for tracking requests and troubleshooting.
tokenhub_usage
object
Usage consumption.
tokenhub_usage.total_tokens
integer
Number of tokens consumed by this task, used for billing/reconciliation.
data.task_id
string
Task ID.
data.task_status
string
Task status, enumerated values: submitted (submitted), processing (processing), succeed (succeeded), failed (failed).
data.task_status_msg
string
Task status information, which displays the failure reason when a task fails.
data.created_at
integer
Task creation time, Unix timestamp in ms.
data.updated_at
integer
Task update time, Unix timestamp in ms.
data.task_result.images[].index
integer
Image number, ranging from 0 to 9.
data.task_result.images[].url
string
URL of the generated image.
data.task_result.images[].watermark_url
string
Download URL of the watermarked image (returned when watermark_info.enabled is true).
data.task_result.series_images[].index
integer
Series image number (returned for series image tasks).
data.task_result.series_images[].url
string
URL of the series image (returned for series image tasks).
Kling-Image-v4 / Kling-Image-v4-long:
Field
Type
Description
code
integer
Error code. 0 indicates success. If not 0, see message for troubleshooting.
message
string
API message.
request_id
string
Request ID. Include it when troubleshooting.
tokenhub_usage.total_tokens
integer
Number of tokens consumed by this task, used for billing/reconciliation.
data[].id
string
Queried task ID.
data[].status
string
Task status: submitted (submitted), processing (processing), succeeded (succeeded), failed (failed).
data[].message
string
Task status information, which displays the failure reason when a task fails (for example, when platform content moderation is triggered).
data[].create_time
integer
Task creation time, Unix timestamp in ms.
data[].update_time
integer
Task update time, Unix timestamp in ms.
data[].outputs[].type
string
Result type. For image tasks, the value is image.
data[].outputs[].url
string
URL of the generated image (hotlink-protected, valid for about 12 hours; download and store it promptly).
data[].outputs[].watermark_url
string
Download URL of the watermarked image (returned only when options.watermark_info.enabled=true).
data[].outputs[].group_id
string
Group ID of the image series (returned only for kling-image-v4 when result_type=series, used to mark images in the same series).

5. Response Example

Success (Kling-Image-v3 / o1 / v3-omni):
{
"code": 0,
"data": {
"created_at": 1790158890000,
"task_status_msg": "",
"updated_at": 1790158935886,
"task_id": "1256342408-WandImage-7f7d37d4db5d4d308b5a0d9a8374d7fb",
"task_info": {

},
"task_result": {
"images": [
{
"index": 0,
"url": "https://xxxxx.png"
},
{
"index": 1,
"url": "https://xxxxx.png"
}
]
},
"task_status": "succeed"
},
"message": "SUCCEED",
"request_id": "6efe9620-b3c6-472d-ac36-0322d3041e87",
"tokenhub_usage": {
"total_tokens": 40000
}
}
Processing (Kling-Image-v4 / v4-long):
{
"code": 0,
"message": "SUCCEED",
"request_id": "f2046163-ba72-460b-8cd0-5c4231619cb1",
"data": [
{
"id": "251435731-kling_image_v4-30bfc3211f66479e8b14135fd1ed5bdc",
"status": "processing",
"message": "",
"create_time": 1794984992000,
"update_time": 1794985029408
}
]
}
Success (Kling-Image-v4, single image):
{
"code": 0,
"message": "SUCCEED",
"request_id": "b7416b83-b664-4e11-b572-7d237bc68438",
"data": [
{
"id": "251435731-kling_image_v4-30bfc3211f66479e8b14135fd1ed5bdc",
"status": "succeeded",
"message": "",
"create_time": 1794984992000,
"update_time": 1794985136996,
"outputs": [
{
"type": "image",
"url": "https://aigc-output-image-file-xxx.cos.ap-guangzhou.myqcloud.com/xxx.png?q-sign-algorithm=sha1&..."
}
]
}
],
"tokenhub_usage": {
"total_tokens": 42000
}
}
Success (Kling-Image-v4-long, e-commerce detail page long image):
{
"code": 0,
"message": "SUCCEED",
"request_id": "45f2d4e8-7773-48ee-ad19-c97510f0d9b7",
"data": [
{
"id": "251435731-kling_image_v4_long-f965a34379a0448881077763957514f9",
"status": "succeeded",
"message": "",
"create_time": 1794986041000,
"update_time": 1794986350684,
"outputs": [
{
"type": "image",
"url": "https://aigc-output-image-file-xxx.cos.ap-guangzhou.myqcloud.com/xxx.png?q-sign-algorithm=sha1&..."
}
]
}
],
"tokenhub_usage": {
"total_tokens": 352000
}
}

Appendix

Error Code Descriptions

HTTP Status Code
Business Code
Business Code Definition
Business Code Description
Suggested Solution
200
0
Request succeeded
-
-
401
1000
Authentication failed
Authentication failed
Check whether Authorization is correct.
401
1001
Authentication failed
Authorization is empty.
Enter the correct Authorization in the Request Header.
401
1002
Authentication failed
Invalid Authorization value
Enter the correct Authorization in the Request Header.
401
1003
Authentication failed
Authorization is not yet valid.
Check the token's effective start time, and wait for it to take effect or reissue the token.
401
1004
Authentication failed
Authorization has expired.
Check the token's validity period and reissue it.
429
1100
Account exception
Account exception
Check the account configuration information.
429
1101
Account exception
Account overdue payment (postpaid scenario)
Top up the account to ensure sufficient balance.
429
1102
Account exception
Resource pack used up/expired (prepaid scenario)
Purchase additional resource packages, or activate the postpaid service if available.
403
1103
Account exception
No access to the requested resource, such as API/model.
Check the account permissions.
400
1200
Invalid request parameters
Invalid request parameters
Check whether the request parameters are correct.
400
1201
Invalid request parameters
Invalid parameters, such as incorrect key or invalid value.
Refer to the specific information in the message field of the response body, and modify the request parameters.
404
1202
Invalid request parameters
Invalid request method
Check the API documentation and use the correct request method.
404
1203
Invalid request parameters
The requested resource does not exist, such as the model.
Refer to the specific information in the message field of the response body, and modify the request parameters.
400
1300
Trigger Policy
Trigger platform policy
Check whether the platform policy is triggered.
400
1301
Trigger Policy
Trigger platform content security policy
Check the input content, modify it, and initiate the request again.
429
1302
Trigger Policy
API requests are too frequent, exceeding the platform rate limit.
Reduce the request frequency, retry later, or contact customer service to increase the limit.
429
1303
Trigger Policy
Concurrency or QPS exceeds the prepaid resource pack limit.
Reduce the request frequency, retry later, or contact customer service to increase the limit.
429
1304
Trigger Policy
Trigger platform IP address allowlist policy
Contact customer service.
500
5000
Internal error.
Internal server error
Retry later, or contact customer service.
503
5001
Internal error.
The server is temporarily unavailable, usually due to maintenance.
Retry later, or contact customer service.
504
5002
Internal error.
Internal server timeout, usually due to backlog.
Retry later, or contact customer service.

General Constraints on Image Assets

Kling-Image-v3 / o1 / v3-omni: Reference images support .jpg / .jpeg / .png formats. Each image must be no larger than 10 MB, with width and height no less than 300 px, and an aspect ratio between 1:2.5 and 2.5:1. Ensure that image URLs are accessible. For Base64 encoding, do not add the data:image/png;base64, prefix. Pass the Base64 string directly. For multi-image reference (image_list), you can provide up to 10 images. The total number of reference subjects and reference images must not exceed 10.
Kling-Image-v4 / v4-long: Reference images support .jpg / .jpeg / .png formats. Each image must be no larger than 30 MB, with width and height no less than 300 px, and an aspect ratio between 2:5 and 5:2. Both image URLs and Base64 encoding are supported. For kling-image-v4, the total number of images and subjects must not exceed 10. For kling-image-v4-long, 1 to 3 product reference images are required in e-commerce detail page scenarios.

FAQs

1. What Is the Difference Between Text-to-Image and Image-to-Image?

The same API supports both modes: for kling-image-v3, passing image enables image-to-image generation, and for kling-image-o1 / kling-image-v3-omni, passing image_list enables image-to-image generation, using the image content as reference. If neither is passed, text-to-image generation is performed (generated solely from the prompt). All three models support both modes. For kling-image-v4, adding refer_image to contents enables image-to-image generation, while including only prompt enables text-to-image generation.

2. How to Generate Image Sets?

kling-image-v3-omni and kling-image-v4 support series image generation:
kling-image-v3-omni: Set result_type to series and use series_amount to specify the number of images (2 to 9 or auto, default 4). In this case, n is ignored. Obtain results from task_result.series_images returned by the query task.
kling-image-v4: Set settings.result_type to series and use settings.series_amount to specify the number of images (2 to 10 or auto, default 4). In this case, settings.n is ignored. Obtain results from outputs[]. Images in the same series share the same group_id.
kling-image-v4-long does not support series image generation and always outputs a single complete long image.

3. When Can Negative Prompts Be Used?

Only Kling-Image-v3 supports negative_prompt, and it takes effect only in text-to-image scenarios. It is not supported for image-to-image generation (when image is passed). For Kling-Image-o1 / Kling-Image-v3-omni, you can write negative descriptions directly in prompt.

4. How to Reference an Image or Subject in Prompts?

kling-image-o1 / kling-image-v3-omni: In prompts, use <<<image_N>>> to reference the Nth reference image in image_list.
kling-image-v4 / kling-image-v4-long: In contents[], assign an id to each reference image / subject (unique within the same task), and reference it in prompts using @id. For example, if a reference image has the id dog, write a prompt like "Use the puppy in @dog as a reference...".

5. How to Upload Reference Images for E-Commerce Detail Pages and Web Design?

For e-commerce detail pages (skill=ecommerce): You must provide 1 to 3 product reference images through refer_image. Do not use style_refer_image / subject_refer_image.
For web design (skill=webpage): Pass reference images through style_refer_image (for visual style and layout reference) or subject_refer_image (to preserve subject elements). Do not use refer_image.

6. When Does the length Parameter Take Effect?

This parameter takes effect only when kling-image-v4-long is used and settings.skill=ecommerce is set. It controls the number of feature pages in e-commerce detail pages (short / medium / long). The setting is invalid for web design scenarios (skill=webpage).

7. Do Generated Image URLs Expire?

The generated result is a temporary address that expires in 12 hours. Download and save it promptly after the task succeeds.



Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan