Removebg API Reference
Integrate our high-performance AI background removal engine directly into your applications using the free removebg API.
Authentication
The removebg API uses Bearer Token authentication. You must include your API key in the Authorization header of every request. You can generate an API key in your Account Settings.
Remove Background Endpoint
Uploads an image and returns the image with the background removed as a transparent PNG.
POST
https://api.removebg.bd/api/remove-bgRemovebg API Code Examples
cURL
curl -X POST https://api.removebg.bd/api/remove-bg \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image=@/path/to/your/image.jpg" \
-o "output-no-bg.png"Node.js (Fetch)
const fs = require('fs');
async function removeBackground() {
const formData = new FormData();
formData.append('image', new Blob([fs.readFileSync('image.jpg')]));
const response = await fetch('https://api.removebg.bd/api/remove-bg', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
},
body: formData
});
if (response.ok) {
const buffer = await response.arrayBuffer();
fs.writeFileSync('output-no-bg.png', Buffer.from(buffer));
console.log("Success!");
} else {
console.error("Error:", await response.text());
}
}
removeBackground();Python (Requests)
import requests
def remove_background(image_path, output_path):
url = "https://api.removebg.bd/api/remove-bg"
headers = {
"Authorization": "Bearer YOUR_API_KEY"
}
with open(image_path, 'rb') as img_file:
files = {'image': img_file}
response = requests.post(url, headers=headers, files=files)
if response.status_code == 200:
with open(output_path, 'wb') as out_file:
out_file.write(response.content)
print("Success!")
else:
print("Error:", response.text)
remove_background('image.jpg', 'output-no-bg.png')Response Handling
On success, the removebg API returns a 200 OK status code along with the raw image binary (image/png).
Common Error Codes
- 401 Unauthorized: Invalid or missing API key.
- 400 Bad Request: No image file was provided in the form data.
- 413 Payload Too Large: The uploaded image exceeds the 20MB limit.
- 429 Too Many Requests: You have exceeded your plan's rate limit.