Image GenerationKling Image
Kling Image
Kling's image generation model with text-to-image and image editing via reference images.
POST /v2/images/generate — model: "kling-image"
Kling Image generates high-quality images from text prompts with support for reference image editing, negative prompts, and multiple aspect ratios.
See Image Generation overview for common request fields, response format, and error codes.
Model-specific parameters
| Parameter | Type | Description |
|---|---|---|
klingImageParams.model_name | string | Kling model variant. Values: "kling-v1", "kling-v1-5", "kling-v2" (default "kling-v1") |
klingImageParams.negative_prompt | string | Negative text prompt, max 2500 characters |
klingImageParams.image | string | Reference image URL for image-to-image generation |
klingImageParams.image_fidelity | number | Reference image strength, 0–1 |
klingImageParams.n | integer | Number of images to generate (1–4, default 1) |
klingImageParams.aspect_ratio | string | Aspect ratio. Values: "16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3" |
Credit cost
Credits are 2 per image, multiplied by n (the number of images requested).
| n | Credits |
|---|---|
| 1 | 2 |
| 2 | 4 |
| 3 | 6 |
| 4 | 8 |
Code examples
curl -X POST https://api.apiframe.ai/v2/images/generate \
-H "X-API-Key: afk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene Japanese garden with cherry blossoms falling into a koi pond",
"model": "kling-image",
"klingImageParams": {
"aspect_ratio": "16:9",
"n": 1
}
}'import requests
response = requests.post(
"https://api.apiframe.ai/v2/images/generate",
headers={
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
json={
"prompt": "A serene Japanese garden with cherry blossoms falling into a koi pond",
"model": "kling-image",
"klingImageParams": {
"aspect_ratio": "16:9",
"n": 1,
},
},
)
print(response.json())const response = await fetch("https://api.apiframe.ai/v2/images/generate", {
method: "POST",
headers: {
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "A serene Japanese garden with cherry blossoms falling into a koi pond",
model: "kling-image",
klingImageParams: { aspect_ratio: "16:9", n: 1 },
}),
});
console.log(await response.json());Try it
POST
/v2/images/generateTry it