STEP 1
pip install requests
STEP 2
import requests
API_URL = (
"https://api.bybybg.com/v1/remove-bg"
)
API_KEY = "YOUR_API_KEY"
with open("image.jpg", "rb") as image:
response = requests.post(
API_URL,
headers={
"X-API-Key": API_KEY
},
files={
"file": image
}
)
if response.status_code == 200:
with open("no-bg.png", "wb") as f:
f.write(response.content)
print("Background removed")
else:
print(
response.status_code,
response.text
)
USE CASES
BEST PRACTICES
ERRORS
Status
Description
401
413
429
500