## Basic model info - Model name: black-forest-labs/black-forest-labs flux-2-klein-4b - Model description: Text-to-image generation with FLUX.2 [klein] 4B from Black Forest Labs. Enhanced realism, crisper text generation, and native editing capabilities. - Endpoint name: image-to-image ## Model schema The model schema is defined in the OpenAPI schema: [OpenAPI Schema](https://oapi.sunra.ai/main/black-forest-labs/flux-2-klein-4b/latest.json) ### Model input schema The model input schema is: ```json { "description": "Input model for FLUX 2 Klein 4B image-to-image editing.", "properties": { "prompt": { "description": "The prompt to generate an image from.", "title": "Prompt", "type": "string", "x-sr-order": 200 }, "aspect_ratio": { "default": "auto", "description": "Aspect ratio of the generated image. Use 'auto' to match the input image.", "enum": [ "auto", "1:1", "4:3", "3:4", "16:9", "9:16" ], "title": "Aspect Ratio", "type": "string", "x-sr-order": 201 }, "seed": { "description": "Seed for reproducibility.", "maximum": 2147483647, "minimum": 0, "title": "Seed", "type": "integer", "x-sr-order": 202 }, "image_urls": { "description": "The URLs of the images for editing. A maximum of 4 images are allowed.", "items": { "anyOf": [ { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, { "type": "string" } ] }, "title": "Image Urls", "type": "array", "x-sr-order": 250 }, "loras": { "description": "List of LoRA weights to apply (maximum 3).", "items": { "description": "LoRA weight specification.", "properties": { "path": { "description": "URL or HuggingFace repo ID (owner/repo) of the LoRA weights.", "title": "Path", "type": "string" }, "scale": { "default": 1, "description": "Scale factor for LoRA application (0.0 to 4.0).", "maximum": 4, "minimum": 0, "title": "Scale", "type": "number" } }, "required": [ "path" ], "title": "LoRAWeight", "type": "object" }, "title": "Loras", "type": "array", "x-sr-order": 301 }, "num_inference_steps": { "default": 4, "description": "The number of inference steps to perform.", "maximum": 8, "minimum": 4, "title": "Num Inference Steps", "type": "integer", "x-sr-order": 300 }, "output_format": { "default": "png", "description": "Output format for the generated image.", "enum": [ "jpeg", "png", "webp" ], "title": "Output Format", "type": "string", "x-sr-order": 400 } }, "required": [ "prompt", "image_urls" ], "title": "ImageToImageInput", "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" }, "title": "Images", "type": "array" } }, "required": [ "images" ], "title": "ImagesOutput", "type": "object" } ``` ## Example inputs and outputs Use the following example inputs and outputs to understand the model. ### Input example ```json { "prompt": "", "aspect_ratio": "auto", "seed": null, "image_urls": [ ], "loras": [ ], "num_inference_steps": 4, "output_format": "png" } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("black-forest-labs/flux-2-klein-4b/image-to-image", { input: { prompt: '', aspect_ratio: 'auto', seed: null, num_inference_steps: 4, loras: [], output_format: 'png', 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( "black-forest-labs/flux-2-klein-4b/image-to-image", arguments={ "prompt": "", "aspect_ratio": "auto", "seed": None, "num_inference_steps": 4, "loras": [], "output_format": "png", "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( "black-forest-labs/flux-2-klein-4b/image-to-image", SubscribeOptions.builder() .input(Map.of( "prompt", "", "aspect_ratio", "auto", "seed", null, "num_inference_steps", 4, "loras", , "output_format", "png", "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 = "black-forest-labs/flux-2-klein-4b/image-to-image", input = mapOf( "prompt" to "", "aspect_ratio" to "auto", "seed" to null, "num_inference_steps" to 4, "loras" to , "output_format" to "png", "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/black-forest-labs/flux-2-klein-4b/image-to-image \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"prompt":"","aspect_ratio":"auto","seed":null,"num_inference_steps":4,"loras":[],"output_format":"png","image_urls":[]}' ``` ## Model readme >