## Basic model info - Model name: bria/bria bria-replace-background - Model description: Bria Background Replace allows for efficient swapping of backgrounds in images via text prompts or reference image, delivering realistic and polished results. - Endpoint name: image ## Model schema The model schema is defined in the OpenAPI schema: [OpenAPI Schema](https://oapi.sunra.ai/main/bria/bria-replace-background/latest.json) ### Model input schema The model input schema is: ```json { "properties": { "prompt": { "description": "The prompt you would like to use to generate images.", "title": "Prompt", "type": "string", "x-sr-order": 201 }, "prompt_enhancer": { "default": true, "description": "Whether to refine prompt", "title": "Prompt Enhancer", "type": "boolean", "x-sr-order": 202 }, "seed": { "description": "The same seed and the same prompt given to the same version of the model will output the same image every time.", "maximum": 2147483647, "minimum": 0, "title": "Seed", "type": "integer", "x-sr-order": 401 }, "negative_prompt": { "description": "The negative prompt you would like to use to generate images.", "title": "Negative Prompt", "type": "string", "x-sr-order": 203 }, "fast": { "default": true, "description": "Whether to use the fast model", "title": "Fast", "type": "boolean", "x-sr-order": 402 }, "image": { "anyOf": [ { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, { "type": "string" } ], "description": "Input Image to erase from", "title": "Image", "x-sr-order": 301 }, "number_of_images": { "default": 1, "description": "Number of Images to generate.", "maximum": 4, "minimum": 1, "multipleOf": 1, "title": "Number Of Images", "type": "integer", "x-sr-order": 403 }, "reference_image": { "anyOf": [ { "format": "uri", "maxLength": 2083, "minLength": 1, "type": "string" }, { "type": "string" } ], "description": "The URL of the reference image to be used for generating the new background. Use \"\" to leave empty. Either ref_image_url or bg_prompt has to be provided but not both. If both ref_image_url and ref_image_file are provided, ref_image_url will be used. Accepted formats are jpeg, jpg, png, webp.", "title": "Reference Image", "x-sr-order": 302 } }, "required": [ "image" ], "title": "BackgroundReplaceInput", "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": "", "prompt_enhancer": true, "seed": null, "negative_prompt": "", "fast": true, "image": "", "number_of_images": 1, "reference_image": "" } ``` ### Output example ```json { } ``` ## Model code examples ### JavaScript ```javascript import { sunra } from "@sunra/client"; const result = await sunra.subscribe("bria/bria-replace-background/image", { input: { image: '', reference_image: '', prompt: '', prompt_enhancer: true, negative_prompt: '', seed: null, fast: true, number_of_images: 1 }, 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( "bria/bria-replace-background/image", arguments={ "image": "", "reference_image": "", "prompt": "", "prompt_enhancer": True, "negative_prompt": "", "seed": None, "fast": True, "number_of_images": 1 }, 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( "bria/bria-replace-background/image", SubscribeOptions.builder() .input(Map.of( "image", "", "reference_image", "", "prompt", "", "prompt_enhancer", true, "negative_prompt", "", "seed", null, "fast", true, "number_of_images", 1)) .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 = "bria/bria-replace-background/image", input = mapOf( "image" to "", "reference_image" to "", "prompt" to "", "prompt_enhancer" to true, "negative_prompt" to "", "seed" to null, "fast" to true, "number_of_images" to 1), 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/bria/bria-replace-background/image \ --header "Authorization: Key $SUNRA_KEY" \ --header "Content-Type: application/json" \ --data '{"image":"","reference_image":"","prompt":"","prompt_enhancer":true,"negative_prompt":"","seed":null,"fast":true,"number_of_images":1}' ``` ## Model readme undefined