## Basic model info - Model name: black-forest-labs/black-forest-labs flux-2-flex - Model description: Text-to-image generation with FLUX.2 [flex] from Black Forest Labs. Features adjustable inference steps and guidance scale for fine-tuned control. Enhanced typography and text rendering capabilities. - Endpoint name: text-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-flex/latest.json) ### Model input schema The model input schema is: ```json { "description": "Input model for FLUX 2 Flex text-to-image generation.", "properties": { "prompt": { "description": "The prompt to generate an image from.", "title": "Prompt", "type": "string", "x-sr-order": 200 }, "aspect_ratio": { "default": "4:3", "description": "Aspect ratio of the generated image.", "enum": [ "1:1", "4:3", "3:4", "16:9", "9:16" ], "title": "Aspect Ratio", "type": "string", "x-sr-order": 201 }, "guidance_scale": { "default": 3.5, "description": "The guidance scale for generation. Higher values follow the prompt more closely.", "maximum": 10, "minimum": 1.5, "multipleOf": 0.1, "title": "Guidance Scale", "type": "number", "x-sr-order": 300 }, "seed": { "description": "Seed for reproducibility.", "maximum": 2147483647, "minimum": 0, "title": "Seed", "type": "integer", "x-sr-order": 202 }, "num_inference_steps": { "default": 28, "description": "The number of inference steps to perform.", "maximum": 50, "minimum": 2, "title": "Num Inference Steps", "type": "integer", "x-sr-order": 301 }, "output_format": { "default": "jpeg", "description": "Output format for the generated image.", "enum": [ "jpeg", "png" ], "title": "Output Format", "type": "string", "x-sr-order": 400 } }, "required": [ "prompt" ], "title": "TextToImageInput", "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": "4:3", "guidance_scale": 3.5, "seed": null, "num_inference_steps": 28, "output_format": "jpeg" } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("black-forest-labs/flux-2-flex/text-to-image", { input: { prompt: '', aspect_ratio: '4:3', seed: null, guidance_scale: 3.5, num_inference_steps: 28, output_format: 'jpeg' }, 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-flex/text-to-image", arguments={ "prompt": "", "aspect_ratio": "4:3", "seed": None, "guidance_scale": 3.5, "num_inference_steps": 28, "output_format": "jpeg" }, 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-flex/text-to-image", SubscribeOptions.builder() .input(Map.of( "prompt", "", "aspect_ratio", "4:3", "seed", null, "guidance_scale", 3.5, "num_inference_steps", 28, "output_format", "jpeg")) .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-flex/text-to-image", input = mapOf( "prompt" to "", "aspect_ratio" to "4:3", "seed" to null, "guidance_scale" to 3.5, "num_inference_steps" to 28, "output_format" to "jpeg"), 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-flex/text-to-image \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"prompt":"","aspect_ratio":"4:3","seed":null,"guidance_scale":3.5,"num_inference_steps":28,"output_format":"jpeg"}' ``` ## Model readme >