Edit images with Bria
Use Bria Image Editing API via CometAPI to erase, gen_fill, expand, enhance, upscale, or replace backgrounds with POST /bria/image/edit/.
POST
/
bria
/
image
/
edit
/
{action}
cURL
curl https://api.cometapi.com/bria/image/edit/replace_background \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/source.jpg",
"prompt": "in a cozy living room"
}'import os
import requests
# Replace replace_background with the action you need: erase, gen_fill,
# increase_resolution, remove_background, ...
response = requests.post(
"https://api.cometapi.com/bria/image/edit/replace_background",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/source.jpg",
"prompt": "in a cozy living room",
},
)
task = response.json()
print(task["request_id"]) # poll GET /bria/{request_id} until status COMPLETED
// Replace replace_background with the action you need: erase, gen_fill,
// increase_resolution, remove_background, ...
const response = await fetch("https://api.cometapi.com/bria/image/edit/replace_background", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
image: "https://your-image-host/source.jpg",
prompt: "in a cozy living room",
}),
});
const task = await response.json();
console.log(task.request_id); // poll GET /bria/{request_id} until status COMPLETED
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/bria/image/edit/{action}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png',
'mask' => 'https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/bria/image/edit/{action}"
payload := strings.NewReader("{\n \"image\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png\",\n \"mask\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/bria/image/edit/{action}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png\",\n \"mask\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/bria/image/edit/{action}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png\",\n \"mask\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png\"\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<request_id>"
}Overview
Bria’s Image Editing API provides a comprehensive suite of tools for manipulating and enhancing images.After a successful API call, use the returned
request_id to query results via the Query Status endpoint.The sync parameter is fixed on this interface — you do not need to specify it.Supported operations
| Operation | Description | Documentation |
|---|---|---|
erase | Remove objects from images | Bria Erase Docs |
gen_fill | Generative fill for masked areas | Bria Gen Fill Docs |
expand | Expand image canvas | Bria Expand Docs |
enhance | Enhance image quality | Bria Enhance Docs |
increase_resolution | Upscale image resolution | Bria Upscale Docs |
replace_background | Replace image background | Bria Background Docs |
Path Parameters
Body
application/json
Response
200 - application/json
Success
The response is of type object.
Last modified on October 15, 2026
⌘I
cURL
curl https://api.cometapi.com/bria/image/edit/replace_background \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"image": "https://your-image-host/source.jpg",
"prompt": "in a cozy living room"
}'import os
import requests
# Replace replace_background with the action you need: erase, gen_fill,
# increase_resolution, remove_background, ...
response = requests.post(
"https://api.cometapi.com/bria/image/edit/replace_background",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"image": "https://your-image-host/source.jpg",
"prompt": "in a cozy living room",
},
)
task = response.json()
print(task["request_id"]) # poll GET /bria/{request_id} until status COMPLETED
// Replace replace_background with the action you need: erase, gen_fill,
// increase_resolution, remove_background, ...
const response = await fetch("https://api.cometapi.com/bria/image/edit/replace_background", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
image: "https://your-image-host/source.jpg",
prompt: "in a cozy living room",
}),
});
const task = await response.json();
console.log(task.request_id); // poll GET /bria/{request_id} until status COMPLETED
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/bria/image/edit/{action}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'image' => 'https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png',
'mask' => 'https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/bria/image/edit/{action}"
payload := strings.NewReader("{\n \"image\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png\",\n \"mask\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.cometapi.com/bria/image/edit/{action}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"image\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png\",\n \"mask\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/bria/image/edit/{action}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"image\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png\",\n \"mask\": \"https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png\"\n}"
response = http.request(request)
puts response.read_body{
"request_id": "<request_id>"
}