Bria로 이미지 편집하기
CometAPI를 통해 Bria Image Editing API를 사용하여 POST /bria/image/edit/로 erase, gen_fill, expand, enhance, upscale 또는 배경 교체를 수행합니다.
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>"
}개요
Bria의 Image Editing API는 이미지를 조작하고 향상시키기 위한 포괄적인 도구 모음을 제공합니다.request_id를 사용해 Query Status 엔드포인트를 통해 결과를 조회하세요.이 인터페이스에서는 sync 파라미터가 고정되어 있으므로 별도로 지정할 필요가 없습니다.지원되는 작업
| 작업 | 설명 | 문서 |
|---|---|---|
erase | 이미지에서 객체 제거 | Bria Erase Docs |
gen_fill | 마스킹된 영역에 대한 생성형 채우기 | Bria Gen Fill Docs |
expand | 이미지 캔버스 확장 | Bria Expand Docs |
enhance | 이미지 품질 향상 | Bria Enhance Docs |
increase_resolution | 이미지 해상도 업스케일 | Bria Upscale Docs |
replace_background | 이미지 배경 교체 | Bria Background Docs |
인증
Bearer token authentication. Use your CometAPI key.
헤더
Must be application/json.
경로 매개변수
Editing action to perform. Supported values: erase, gen_fill, expand, enhance, increase_resolution, replace_background.
본문
Source image as a public URL or base64-encoded data URI. Accepted formats: JPEG, PNG, WebP. Maximum 12 MB.
Mask image as a public URL or base64. White areas mark the region to edit; black areas are preserved. Required for erase, gen_fill, and expand actions.
Text description of the desired edit. Required for gen_fill and replace_background actions.
Number of result variants to generate. Default: 1.
When true, the response blocks until results are ready. When false (default), returns immediately with placeholder URLs that can be polled.
응답
Success
The response is of type object.
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>"
}