v1

latestOpenAPI 3.0.02026-07-13650400.5 KB
Image Editing

Generate Background

Description

The Replace BG Route is used to replace the background of any image with a generated background using the state-of-the-art BRIA 2.3 ControlNet BG-Gen model (<a href="https://huggingface.co/briaai/BRIA-2.3-ControlNet-BG-Gen" target="_blank">available on Hugging Face</a>). We offer a fast version of this feature, powered by Bria 2.3 Fast LoRA (<a href="https://huggingface.co/briaai/BRIA-2.3-FAST-LORA" target="_blank">model card on Hugging Face</a>), which provides an optimal balance between speed and quality. This endpoint also supports solid colors - you can take a color code and use it in the prompt.
Here are some examples:

original image:

<img src="https://i.ibb.co/n6JtktM/unnamed-13.jpg" width="200"/>

bg_prompt: in a parking lot

num_results: 3

results:

<img src="https://i.ibb.co/1zvT5h4/unnamed-14.jpg" width="200"/> <img src="https://i.ibb.co/MkVDxc8/unnamed-15.jpg" width="200"/> <img src="https://i.ibb.co/pfgQ34p/unnamed-16.jpg" width="200"/>

post/background/replace

Headers

api_tokenstring required

API token associated with the organization.

Request body

syncboolean

Determines the response mode. When true, responses are synchronous. With false, responses are asynchronous, immediately providing URLs for images that are generated in the background. It is recommended to use sync=false for optimal performance. When generating more than 1 result, you should use the value false.

fastboolean

Determines the generation mode. When true, the generation will utilize the fast mode which provides the best balance between speed and quality. When false, the regular mode will be utilized.

image_urlstring

The URL of the image to which a new background should be generated. If both image_url and image_file are provided, image_url will be used. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.

filestring

The product of the image to which a new background should be generated, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.

ref_image_urlstring

The URL of the reference image to be used for generating the new background. 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.

ref_image_filestring

The reference image file to be used for generating the new background. If both ref_image_url and ref_image_file are provided, ref_image_url will be used. Accepted formats are jpeg, jpg, png, webp.

bg_promptstring

Text description of the new scene or background for the provided image. Either ref_image_url or bg_prompt has to be provided but not both. Bria currently supports prompts in English only, excluding special characters.

refine_promptboolean

When true, an additional logic takes the bg_prompt that was included and adjusts it to achieve optimal results. Built with Meta Llama 3.

enhance_ref_imageboolean

When set to true, additional logic processes the included reference image to make adjustments for optimal results.

original_qualityboolean

When true, the output image retains the original input image's size; otherwise, the image is scaled to 1 megapixel (1MP) while preserving its aspect ratio.

num_resultsinteger

The number of results you would like to generate.

force_rmbgboolean

Forces background removal, even if the original image already contains an alpha channel. Useful for refining existing foreground/background separation or ignoring unnecessary alpha channels.

negative_promptstring

Elements or features that should be excluded from the generated scene. This parameter is optional and is available only when fast=false. Bria currently supports descriptions in English only.

seedinteger

You can choose whether you want your generated results to be random or predictable. You can recreate the same result in the future by using the seed value of a result from the response. You can exclude this parameter if you are not interested in recreating your results. This parameter is optional.

Response

Successful operation.

Example response

{
  "result": [
    [
      "result_url",
      244184855,
      "ef3d9a20-4d5d-11ee-8741-8e22fc45bbfc.JPEG"
    ]
  ]
}