## Basic model info - Model name: kling/kling kling-image-4 - Model description: Generate or edit 2K, 4K, and 8K images with up to ten references, or create long webpage and ecommerce visuals. - Endpoint name: image-editing ## Model schema The model schema is defined in the OpenAPI schema: [OpenAPI Schema](https://oapi.sunra.ai/main/kling/kling-image-4/ddf6cb742904d9f8bc15081a014eb7c7ba010943.json) ### Model input schema The model input schema is: ```json { "properties": { "prompt": { "maxLength": 50000, "minLength": 1, "title": "Prompt", "type": "string", "x-sr-order": 201 }, "aspect_ratio": { "default": "auto", "enum": [ "16:9", "9:16", "1:1", "4:3", "3:4", "3:2", "2:3", "21:9", "auto" ], "title": "Aspect Ratio", "type": "string", "x-sr-order": 402 }, "image_urls": { "description": "Reference images, addressable as @image_1, @image_2, ...", "items": { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, "maxItems": 10, "minItems": 1, "title": "Image Urls", "type": "array", "x-sr-order": 301 }, "n": { "default": 1, "maximum": 9, "minimum": 1, "title": "N", "type": "integer", "x-sr-order": 404 }, "resolution": { "default": "2K", "enum": [ "2K", "4K", "8K" ], "title": "Resolution", "type": "string", "x-sr-order": 401 }, "result_type": { "default": "single", "enum": [ "single", "series" ], "title": "Result Type", "type": "string", "x-sr-order": 403 }, "series_amount": { "anyOf": [ { "type": "integer" }, { "const": "auto", "type": "string" }, { "type": "null" } ], "title": "Series Amount", "x-sr-order": 405 } }, "required": [ "prompt", "image_urls" ], "title": "ImageEditingInput", "type": "object" } ``` ### Model output schema The model output schema is: ```json { "properties": { "images": { "items": { "properties": { "content_type": { "description": "The mime type of the file.", "title": "Content Type", "type": "string" }, "file_name": { "description": "The name of the file. It will be auto-generated if not provided.", "title": "File Name", "type": "string" }, "file_size": { "description": "The size of the file in bytes.", "title": "File Size", "type": "integer" }, "url": { "description": "The URL where the file can be downloaded from.", "title": "Url", "type": "string" } }, "required": [ "content_type", "file_name", "file_size", "url" ], "title": "SunraFile", "type": "object" }, "minItems": 1, "title": "Images", "type": "array" }, "units": { "description": "Customer charge in thousandths of a USD.", "minimum": 0, "title": "Units", "type": "integer" } }, "required": [ "images", "units" ], "title": "KlingImage4UnitsOutput", "type": "object" } ``` ## Example inputs and outputs Use the following example inputs and outputs to understand the model. ### Input example ```json { "prompt": "", "aspect_ratio": "auto", "image_urls": [ ], "n": 1, "resolution": "2K", "result_type": "single", "series_amount": null } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("kling/kling-image-4/image-editing", { input: { prompt: '', resolution: '2K', aspect_ratio: 'auto', result_type: 'single', n: 1, series_amount: null, image_urls: [] }, logs: true, onQueueUpdate: (update) => { console.log(`Status Update: ${update.status}, Request ID: ${update.request_id}`); }, }); console.log(result.data); console.log(result.requestId); ``` ### Python ```python import sunra_client result = sunra_client.subscribe( "kling/kling-image-4/image-editing", arguments={ "prompt": "", "resolution": "2K", "aspect_ratio": "auto", "result_type": "single", "n": 1, "series_amount": None, "image_urls": [] }, with_logs=True, on_enqueue=print, on_queue_update=print, ) print(result) ``` ### Java ```java import ai.sunra.client.*; import java.util.Map; import com.google.gson.JsonObject; var client = SunraClient.withEnvCredentials(); var response = client.subscribe( "kling/kling-image-4/image-editing", SubscribeOptions.builder() .input(Map.of( "prompt", "", "resolution", "2K", "aspect_ratio", "auto", "result_type", "single", "n", 1, "series_amount", null, "image_urls", )) .resultType(JsonObject.class) .onQueueUpdate(update -> System.out.printf( "\nStatus Update: %s, Request ID: %s%n", update.getStatus(), update.getRequestId() )) .logs(true) .build() ); System.out.println("Completed!"); System.out.println(response.getData()); ``` ### Kotlin ```kotlin import ai.sunra.client.kt.* import com.google.gson.JsonObject val client = createSunraClient() val response = client.subscribe( endpointId = "kling/kling-image-4/image-editing", input = mapOf( "prompt" to "", "resolution" to "2K", "aspect_ratio" to "auto", "result_type" to "single", "n" to 1, "series_amount" to null, "image_urls" to ), options = ai.sunra.client.kt.SubscribeOptions(logs = true), onUpdate = { update -> println("\nStatus Update: ${update.status}, Request ID: ${update.requestId}") } ) println("Completed!") println(response.data) ``` ### Curl ```bash curl --request POST \ --url https://api.sunra.ai/v1/queue/kling/kling-image-4/image-editing \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"prompt":"","resolution":"2K","aspect_ratio":"auto","result_type":"single","n":1,"series_amount":null,"image_urls":[]}' ``` ## Model readme > Kling Image 4.0 supports text generation, editing with as many as ten reference images, and long webpage or ecommerce visuals. Standard output supports 2K, 4K, and 8K; long image output supports 1K and 2K. > > Kling official is the default provider. Fal is retained as selectable standby for text generation and image editing; long-image generation is official-only because the measured fal cost exceeded the public sell price. Customer billing always follows Kling's public list matrix; provider cost is tracked separately.