Skip to main content

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

An accepted request returns a task ID:
Task acceptance does not mean generation has completed. Save the task ID and query the status endpoint.

Mode examples

Replace example image URLs with your publicly accessible image URLs.

Coherent three-image set with one subject

This request has one billable subject, even though it contains three reference images and the task requests three outputs.

Webpage long image

Both references are optional. This example has two billable input materials.

Ecommerce detail-page long image

Ecommerce requires 1–3 product images. 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

string
default:"async"
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.
string
Required when request_type is callback. Use a publicly accessible HTTPS webhook URL. See Webhooks.
object
required
Kling Image 4.0 generation parameters. Send the fields for your selected mode.

Poll for result

While generating, the task returns a nonterminal state such as 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:
Creation and completion timestamps use Unix milliseconds; 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

Set request_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.
Apply the applicable account discount to the full amount, then round the request total upward to the nearest $0.001. Failed tasks are fully refunded. When a successful task returns fewer images than requested, missing output charges are refunded using the task’s captured prices and discount; input material fees are retained. See Pricing for the platform calculation rules.

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: check data.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 declares mcp.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.