## 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: long-image-generation ## 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": 166000, "minLength": 1, "title": "Prompt", "type": "string", "x-sr-order": 201 }, "image_urls": { "anyOf": [ { "items": { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, "maxItems": 3, "minItems": 1, "type": "array" }, { "type": "null" } ], "title": "Image Urls", "x-sr-order": 301 }, "length": { "anyOf": [ { "enum": [ "short", "medium", "long" ], "type": "string" }, { "type": "null" } ], "title": "Length", "x-sr-order": 403 }, "resolution": { "default": "1K", "enum": [ "1K", "2K" ], "title": "Resolution", "type": "string", "x-sr-order": 402 }, "skill": { "enum": [ "webpage", "ecommerce" ], "title": "Skill", "type": "string", "x-sr-order": 401 }, "style_image_url": { "anyOf": [ { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, { "type": "null" } ], "title": "Style Image Url", "x-sr-order": 302 }, "subject_image_url": { "anyOf": [ { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, { "type": "null" } ], "title": "Subject Image Url", "x-sr-order": 303 } }, "required": [ "prompt", "skill" ], "title": "LongImageInput", "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": "", "image_urls": null, "length": null, "resolution": "1K", "skill": "", "style_image_url": null, "subject_image_url": null } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("kling/kling-image-4/long-image-generation", { input: { prompt: '', skill: '', resolution: '1K', length: null, image_urls: null, style_image_url: null, subject_image_url: null }, 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/long-image-generation", arguments={ "prompt": "", "skill": "", "resolution": "1K", "length": None, "image_urls": None, "style_image_url": None, "subject_image_url": None }, 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/long-image-generation", SubscribeOptions.builder() .input(Map.of( "prompt", "", "skill", "", "resolution", "1K", "length", null, "image_urls", null, "style_image_url", null, "subject_image_url", null)) .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/long-image-generation", input = mapOf( "prompt" to "", "skill" to "", "resolution" to "1K", "length" to null, "image_urls" to null, "style_image_url" to null, "subject_image_url" to null), 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/long-image-generation \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"prompt":"","skill":"","resolution":"1K","length":null,"image_urls":null,"style_image_url":null,"subject_image_url":null}' ``` ## 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.