v1

latestOpenAPI 3.0.02026-07-13650400.5 KB
Image Editing

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)
post/background/remove

Headers

api_tokenstring required

Response

Successful operation.

result_urlstring

URL that represents the updated visual created in the request. It is a temporary URL that will expire.