Overview
Kling Image 4.0 uses one model ID for ordinary image generation, coherent image sets, webpage designs, and ecommerce detail pages. Ordinary images and image sets share the same per-image prices.image can generate several independent images. Use series when the outputs should form a coherent set. webpage creates a scrolling webpage design as an image; ecommerce creates a product detail page as an image. Long-image outputs are not HTML or editable websites.
Endpoint and authentication
Base URL:
Send
Authorization: Bearer YOUR_API_KEY. POST requests also require Content-Type: application/json.
Copy-paste async quickstart
Mode examples
Replace example image URLs with your publicly accessible image URLs.Coherent three-image set with one subject
Webpage long image
Ecommerce detail-page long image
length controls content inside one image: roughly 2–5 sections for short, 6–10 for medium, and 11–18 for long. These are content guidelines, not fixed output heights or section counts.
Parameters
Result delivery mode. Supported values:
async, callback. Use async for polling or callback for final webhook delivery. Poll until data.state is success or failed; HTTP 200 alone does not indicate successful generation.Required when request_type is callback. Use a publicly accessible HTTPS webhook URL. See Webhooks.
Poll for result
processing. Continue polling until success or failed; treat other states as still processing.
On success, data.resultJson is a JSON string containing one URL for each generated image:
costTime is elapsed milliseconds when available. Read each image’s actual content type instead of assuming an extension. Long-image tasks return one URL for the complete image.
Webhook delivery
Setrequest_type to callback and supply a top-level callback_url. Input parameters and the image result format are the same as with polling. Your receiver should accept the final payload and handle duplicate delivery safely. See Webhooks for the shared contract.
Billing
Standard prices are in USD before applicable account discounts. Check current prices for the latest rates. Ordinary images and coherent image sets share one output price table:
Each long-image task produces one complete image:
Input materials add $0.003 each per task, including the first. Count each ordinary reference image, named subject, webpage style/subject reference, or ecommerce product image as one material. A subject’s 2–4 internal reference images are included in its single subject fee. Material fees do not multiply with output count.
Request amount = output price × output count + $0.003 × input materials.
- Three 2K outputs with one subject containing three reference images:
3 × $0.063 + $0.003 = $0.192. - A 1K webpage with style and subject references:
$0.549 + 2 × $0.003 = $0.555. - A short 1K ecommerce page with one product image:
$0.235 + $0.003 = $0.238.
Latency and polling
Use callback mode for production workloads and allow longer generations in your application timeout. Do not submit a duplicate task just because the current task is still processing.
Errors and troubleshooting
Invalid inputs and insufficient balance can reject task creation. An accepted task may later fail: checkdata.state, then read failCode and failMsg when the state is failed. An HTTP 200 response by itself does not mean generation succeeded. See Error codes and Status Task.
Check the selected mode’s resolution and output count, ecommerce product-image requirement, and the combined limit of ordinary references plus subjects. Reference URLs must remain publicly accessible while the task runs.
MCP integration
The paired model schema declaresmcp.result as image URLs using url_array_v1. Render every returned URL. mcp.attachments supports image_urls, elements[].image_urls, style_image_url, and subject_image_url. Preserve file order. For a named subject, provide the parent object and its name in input, then bind its files to an explicit item index. See schema-driven MCP contracts.