Image Modifications

Get Masks

Description

Note: This API route requires the image to be registered via the /register route.

The Objects/Mask Generator Route is used to generate all possible masks for an image, creating a full segmentation of the image.

The response contains a zip file named as the visual_id of the provided image.

There are k mask files in the zip, each named with the visual_id and mask_id.

The zip file contains an additional file whose name ends with "panoptic". It's not an image, it's a panoptic map. It can be transformed into a regular matrix.

Each point in the image (x,y) is mapped to the mask that applies to that point. In the panoptic map, each pixel's grayscale value includes the mask_id.

You can display those masks to the user, let them pick one or more masks, and use objects/remove route to remove the masked area.

In order to use the objects/remove route on the mask the user selected, you should provide the mask_id, and use the parameter mask_source=generated.

You can see below an example of the content of the zip:

  92bf8ce17584de82_panoptic.png

  
  92bf8ce17584de82_1.png

  
  92bf8ce17584de82_2.png

  
  92bf8ce17584de82_3.png

  
  ...

  
  92bf8ce17584de82_86.png

You can access the SDK that demonstrates how to use this endpoint in a UI in the following link.

Request
path Parameters
visual_id
required
string

visual id of the image, received after using the /upload or register route.

Example: 92bf8ce17584de82
header Parameters
api_token
required
string
Responses
200

Successful operation.

400

Bad request.

404

Specified Image does not exist.

405

Method not allowed.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

500

Internal server error.

506

Insufficient data. The given input is not supported by the Bria API.

post/{visual_id}/objects/mask_generator
Request samples

Get Presenter info

Description

Note: This API route requires the image to be registered via the /register route.

The Person/Info Route is used to retrieve useful information on the people in a specific visual that was previously uploaded to the database.

Additionally, it provides a description of each person within the scene along with its available changes, which are supported by the Bria API.

This route should be used instead of the main /info route when you are only interested in information and available actions for the people in the image. With this route, you will save time by only obtaining information that is relevant to your needs.

Request
path Parameters
visual_id
required
string

visual id of the image, received after using the /upload or register route.

Example: f49943971e3039c7
header Parameters
api_token
required
string
Responses
200

Successful operation.

205

File hasn’t finished onboarding. Please call /info again until you get 200.

400

One of the details does not meet specification. Please call person/info again.

404

Specified Image does not exist.

405

Method not allowed.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

500

Internal server error.

506

Insufficient data. The given input is not supported by the Bria API.

get/{visual_id}/person/info
Request samples
Response samples
application/json
[
  • {
    },
  • {
    }
]

Modify Presenter

Description

Note: This API route requires the image to be registered via the /register route.

The Create Route is used to create a new visual, based on the changes requested by the user for a previously uploaded visual.

You can also use this route on a modified image by providing the sid from the response of the previously used route.

This route returns both the URL and the sid associated with the updated image.

Before making any modifications, please call the /info or person/info route to obtain information on the available presenters in the image, the available modifications, and their oracle values.

You should always include all the required changes in the request if you want to use multiple changes on a single person. It is not supported to make one request on a person with one change, take the SId from the result, and then use it in another request with a different change.

When you want to make changes on multiple people, you can make one request with all the desired changes on all the relevant people or make one request with all the desired changes on one person and then use the sid from the response in the request on the other person.

Request
path Parameters
visual_id
required
string

visual id of the image the user wants to create a new visual from.

Example: 8487fb411f3c6716
header Parameters
api_token
required
string
Request Body schema: application/json
sid
string

This session id was obtained from the response of a route that had been applied to this visual id. If you have used another route on the provided visual before, and you would like the current route to modify the result of that route, please provide this information. This parameter is optional.

desired_resolution
string

The desired resolution of the updated image. This parameter is optional.

Enum: "original" "nhd" "svga" "xga" "had" "wuxga" "uwfhd" "wqxga" "uwqhd" "uhd"
Array of objects

The requested changes to the original visual.

Responses
200

Successful operation.

400

Bad request.

404

Specified Image does not exist.

405

Method not allowed.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

500

Internal server error.

506

Insufficient data. The given input is not supported by the Bria API.

Erase Foreground

Description

This route is used to erase the foreground from a provided image, while generating the area behind it.

Request
header Parameters
api_token
required
string
Request Body schema: application/json
image_url
string

The URL of the input image. 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.

file
string

The file of the input image, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.

Responses
200

Successful operation.

400

Bad request. Missing or invalid parameters.

401

Unauthorized. Invalid API key or authentication token.

404

Not found. Image could not be found at the provided URL.

413

Payload too large. Image file size exceeds the 12MB limit.

415

Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

451

Unavailable for legal reasons.

460

Failed to download image.

500

Internal server error. An error occurred on the server.

post/erase_foreground
Request samples
Response samples
application/json
{
  • "result_url": "URL"
}

Eraser

Description

The Eraser Route enables the removal of elements or specific areas from a given image.

You can define the area to be removed by providing a mask that outlines the region to be erased. There are two main ways recommended to generate these masks:

  1. Masks can be created by allowing users to draw directly on the image with a brush, for example. To access the SDK that demonstrates how to implement a brush feature in your interface, please refer to the following link.
  2. By using the /objects/mask_generator route, which will generate all the possible masks for an image.

This capability is powered by our fast ControlNet inpainting model. HF model card is available here, and the HF demo space can be found here

Additionally, ComfyUI nodes that enable running this API route can be found here

Request
header Parameters
api_token
required
string
Request Body schema: application/json
image_url
string

The URL of the input image. If both image_url and image_file are provided, image_url will be used. Accepted formats are jpeg, jpg, png, webp.

file
string

The file of the input image, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp.

mask_url
string

The URL of the binary mask image that represents the area that will be cleaned. If both mask_url and mask_file are provided, mask_url will be used. Accepted formats - jpeg, jpg, png, webp. The area to be removed should have the value 255 (white), while the rest of the image should have the value 0 (black).

mask_file
string

The file of the binary mask image that represents the area that will be cleaned, in base64 format. This parameter is used if mask_url is not provided. Accepted formats - jpeg, jpg, png, webp. The area to be removed should have the value 255 (white), while the rest of the image should have the value 0 (black).

mask_type
string
Default: "manual"

You can use this parameter to specify the type of the input mask from the list. 'manual' opttion should be used in cases in which the mask had been generated by a user (e.g. with a brush tool), and 'automatic' mask type should be used when mask had been generated by an algorithm like 'SAM'.

Enum: "manual" "automatic"
Responses
200

Successful operation.

400

Bad request. Missing or invalid parameters.

401

Unauthorized. Invalid API key or authentication token.

404

Not found. Image could not be found at the provided URL.

415

Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

460

Failed to download image.

500

Internal server error. An error occurred on the server.

post/eraser
Request samples
Response samples
application/json
{
  • "result_url": "URL"
}

Remove Background

Description

The Remove BG Route can be used to remove the background of an image. This route leverages Bria's newest model, RMBG 2.0. For more details and to explore the model, check out the Hugging Face demo.

The main difference between the regular and this isolated background removal endpoint is that you can use this endpoint without uploading or registering the image to Bria.

Constraints

The Bria API currently supports only JPEG and PNG files in RGB, RGBA, or CMYK color modes. When the file is of a different type or color mode, the status code 415 will be returned.

Remove the background from an image using the image file

In our documentation request example, we demonstrate how to remove the background from an image using the image URL.

If you want to use an image from a file, follow the example below:

  import requests

  url = "https://engine.prod.bria-api.com/v1/background/remove"

  payload = {}
  files=[
    ('file',('image_name.jpeg',open('/path_to_local_file/image_name.jpeg','rb'),'image/jpeg'))
  ]
  headers = {
    'api_token': 'xxxx'
  }

  response = requests.request("POST", url, headers=headers, data=payload, files=files)

  print(response.text)
Request
header Parameters
api_token
required
string
Request Body schema: application/x-www-form-urlencoded
required
file
string <binary>

The image file you would like to remove the background from.

image_url
string

The URL of the image file you would like to remove the background from. The URL should lead to an image publicly available online. Either a file or an image_url should be provided. If both are provided, then the route will use image_url.

Responses
200

Successful operation.

206

File value was not provided.

400

Request doesn't contain file part.

405

Method not allowed.

415

Unsupported media type.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

460

Failed to download image.

500

Internal server error.

506

Insufficient data. The given input is not supported by the Bria API.

post/background/remove
Request samples
Response samples
application/json
{
  • "result_url": "string"
}

Blur Background

Description

The background/blur Route is used to create a blur effect on the background of an image.

Request
header Parameters
api_token
required
string
Request Body schema: application/json
image_url
string

The URL of the input image. 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.

file
string

The file of the input image, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.

scale
integer [ 1 .. 5 ]
Default: 5

A scale for determining how blurry the background of the image should be. The options are 1, 2, 3, 4, 5. This parameter is optional.

Responses
200

Successful operation.

400

Bad request. Missing or invalid parameters.

401

Unauthorized. Invalid API key or authentication token.

404

Not found. Image could not be found at the provided URL.

413

Payload too large. Image file size exceeds the 12MB limit.

415

Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

451

Unavailable for legal reasons.

460

Failed to download image.

500

Internal server error. An error occurred on the server.

post/background/blur
Request samples
Response samples
application/json
{
  • "result_url": "URL"
}

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 (available on Hugging Face). We offer a fast version of this feature, powered by Bria 2.3 Fast LoRA (model card on Hugging Face), 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:

bg_prompt: in a parking lot

num_results: 3

results:

Request
header Parameters
api_token
required
string

API token associated with the organization.

Request Body schema: application/json
sync
boolean
Default: false

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.

fast
boolean
Default: true

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_url
string

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.

file
string

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.

bg_prompt
string

Text description of the new scene or background for the provided image. Bria currently supports prompts in English only, excluding special characters.

refine_prompt
boolean
Default: true

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

original_quality
boolean
Default: false

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_results
integer
Default: 4

The number of results you would like to generate.

negative_prompt
string

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.

seed
integer

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.

Responses
200

Successful operation.

400

Bad request. Missing or invalid parameters.

401

Unauthorized. Invalid API key or authentication token.

404

Not found. Image could not be found at the provided URL.

413

Payload too large. Image file size exceeds the 12MB limit.

415

Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

451

Unavailable for legal reasons.

460

Failed to download image.

500

Internal server error. An error occurred on the server.

post/background/replace
Request samples
Response samples
application/json
{
  • "result": [
    ]
}

Expand Image

Description

The Image Expension Route can be used to expand an image, by utilizing generative AI.

You can decide on the image size of the final result as well as the position and size of the original image compared to the final result.

In this way, you can create unique variations of your original image instead of cropping it into different aspect ratios and losing important details.

Optimal input range

Input Image Area: Ensure that the ratio of the input image foreground or main subject to the canvas area is greater than 15% to achieve optimal results.

Canvas Size: The canvas size should be up to an area of 5000x5000 pixels. Here are some examples:

original image (Generated by Bria):

results:

original image (Stock Image):

results:

Request
header Parameters
api_token
required
string
Request Body schema: application/json
image_url
string

The URL of the input image. 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.

file
string

The file of the input image, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.

canvas_size
Array of integers
Default: [1000,1000]

The desired size of the final image, after the expansion. should have an area of less than 5000x5000 pixels.

original_image_size
Array of integers

The desired size of the original image, inside the full canvas. Ensure that the ratio of input image foreground or main subject to the canvas area is greater than 15% to achieve optimal results.

original_image_location
Array of integers

The desired location of the original image, inside the full canvas. Provide the location of the upper left corner of the original image. The location can also be outside the canvas (the original image will be cropped).

prompt
string

Text on which you wish to base the image expansion. This parameter is optional. Bria currently supports prompts in English only, excluding special characters.

seed
integer

You can choose whether you want your generated expension 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.

negative_prompt
string

This parameter is optional. Bria currently supports prompts in English only.

Responses
200

Successful operation.

400

Bad request. Missing or invalid parameters.

401

Unauthorized. Invalid API key or authentication token.

404

Not found. Image could not be found at the provided URL.

413

Payload too large. Image file size exceeds the 12MB limit.

415

Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

451

Unavailable for legal reasons.

460

Failed to download image.

500

Internal server error. An error occurred on the server.

post/image_expansion
Request samples
Response samples
application/json
{
  • "code": 200,
  • "description": "SUCCESS",
  • "message": "Finished sucessfully",
  • "prompt": "a man in a shirt sitting down in front of a brick wall looking off to the side",
  • "result_url": "URL",
  • "seed": 1525972691,
  • "status": "SUCCESS"
}

Increase Resolution

Description

The Isolated Increase Resolution Route is used to upscale the resolution of any image.

The main difference between the regular and this isolated Increase Resolution endpoint is that you can use this endpoint without uploading or registering the image to Bria.

Constraints

The Bria API currently supports only JPEG and PNG files in RGB, RGBA, or CMYK color modes. When the file is of a different type or color mode, the status code 415 will be returned.

It's possible to increase the resolution of an image up to a total area of 8192x8192 pixels.

Increase the Resolution of an image using the image file

In our documentation request example, we demonstrate how to Increase the Resolution of an image using the image URL.

If you want to use an image from a file, follow the example below:

  import requests

  url = "https://engine.prod.bria-api.com/v1/image/increase_resolution?desired_increase=2"

  payload = {}
  files=[
    ('file',('image_name.jpeg',open('/path_to_local_file/image_name.jpeg','rb'),'image/jpeg'))
  ]
  headers = {
    'api_token': 'xxxx'
  }

  response = requests.request("POST", url, headers=headers, data=payload, files=files)

  print(response.text)
            
Request
query Parameters
desired_increase
integer

The resolution multiplier. The possible value are 2,4. It's possible to increase the resolution of an image up to a total area of 8,192x8,192 pixels.

Example: desired_increase=2
header Parameters
api_token
required
string
Request Body schema: application/x-www-form-urlencoded
required
file
string <binary>

The image file you would like to increase the resolution for. Minimum resolution supported for width and/or height is 216 pixels.

image_url
string

The URL of the image file you would like to increase the resolution for. The URL should lead to an image publicly available online. Either a file or an image_url should be provided. If both are provided, then the route will use image_url. Minimum resolution supported for width and/or height is 216 pixels.

Responses
200

Successful operation.

400

Bad request

405

Method not allowed.

406

The input image's resolution is too low.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

460

Failed to download image.

500

Internal server error.

506

Insufficient data. The given input is not supported by the Bria API.

Delayer Image

Description

Note: This API route requires the image to be registered via the /register route. It will be replaced soon with isolated version, that doesn't require image registration.

The Image to PSD Route is used to create a layered PSD file from any image.

The image is divided into different layers (depending on the image): a background layer with all identified objects removed, a foreground layer without the background, and a layer for each object.

You can also use this route on a modified image by providing the sid from the response of the previously used route.

Request
path Parameters
visual_id
required
string

visual id of the image, for which the user would like to create a layered PSD file

Example: 8487fb411f3c6716
query Parameters
sid
string

This session id was obtained from the response of a route that had been applied to this visual id. If you have used another route on the provided visual before, and you would like the current route to apply on the result of that route, please provide this information. This parameter is optional.

Example: sid=Remove this parameter if the image has not been modified using Bria.
header Parameters
api_token
required
string
Responses
200

Successful operation.

400

Bad request.

404

Specified Image does not exist.

405

Method not allowed.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

500

Internal server error.

506

Insufficient data. The given input is not supported by the Bria API.

Crop out foreground

Description

The Crop Route is used to crop an image without a background tightly around the remaining region of interest.

You can utilize Bria's /background/remove endpoint and then use the result of that route in the/crop route.

Request
header Parameters
api_token
required
string
Request Body schema: application/json
optional
image_url
string

The URL of the input image. 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.

file
string

The file of the input image, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp. Maximum file size 12MB.

padding
integer
Default: 0

Cropping the object with padding around it. Currently, padding is applied to all four borders of the remaining region. This parameter is optional.

Responses
200

Successful operation.

400

Bad request. Missing or invalid parameters.

401

Unauthorized. Invalid API key or authentication token.

404

Not found. Image could not be found at the provided URL.

413

Payload too large. Image file size exceeds the 12MB limit.

415

Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.

429

Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.

451

Unavailable for legal reasons.

460

Failed to download image.

500

Internal server error. An error occurred on the server.

post/crop
Request samples
Response samples
application/json
{
  • "result_url": "URL"
}