The Bria API is designed to provide a comprehensive suite of tools for generating and customizing images. With Bria, you can:
Generate Images Using Bria Models: Utilize pre-trained Bria models to generate high-quality images based on text prompts.
Train Your Own Tailored Models: Create and manage custom-tailored models to generate images in specific styles or themes using your datasets.
Enhance Product Imagery with E-commerce Solutions: Use specialized features to create professional product shots, packshots, and lifestyle images for e-commerce platforms.
Upload or Register Images: Bring your own images into Bria and modify them using various routes to suit your needs.
This document provides an overview of the API's capabilities and guides users on how to effectively implement them.
Image Generation: - Use the /text-to-image
endpoints to generate any image you would like, based on the provided prompt, without needing to upload or register images first.
Tailored Generation: The Tailored Generation API allows you to create and manage custom-tailored models for generating unique visual content based on your datasets. Tailored models can be trained using the API or through the Bria platform here.
Using the Tailored Generation API:
/datasets
endpoint to create a new dataset or retrieve existing datasets that belong to the client organization./datasets/{dataset_id}/images
endpoint to upload new images to a dataset or retrieve existing images that belong to the dataset./datasets/{dataset_id}/images/{image_id}
endpoint to get or delete a specific image from a dataset./models
endpoint to create a new model or retrieve all models that belong to the client organization./models/{id}
endpoint to retrieve a specific model by its ID or delete a specific model./models/{id}/start_training
endpoint to initiate the training process. Ensure that the dataset includes the minimum required number of images and has a status of 'completed' before starting training./models/{id}/stop_training
endpoint to stop a training job for a model.Training a Tailored Model:
/datasets
endpoint to create a dataset./datasets/{dataset_id}/images
endpoint./models
endpoint to create a model associated with your dataset./models/{id}/start_training
endpoint./text-to-image/tailored/{model_id}
route to generate images.Bria offers a variety of solutions for products and apps in the e-commerce industry, which allow to enhance product imagery for online stores and product catalogs. These solutions include:
Product Cutout: Create clean and professional product cutouts.
Product Packshot: Generate professional-standard packshots with customizable background colors and optimal product placement.
Lifestyle Product Shot by Text: Enrich product images by placing them in various environments using textual descriptions, enhancing appeal and providing context.
Lifestyle Product Shot by Image: Generate product images in enriched environments using a reference image for inspiration, allowing for creative and unique presentations.
Uploading and Registering Images:
/register
endpoint to send a new image to Bria without being uploaded to the database. This is the recommended method to onboard images to Bria when needed.With the response from the Upload/Register Routes (visual_id), the following routes can be used without any particular order:
With the response from the Info Routes or from the Mask Generator, the following routes can be used without any particular order:
The "Oracle" capability within the API can significantly elevate the user experience by offering quality prediction functionalities.
With the Oracle integrated into your product, you can ensure optimal outcomes for your end users.
This feature covers various endpoints, including /create, objects/remove, and background operations, providing you with a range of quality prediction options to enhance your product's capabilities.
The orcale value predicts the quality of the result, for each possible action.
By using the "info" for all endpoints, "person/info" endpoint for face modifications, "objects/info" for object removal, and "background/info" for background actions, you can access the Oracle's predictions, and help your users to make informed decisions.
Incorporating Oracle predictions into the API workflow enhances efficiency, minimizes errors, and fosters an optimized API experience.
The Bria API consists of a number of methods for uploading and creating new visual assets. The REST (representational state transfer) API methods can be called directly from within your own custom code.
curl --location --request POST 'https://engine.prod.bria-api.com/v1' \
--header: 'api_token: <...>' \
...
You can register and access the API Token through Bria's platform by clicking here.
Description
The /text-to-image/base Route empowers users to create stunning images directly from textual prompts. This model allows for generating high-quality, photorealistic and artistic, images with a resolution of up to 1024x1024 pixels, supporting a variety of aspect ratios natively to accommodate diverse creative needs.
Advanced Customization and Access:
Beyond the API, developers interested in deeper customization can access BRIA's models directly through Hugging Face. This alternative provides access to the underlying model source code, offering additional features such as Bria 2.3 Fast LoRA and ControlNets: Canny , Depth, and ReColoring. This option is ideal for developers seeking advanced control over the image generation process and those who wish to integrate cutting-edge AI directly into their workflows.
Examples:
prompt: A professional headshot of a CEO
BRIA BASE model 2.3:
prompt: A vaporwave detailed illustration of a street in London in pastel hues, under a Union Jack sky
BRIA BASE model 2.3:
prompt: A portrait of a Beautiful and playful ethereal singer, art deco, fantasy, intricate art deco golden designs, elegant, highly detailed, sharp focus, blurry background, teal and orange shades
BRIA BASE model 2.3:
Successful operation.
Successful operation, a model version that is no longer available was requested. The request was redirected to the latest model version.
Bad request.
Method not allowed.
Internal server error.
Description
The /text-to-image/fast Route is optimized for speed, enabling rapid image creation without compromising quality. This model allows for generating high-quality, photorealistic and artistic, images with a resolution of up to 1024x1024 pixels, supporting a variety of aspect ratios natively to accommodate diverse creative needs. Ideal for applications requiring quick turnaround without sacrificing image fidelity.
Advanced Customization and Access:
Beyond the API, developers interested in deeper customization can access BRIA's models directly through Hugging Face. This alternative provides access to the underlying model source code, offering additional features such as ControlNets: Canny , Depth, and ReColoring. This option is ideal for developers seeking advanced control over the image generation process and those who wish to integrate cutting-edge AI directly into their workflows.
An example:
prompt: A portrait of a Beautiful and playful ethereal singer, art deco, fantasy, intricate art deco golden designs, elegant, highly detailed, sharp focus, blurry background, teal and orange shades
BRIA FAST model 2.3:
Successful operation.
Bad request.
Method not allowed.
Internal server error.
Description
The /text-to-image/hd Route is tailored for projects demanding the utmost in image detail and clarity. This model allows for generating high-quality, photorealistic and artistic, images with unparalleled resolution of 1920x1080 (1:1 1536x1536) pixel, supporting a variety of aspect ratios natively to accommodate diverse creative needs.
Advanced Customization and Access:
Beyond the API, developers interested in deeper customization can access BRIA's models directly through Hugging Face. This alternative provides access to the underlying model source code, offering additional features such as ControlNets: Canny , Depth, and ReColoring. This option is ideal for developers seeking advanced control over the image generation process and those who wish to integrate cutting-edge AI directly into their workflows.
Examples:
prompt: A photo of detailed short female blond hair viewed from behind, with rich texture and clearly visible individual strands that give depth and realism, and featuring subtle waves reflect light
BRIA HD model 2.2:
prompt: A portrait of a Beautiful and playful ethereal singer, art deco, fantasy, intricate art deco golden designs, elegant, highly detailed, sharp focus, blurry background, teal and orange shades
BRIA HD model 2.2:
Successful operation.
Bad request.
Method not allowed.
Internal server error.
Description
The campaign_generator Route enables users to create visual campaigns for various ad channels using a visual_id. This route facilitates the generation of templates featuring diverse layouts that incorporate elements like text, logos, and calls to action (CTA), tailored to various resolutions (placements) and target audiences.
Ad backgrounds are expanded to fit the necessary layout specifications.
Examples
original image (Generated by Bria):
Results:
Successful response with generated campaign visuals.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "ads": [
- {
- "bg_seed": null,
- "canvas_size": [
- 1200,
- 627
], - "channel": {
- "id": 7,
- "name": "Amazon"
}, - "expansion_seed": 4046260470,
- "jpeg_file": "jpg_file_url",
- "layout_id": "120",
- "placement": {
- "id": 54,
- "name": "Amazon 1200x627"
}, - "png_file": "png_file_url",
- "psd_file": "psd_file_url",
- "template_id": null
}
]
}
Description
The Image Expension Route can be used to expand an image and its background, 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 input image area is more than 15% of the canvas area 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:
You can 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.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Insufficient resources to process the request.
{- "message": "Finished sucessfully",
- "prompt": "a man in a shirt sitting down in front of a brick wall looking off to the side",
- "seed": 1525972691,
- "sid": "3b5b6858-0a9a-11ee-a0d6-565ee9a92763.JPEG",
- "status": "SUCCESS"
}
Description
The Isolated Increase Resolution Route is used to upsacle 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 Resolutio 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)
Successful operation.
Bad request
Method not allowed.
Failed to download image.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
The Increase Resolution Route is used to upsacle the resolution of any image.
You can also use this route on a modified image by providing the sid from the response of the previously used route.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
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.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
The Crop Route is used to crop an image without a background tightly around the remaining region of interest.
You can also use this route on a modified image by providing the sid from the response of the previously used route. You can utilize Bria's /background/remove endpoint and then use the result of that route in the /crop route.
This route returns both the URL and the sid associated with the updated image.
On images without transparent backgrounds, the response will be the provided image at the selected resolution.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
This route allows you to generate images using a tailored model. Tailored models are trained using your own datasets to create unique visual styles, character illustrations, or icons. You can train a tailored model through the API or using the Bria platform.
The Tailored Model API provides a set of endpoints to manage the entire lifecycle of a tailored model:
Dataset Management: Create and manage datasets which will be used to train your tailored models. You can:
/datasets
endpoint to create a new dataset or retrieve existing datasets that belong to the client organization./datasets/{dataset_id}/images
endpoint to upload a new image to a dataset or retrieve existing images that belong to the dataset./datasets/{dataset_id}/images/{image_id}
endpoint to get or delete a specific image from a dataset.Model Management: Create and manage models based on your datasets. You can:
/models
endpoint to create a new model or retrieve all models that belong to the client organization./models/{id}
endpoint to retrieve a specific model by its ID or delete a specific model.Training Management: Start and stop training jobs for your models. You can:
/models/{id}/start_training
endpoint to initiate the training process. Note that the dataset must include the minimum required number of images and have a status of 'completed' before training can start./models/{id}/stop_training
endpoint to stop a training job for a model.To train a tailored model via the API:
/datasets
endpoint to create a dataset./datasets/{dataset_id}/images
endpoint./models
endpoint to create a model associated with your dataset./models/{id}/start_training
endpoint. Training of a tailored model takes between 1-3 hours.Alternatively, you can use the Bria platform to manage and train your tailored models through a user-friendly interface. Access the Bria platform here.
Successful operation.
Bad request.
Method not allowed.
Internal server error.
Description This endpoint allows the creation of a new dataset that will belong to the organization associated with the used API token. The dataset will be created with a default status of "draft".
Dataset successfully created.
Bad request.
Unauthorized.
Internal server error.
{- "id": 123,
- "use_case": "illustrative_style",
- "style_description": "A 2d vibrant and colorful flat illustration.",
- "name": "My Illustrations",
- "status": "draft",
- "images_count": 0,
- "images": [ ],
- "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}
Description Retrieve a list of datasets that belong to the organization associated with the used API token. If no datasets are found, an empty array is returned.
Successful operation.
Unauthorized.
Internal server error.
[- {
- "id": 123,
- "use_case": "illustrative_style",
- "style_description": "A 2d vibrant and colorful flat illustration.",
- "name": "My Illustrations",
- "images_count": 10,
- "status": "completed",
- "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}, - {
- "id": 124,
- "use_case": "illustrative_single_object",
- "style_description": "A 2d illustration of a bear",
- "name": "Character bear",
- "images_count": 5,
- "status": "draft",
- "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}
]
Description Retrieve a specific dataset by its ID. The response includes all the details of the dataset and an array of associated images.
Successful operation.
Unauthorized.
Dataset with the specified ID does not exist.
Internal server error.
{- "id": 123,
- "use_case": "illustrative_style",
- "style_description": "A 2d vibrant and colorful flat illustration.",
- "name": "My Illustrations",
- "status": "draft",
- "images": [
- {
- "id": 123,
- "name": "Illustration1",
- "caption": "A vibrant 2D illustration of a sunny day with children playing in a park.",
- "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}, - {
- "id": 124,
- "name": "Illustration2",
- "caption": "A colorful 2D illustration depicting a busy city street with various shops and people.",
- "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}
], - "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}
Description
Update the details of a specific dataset by its ID. If the status of the dataset is completed
, the style_description
and use_case
cannot be updated. Additionally, if the status is completed
, it cannot be returned to draft
if a model has already been trained based on it.
Successful operation.
Bad request.
Unauthorized.
Dataset with the specified ID does not exist.
Conflict.
Internal server error.
{- "id": 123,
- "use_case": "illustrative_style",
- "style_description": "A 2d vibrant and colorful flat illustration.",
- "name": "My Illustrations",
- "status": "draft",
- "images": [
- {
- "id": 123,
- "name": "Illustration1",
- "caption": "A vibrant 2D illustration of a sunny day with children playing in a park.",
- "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}, - {
- "id": 124,
- "name": "Illustration2",
- "caption": "A colorful 2D illustration depicting a busy city street with various shops and people.",
- "created_at": "2024-05-26T12:00:00Z",
- "updated_at": null
}
], - "created_at": "2024-05-26T12:00:00Z",
- "updated_at": "2024-05-26T12:00:00Z"
}
Description Delete a specific dataset. Changes status to deleted.
Dataset successfully deleted.
Dataset with the specified ID does not exist.
Conflict.
Internal server error.
{- "error": "Cannot delete a dataset that is used by a model that is in training or has the status 'ready'."
}
Description
Upload a new image to a specific dataset. One of the following parameters, file
or image_url
, must be provided.
Upload a new image using the image file
In our documentation request example, we demonstrate how to upload a new image using the image URL.
If you want to use an image from a file, follow the example below:
import requests
url = "/tailored-gen/datasets/{dataset_id}/images"
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)
Image successfully uploaded.
Bad request.
Dataset with the specified ID does not exist.
Conflict.
Precondition Failed.
Unsupported Media Type.
Unprocessable Entity.
Internal server error.
id=123&dataset_id=123&caption=A%20vibrant%202D%20illustration%20of%20a%20sunny%20day%20with%20children%20playing%20in%20a%20park.&file_name=Illustration1.png&image_url=https%3A%2F%2Fexample.com%2Fimage1.png&thumbnail_url=https%3A%2F%2Fexample.com%2Fimage1_thumbnail.png&created_at=2024-05-26T12%3A00%3A00Z
Description Retrieve a list of images in a specific dataset.
Successful operation.
Dataset with the specified ID does not exist.
Internal server error.
[- {
- "id": 123,
- "dataset_id": 123,
- "caption": "A vibrant 2D illustration of a sunny day with children playing in a park.",
- "file_name": "Illustration1.png",
- "created_at": "2024-05-26T12:00:00Z"
}, - {
- "id": 123,
- "dataset_id": 123,
- "caption": "A colorful 2D illustration depicting a busy city street with various shops and people.",
- "file_name": "Illustration2.png",
- "created_at": "2024-05-26T12:00:00Z"
}
]
Description Retrieve a specific image by its ID.
Successful operation.
Not Found.
Internal server error.
{- "id": 123,
- "dataset_id": 123,
- "caption": "A vibrant 2D illustration of a sunny day with children playing in a park.",
- "file_name": "Illustration1.png",
- "created_at": "2024-05-26T12:00:00Z"
}
Description Delete a specific image.
Image successfully deleted.
Not Found.
Conflict.
Internal server error.
{- "error": "Image with the specified ID does not exist."
}
Description Create a new model.
Model successfully created.
Dataset with the specified ID does not exist.
Internal server error.
{- "id": 123,
- "name": "My Model",
- "description": "This model is designed for generating illustrative style images.",
- "status": "Created",
- "dataset_id": 123,
- "created_at": "2024-05-26T12:00:00Z"
}
Description Retrieve a list of models. If there are no models, an empty array is being returned.
Successful operation.
Unauthorized.
Internal server error.
[- {
- "id": 123,
- "name": "My Model",
- "description": "This model is designed for generating illustrative style images.",
- "status": "Created",
- "dataset_id": 123,
- "created_at": "2024-05-26T12:00:00Z"
}, - {
- "id": 124,
- "name": "Another Model",
- "description": "This model is designed for generating character style images.",
- "status": "Training In Progress",
- "dataset_id": 124,
- "created_at": "2024-05-26T12:00:00Z"
}
]
Description Retrieve a specific model by its ID.
Successful operation.
Model with the specified ID does not exist.
Internal server error.
{- "id": 123,
- "name": "My Model",
- "description": "This model is designed for generating illustrative style images.",
- "status": "Created",
- "dataset_id": 123,
- "created_at": "2024-05-26T12:00:00Z"
}
Description Delete a specific model.
Model successfully deleted.
Model with the specified ID does not exist.
Internal server error.
{- "status": "Deleted"
}
Description Start a new training job for a specific model. Training of a tailored model takes between 1-3 hours.
Training job successfully started.
Model with the specified ID does not exist.
Conflict.
Precondition Failed.
Internal server error.
{- "id": 123,
- "status": "Training In Progress"
}
Description Stop a specific training job for a model.
Training job successfully stopped.
Model with the specified ID does not exist.
Conflict.
Internal server error.
{- "error": "Model with the specified ID does not exist."
}
This capability allows you to create a precise cutout of a product from any given image. This feature is especially valuable for e-commerce platforms and applications, serving as a fundamental building block for crafting a user-friendly interface.
The following interactive Colab notebook demonstrates how to use this API effectively. Explore the example code and try it out for yourself to fully appreciate the potential of this suite.
Successful operation.
Bad request.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result_url": "URL"
}
The Product Pack Shot feature is designed to create professional standard pack shots. The output is a 2000x2000 px image, with the product size and location according to best practices. This feature can allow users to take any photo of a product and transform it into a professional pack shot, placing the product on a clean, seamless background, typically white but customizable to any color.
The following interactive Colab notebook demonstrates how to use this API effectively. Explore the example code and try it out for yourself to fully appreciate the potential of this suite.
Successful operation.
Bad request.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result_url": "URL"
}
Creates enriched product shots by placing them in various environments using textual descriptions. Additionally, you can change the image size of the final result as well as the positioning of the product in the image. This will enable you to create new and unique variations of your original image.
The following interactive Colab notebook demonstrates how to use this API effectively. Explore the example code and try it out for yourself to fully appreciate the potential of this suite.
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result": [
- [
- "result_url",
- 244184855
]
]
}
Generates product images in enriched environments using a reference image for inspiration. Additionally, you can change the image size of the final result as well as the positioning of the product in the image. This will enable you to create new and unique variations of your original image.
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result": [
- [
- "result_url",
- 244184855,
- "ef3d9a20-4d5d-11ee-8741-8e22fc45bbfc.JPEG"
]
]
}
Description This feature allows users to create consistent product shots by providing either a textual description of a scene or an image, along with a group of product images. The resulting consistent product shots are ideal for use on social media, e-commerce websites, product catalogs, and other marketing materials, ensuring a uniform and professional appearance across all platforms.
Successful operation.
Description This feature allows users to extract relevant keywords from an image and its context, focusing on the primary product rather than secondary elements. This capability enhances search optimization in e-commerce by ensuring that the keywords accurately represent the product being sold. It can be particularly useful for improving product searchability on e-commerce websites, enhancing SEO for product listings, automating content management, and optimizing social media marketing efforts.
Successful operation.
Description
A new visual can be registered to Bria without being uploaded to the database using the Register Route. This route returns a visual identification to the user. This is the recommended method to onboard images to Bria, when needed.
It's the first step for consuming the Bria API for new visuals (instead of using the /upload route).
Response
The visual id in the response of the Register Route must be kept by the user in order to query image info, modify the image and use the search routes.
{ "visual_id": "9ea9a4d2d19977a7c" }
The visual_id in the response of the /upload route will be used for all other routes. Store the visual_id in your database and map it to your image identification method for easy reference
Constraints
Files should not be larger than 12MB. The status code 413 will be returned if the file exceeds its maximum size.
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.
Successful operation.
Image already registered.
Bad request.
Method not allowed.
Failed to download image.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "visual_id": "string"
}
Description
With this route, you can remove an image from the gallery of your organization. The image won't be removed from Bria.
Successful operation.
Bad request.
Method not allowed.
Failed to download image.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
The Info Route is used to retrieve useful information on a specific visual that was previously uploaded or registered.
Additionally, it provides the following:
A description of each object and element within the scene
The available changes, which are supported by the Bria API for each object and element
The Oracle value for each available change. The orcale value predicts the quality of the result, for each possible action. The possible oracle values for object removal or background actions are true and false. The possible values for person modification are high, medium, and low.
Successful operation.
File hasn’t finished onboarding. Please call /info again until you get 200.
One of the details does not meet specification. Please call /info again.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "description": "Coming Soon",
- "scene": [
- {
- "actions": {
- "age": [
- "mid-20",
- "mid-40",
- "mid-60"
], - "Beard": [
- "shaved",
- "medium",
- "full"
], - "diversity": [
- "africa",
- "korea",
- "india",
- "japan",
- "sweden",
- "germany",
- "russia",
- "mexico",
- "brazil",
- "england",
- "spain",
- "france"
], - "expression": [
- "happy",
- "surprised",
- "dreaming",
- "angry",
- "fear",
- "contempt",
- "disgusted",
- "sad"
], - "gender": [
- "femininity",
- "masculinity"
], - "glasses": [
- "light",
- "none",
- "heavy"
], - "hair_line": [
- "high",
- "low"
], - "haircolor": [
- "black",
- "brown",
- "red",
- "blond",
- "gray"
], - "makeup": [
- "light",
- "heavy",
- "none"
]
}, - "id": "a48284e4832c809e4475ad5de7bdd333658e363b417a28991022a6fa79488a6b",
- "labels": [
- "age_23-35",
- "calm"
], - "oracle": {
- "age": {
- "age": "high"
}, - "Beard": {
- "Beard": "high"
}, - "diversity": {
- "africa": "high",
- "brazil": "high",
- "england": "high",
- "france": "high",
- "germany": "high",
- "india": "high",
- "japan": "high",
- "korea": "high",
- "mexico": "high",
- "russia": "high",
- "spain": "high",
- "sweden": "high"
}, - "expression": {
- "angry": "high",
- "contempt": "high",
- "disgusted": "high",
- "dreaming": "high",
- "fear": "high",
- "happy": "high",
- "surprised": "high"
}, - "gender": {
- "gender": "high"
}, - "glasses": {
- "glasses": "high"
}, - "hair_line": {
- "hair_line": "high"
}, - "haircolor": {
- "haircolor": "high"
}
}, - "type": "person"
}, - {
- "id": "0a349cbe603a786570d4eec7dd9cf64e568ef72767a5847251b32988a2b99dff",
- "type": "chair",
- "labels": [
- "object"
], - "rect": {
- "x": 647.4609375,
- "y": 3910.6640625,
- "w": 1139.53125,
- "h": 2071.875
}, - "actions": {
- "remove": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true
}, - "bg_overlap": 0.4
}, - {
- "actions": {
- "remove": [
- true
]
}, - "id": "26bf1a1e6b7c5a802b804a52be420a14e44c7d4a393d695afb9d58c9f869cac3",
- "labels": null,
- "oracle": {
- "remove": true
}, - "type": "background"
}
]
}
Description
The Background/Info Route is used to retrieve useful information on the background of a specific visual that was previously uploaded to the database.
Additionally, it provides the following:
The available background actions, which are supported by the Bria API.
The Oracle value for each available action. The orcale value predicts the quality of the result, for each possible action. The possible oracle values for background actions are true and false.
This route should be used instead of the main /info route when you are only interested in the available actions for the background of the image. With this route, you will save runtime by only obtaining information that is relevant to your needs.
Successful operation.
File hasn’t finished onboarding. Please call /info again until you get 200.
One of the details does not meet specification. Please call person/info again.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "id": "67a9746d4c7939e2753869cdb4330852b6e2472b8110ae1fb59f8c033fc7fe1f",
- "type": "background",
- "labels": null,
- "rect": null,
- "actions": {
- "remove": [
- true
], - "blur": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true,
- "blur": true,
- "replace": true
}
}
Description
The Remove BG Route can be used to remove the background of an image.
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)
Successful operation.
File value was not provided.
Request doesn't contain file part.
Method not allowed.
Unsupported media type.
Failed to download image.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "result_url": "string"
}
Description
The Remove BG Route is used to remove the background of a previously uploaded image.
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 background/info route to obtain information on the available modifications, and their oracle values.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
The background/blur Route is used to create a blur effect on the background of a previously uploaded image.
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 background/info route to obtain information on the available modifications, and their oracle values.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
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:
Successful operation.
Bad request. Missing or invalid parameters.
Unauthorized. Invalid API key or authentication token.
Not found. Image could not be found at the provided URL.
Payload too large. Image file size exceeds the 12MB limit.
Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
Unavailable for legal reasons.
Failed to download image.
Internal server error. An error occurred on the server.
{- "result": [
- [
- "result_url",
- 244184855,
- "ef3d9a20-4d5d-11ee-8741-8e22fc45bbfc.JPEG"
]
]
}
Description
The Replace BG Route is used to replace the background of a previously uploaded 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. Before making any modifications, please call the /info or background/info route to obtain information on the available modifications, and their oracle values.
Here are some examples:
original image:
bg_prompt: in a parking lot
num_results: 3
results:
You can 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.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Insufficient resources to process the request.
{- "result": [
- [
- "result_url",
- 244184855,
- "ef3d9a20-4d5d-11ee-8741-8e22fc45bbfc.JPEG"
]
]
}
Description
The Objects/Info Route is used to retrieve useful information on the objects in a specific visual that was previously uploaded to the database.
Additionally, it provides the following:
The available object actions, which are supported by the Bria API.
The Oracle value for each available action. The orcale value predicts the quality of the result, for each possible action. The possible oracle values for object actions are true and false.
This route should be used instead of the main /info route when you are only interested in information and available actions for the objects in the image. With this route, you will save runtime by only obtaining information that is relevant to your needs.
Successful operation.
File hasn’t finished onboarding. Please call /info again until you get 200.
One of the details does not meet specification. Please call objects/info again.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
[- {
- "id": "d34ef7cf0b4e1ea2e414cdff7ae9ded80162f1f93bb94df709fe29d9df3dbfb5",
- "type": "dining table",
- "labels": [
- "object"
], - "rect": {
- "x": 1294.921875,
- "y": 4143.75,
- "w": 2253.1640625,
- "h": 2071.875
}, - "actions": {
- "remove": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true
}, - "bg_overlap": 0.4,
- "mask_id": 1
}, - {
- "id": "d1b004a7b3b065aa8b98b321b67806cb3e6ca09e596ad6d3f31c625e46e168e2",
- "type": "potted plant",
- "labels": [
- "object"
], - "rect": {
- "x": 4558.125,
- "y": 2667.5390625,
- "w": 517.96875,
- "h": 725.15625
}, - "actions": {
- "remove": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true
}, - "bg_overlap": 0.67,
- "mask_id": 2
}, - {
- "id": "f173a0ad62749dbeb97f8055f51d3d125d4c9c968ee3ae46754e911f3fd12000",
- "type": "vase",
- "labels": [
- "object"
], - "rect": {
- "x": 3366.796875,
- "y": 2123.671875,
- "w": 595.6640625,
- "h": 284.8828125
}, - "actions": {
- "remove": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true
}, - "bg_overlap": 0.89,
- "mask_id": 3
}, - {
- "id": "7a3bd30a268840cc3645abf7b512c3b9b8bc2d55d98aa5f7ef8c1e72348a016c",
- "type": "potted plant",
- "labels": [
- "object"
], - "rect": {
- "x": 3263.203125,
- "y": 1398.515625,
- "w": 854.6484375,
- "h": 751.0546875
}, - "actions": {
- "remove": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true
}, - "bg_overlap": 1,
- "mask_id": 4
}, - {
- "id": "0289aaf067a6d7d812738a8d42d17e54ffd2fa79e0decbca46a873018a6d791a",
- "type": "chair",
- "labels": [
- "object"
], - "rect": {
- "x": 2900.625,
- "y": 3858.8671875,
- "w": 1502.109375,
- "h": 2486.25
}, - "actions": {
- "remove": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true
}, - "bg_overlap": 0,
- "mask_id": 5
}, - {
- "id": "0a349cbe603a786570d4eec7dd9cf64e568ef72767a5847251b32988a2b99dff",
- "type": "chair",
- "labels": [
- "object"
], - "rect": {
- "x": 647.4609375,
- "y": 3910.6640625,
- "w": 1139.53125,
- "h": 2071.875
}, - "actions": {
- "remove": [
- true
], - "replace": [
- true
]
}, - "oracle": {
- "remove": true
}, - "bg_overlap": 0.4,
- "mask_id": 6
}
]
Description
The Objects/Mask Generator Route is used to generate all possible masks for an 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 paramter 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.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
The Remove Object Route is used to remove objects or areas.
You can provide the area for removal in the following methods:
Call the /mask_generator endpoint, display the masks to the user, allow them to select a mask, and then send the mask_id to the objects/remove endpoint. Under the example named generated mask, you can see an example of this type of request.
Allow the user to create a mask manually (by using a brush, for example), and then send the mask_url to the objects/remove endpoint. Under the example named manual mask, you can see an example of this type of request. You can access the SDK that demonstrates how to implement a brush feature in your Interface via the following link.
Get the possible objects for removal using the /info or objects/info endpoint, present them to the user, and allow them to select objects for removal using the object name. Send the id of the selected object to the objects/remove endpoint. Under the example named object, you can see an example of this type of request. Since it covers only very specific elements, rather than all the elements in the image, this method is less recomended than the two above.
In one request, you may send multiple IDs of objects, or points, or masks for removal, but you cannot combine them in one request. For example, you cannot send a point and a mask_id at the same time.
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 objects/info route to obtain information on the available predefined objects in the image, the available modifications, and their Oracle values. If you are using mask_url or positive_points there is no need to call the info routes.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
Description
The Caption Route is used to get a caption that describes the given image.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "results": [
- {
- "caption": "woman walking on a bridge in the jungle"
}
]
}
Description By using the Search Route, you can utilize Bria's generative search capabilities, which don't require labels or keywords. The user can send any text query and receive relevant images that match the query. The Search Route returns the images, sorted by the match score, from highest match to lowest match. The images are returned in batches, and you can specify how many images to receive in one batch, and which batch to receive in each call. Note: To use this endpoint, please contact us at support@bria.ai.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "results": [
- {
- "visual_id": "a169a6862f24de75",
- "org_image_key": "None",
- "source_url": "None"
}
]
}
Description By using the Search Similar Images Route, you can send an image as a query and receive relevant images that are similar. The Search Similar Images Route returns the images, sorted by the similarity score, from the highest to the lowest. The images are returned in batches, and you can specify how many images to receive in one batch, and which batch to receive in each call. Note: To use this endpoint, please contact us at support@bria.ai.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
{- "results": [
- {
- "visual_id": "a169a6862f24de75",
- "org_image_key": "None",
- "source_url": "None"
}
]
}
Description
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.
Successful operation.
File hasn’t finished onboarding. Please call /info again until you get 200.
One of the details does not meet specification. Please call person/info again.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
[- {
- "actions": {
- "age": [
- "mid-20",
- "mid-40",
- "mid-60"
], - "Beard": [
- "shaved",
- "medium",
- "full"
], - "diversity": [
- "original",
- "africa",
- "korea",
- "india",
- "japan",
- "sweden",
- "germany",
- "russia",
- "mexico",
- "brazil",
- "england",
- "spain",
- "france",
- "unsplash"
], - "expression": [
- "happy",
- "surprised",
- "dreaming",
- "angry",
- "fear",
- "contempt",
- "disgusted",
- "sad",
- "smile"
], - "gender": [
- "femininity",
- "masculinity"
], - "glasses": [
- "light",
- "none",
- "heavy"
], - "hair_line": [
- "high",
- "low"
], - "haircolor": [
- "black",
- "brown",
- "red",
- "blond",
- "gray"
], - "makeup": [
- "light",
- "heavy",
- "none"
]
}, - "id:"c6bbe1cd719300c11e5c581889e9383245a0c1d923f210a3445e8ea5a25500e0"": null,
- "labels": [
- "age_14-26",
- "glasses",
- "Female"
], - "oracle": {
- "age": {
- "age": "low"
}, - "Beard": {
- "Beard": "low"
}, - "diversity": {
- "africa": "low",
- "brazil": "low",
- "england": "low",
- "france": "low",
- "germany": "low",
- "india": "low",
- "japan": "low",
- "korea": "low",
- "mexico": "low",
- "russia": "low",
- "spain": "low",
- "sweden": "low"
}, - "expression": {
- "angry": "high",
- "calm": "high",
- "contempt": "high",
- "disgusted": "high",
- "dreaming": "high",
- "fear": "high",
- "happy": "high",
- "surprised": "high"
}, - "gender": {
- "gender": "low"
}, - "glasses": {
- "glasses": "low"
}, - "hair_line": {
- "hair_line": "low"
}, - "haircolor": {
- "haircolor": "low"
}
}, - "rect": {
- "h": 375.98625326156616,
- "w": 280.4049072265625,
- "x": 1134.1341552734375,
- "y": 290.6307406425476
}, - "type:"person"": null
}, - {
- "actions": {
- "age": [
- "mid-20",
- "mid-40",
- "mid-60"
], - "Beard": [
- "shaved",
- "medium",
- "full"
], - "diversity": [
- "original",
- "africa",
- "korea",
- "india",
- "japan",
- "sweden",
- "germany",
- "russia",
- "mexico",
- "brazil",
- "england",
- "spain",
- "france",
- "unsplash"
], - "expression": [
- "happy",
- "surprised",
- "dreaming",
- "angry",
- "fear",
- "contempt",
- "disgusted",
- "sad",
- "smile"
], - "gender": [
- "femininity",
- "masculinity"
], - "glasses": [
- "light",
- "none",
- "heavy"
], - "hair_line": [
- "high",
- "low"
], - "haircolor": [
- "black",
- "brown",
- "red",
- "blond",
- "gray"
], - "makeup": [
- "light",
- "heavy",
- "none"
]
}, - "id:"d74da71f722b45de5f18f93e9dd7fc64a50a5a5dda001985ab9c2374807182b8"": null,
- "labels": [
- "age_26-42",
- "happy",
- "Female"
], - "oracle": {
- "age": {
- "age": "high"
}, - "Beard": {
- "Beard": "high"
}, - "diversity": {
- "africa": "high",
- "brazil": "high",
- "england": "high",
- "france": "high",
- "germany": "high",
- "india": "high",
- "japan": "high",
- "korea": "high",
- "mexico": "high",
- "russia": "high",
- "spain": "high",
- "sweden": "high"
}, - "expression": {
- "angry": "high",
- "calm": "high",
- "contempt": "high",
- "disgusted": "high",
- "dreaming": "high",
- "fear": "high",
- "happy": "high",
- "surprised": "high"
}, - "gender": {
- "gender": "high"
}, - "glasses": {
- "glasses": "high"
}, - "hair_line": {
- "hair_line": "high"
}, - "haircolor": {
- "haircolor": "high"
}
}, - "rect": {
- "h": 354.8530983924866,
- "w": 282.885498046875,
- "x": 555.80419921875,
- "y": 486.4655692577362
}, - "type:"person"": null
}
]
Description
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.
Successful operation.
Bad request.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.