Remove Background
The Remove Background service accurately segments the foreground from an image and implements and removes the background.
Credits
The service uses 4 credits per successful result. You will not be charged for failed results.
Example Request and Response
API Documentation
API Endpoint | Method |
---|---|
/api/edit/remove-background | POST |
Request Header
Parameter | Description |
---|---|
Authentication | Use your API key to authentication requests to this App. |
Request Body
The request should include a JSON object in the body with the following parameters:
Parameter | Type | Required | Description |
---|---|---|---|
image | string <binary> | Yes | apiIntroduction.removeKeyImage |
Response Body
The response should include a JSON object in the body with the following parameters:
Parameter | Type | Description |
---|---|---|
code | int | Status Code, 0 for success callback, -1 for failure callback |
message | string | Callback message, 'success' for success, failure reason for failure |
data | object | Image Details |
Image Details
Parameter | Type | Description |
---|---|---|
image | string | Return the base64 encoded image of the generated picture. |
seed | int | The seed used as random noise for this generation. |
Example Request
import requests
response = requests.post(
f"https://www.aithriving.com/api/edit/remove-background",
headers={
"authorization": f"your-auth-token"
},
files={
"image": open("./your-image.png", "rb")
},
data={
"output_format": "webp"
},
)
if response.status_code == 200:
data = response.json()
if data['code'] == 0:
// image: data['data']['image']
else:
// error
else:
raise Exception(str(response.json()))
Example Response
{
"code": 0,
"message": "success",
"data": "base64 encoded image data"
}