The Bria API was designed for users to interact with the BriEngine, creating new images and videos with specific requests. This document will outline the capabilities of the API and explain to users how to implement it.
The common use of the Bria API is according to the following order:
With the response from the Upload Route, the following routes can be used without any particular order:
With the response from the Info Route, the following route can be used without any particular order:
The following route can be used at any moment:
The current version of the web API is known as V2 and is considered to be in a draft phase. While we don’t expect public endpoints to materially change, please bear in mind that the API is still under development.
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 'http://bria-api.com:5000/v2' \
--header: 'api_token: <...>' \
--header: 'api_secret: <...>' \
...
You can access the API Token and API Secret through Bria's platform by clicking here.
For a full example of the Bria API usage, using python code, please check this link.
Description
The Upload Route is used to upload visuals to the database.
This route returns a visual identification to the user. It's the first step for consuming the Bria API for new visuals.
Response
The visual id in the response of the Upload Route must be kept by the user in order to query image info and make changes to it
{ "visual_id": "9ea9a4d2d19977a7c" }
The visual_id in the response of the /upload route can be used for all other routes.
Bria generative Web tool
The uploaded visual can be seen and used in the Bria generative web tool in cases where the tool is licensed as part of the project.
To do so, the user can access the following url: https://labs.bria.ai/tools/{visual_id}
, where the {visual_id} comes from the response of the /upload route.
In Bria's web tool, the user has the ability to make many changes to the visual and also generate live videos, using an intuitive interactive platform.
Bria's web tool can also be embedded in other websites, with the use of an iframe HTML element:
Constraints
Files should not be larger than 12MB. The status code 413 will be returned if the file exceeds its maximum size.
Bria API currently only supports JPEG files. The status code 415 will be returned if the file is of a different type.
Successful operation.
File value was not provided.
File already uploaded.
Request doesn't contain file part.
Method not allowed.
Request entity too large.
Unsupported media type.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
curl -i -X POST \ http://bria-api.com:5000/v2/upload \ -H 'Content-Type: multipart/form-data' \ -F file=string
{- "visual_id": "string"
}
Description
The Info Route is used to retrieve useful information on a specific visual that was previously uploaded to the database.
Additionally, it provides a description of each object and element within the scene along with its available changes, which are supported by the Bria API.
Successful operation.
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.
curl -i -X GET \ 'http://bria-api.com:5000/v2/{visual_id}/info'
{- "description": "Coming Soon",
- "scene": [
- {
- "id": "a48284e4832c809e4475ad5de7bdd333658e363b417a28991022a6fa79488a6b",
- "type": "person",
- "labels": [
- "age_22-34",
- "calm",
- "Male"
], - "actions": {
- "age": [
- "mid-20",
- "mid-40",
- "mid-60"
], - "diversity": [
- "africa",
- "korea",
- "india",
- "japan",
- "sweden",
- "germany",
- "russia",
- "mexico",
- "brazil"
], - "expression": [
- "happy",
- "calm",
- "surprised",
- "dreaming",
- "angry"
], - "glasses": [
- "light",
- "heavy",
- "none"
], - "haircolor": [
- "black",
- "brown",
- "red",
- "blond",
- "gray"
], - "gender": [
- "femininity",
- "masculinity"
], - "makeup": [
- "light",
- "heavy",
- "none"
], - "hair_line": [
- "high",
- "low"
], - "beard": [
- "shaved",
- "medium",
- "full"
]
}
}
]
}
Description
The Create Route is used to create a new visual, based on the changes requested by the user for a previously uploaded visual.
The Create Route will return the url for accessing the new generated visual and the confidence that Bria has in the quality of the new visual.
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.
curl -i -X POST \ 'http://bria-api.com:5000/v2/{visual_id}/create' \ -H 'Content-Type: application/json' \ -d '{ "changes": [ { "id": "a48284e4832c809e4475ad5de7bdd333658e363b417a28991022a6fa79488a6b", "actions": { "age": "mid-60", "diversity": "france", "expression": "happy", "glasses": "light", "haircolor": "brown", "gender": "masculinity", "makeup": "none", "hair_line": "high", "beard": "medium" } } ] }'
Description
The Remove BG Route is used to remove the background of a previously uploaded image.
This route can also be used on an image that has been changed by the user using the /create route.
The Remove BG Route will return the URL for accessing 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.
curl -i -X POST \ 'http://bria-api.com:5000/v2/{visual_id}/remove_bg?visual_url=string'
Description
The Video Route is used to create a new video, based on a previously uploaded single still image.
This route can also be used on an image that has been changed by the user using the /create route.
The Video Route will return the URL for accessing the new generated video and the confidence that Bria has in the quality of this video.
Array of objects The requested change to the selected visual or object. |
Successful operation.
Either pace
or duration
are required.
Specified Image does not exist.
Method not allowed.
Internal server error.
Insufficient data. The given input is not supported by the Bria API.
curl -i -X POST \ 'http://bria-api.com:5000/v2/{visual_id}/video?visual_url=string' \ -H 'Content-Type: application/json' \ -d '{ "changes": [ { "id": "string", "actions": { "zoom": { "type": "zoom_in", "focus_area": "center_middle", "video_depth": "shallow", "boomerang_loop": false, "pace": "medium", "duration": 5 }, "hover": { "start_area": "top_left", "end_area": "center_middle", "video_depth": "shallow", "boomerang_loop": false, "pace": "medium", "duration": 5 }, "smart_zoom": { "boomerang_loop": false, "pace": "medium", "duration": 5 } } } ] }'
{- "video_response": "string",
- "confidence": "string"
}