Overview
The ClearBG API provides powerful AI-driven background removal capabilities using the BiRefNet model. Our API is designed for developers who want to integrate professional-grade background removal into their applications, websites, or services.
🚀 Fast Processing
Process images in seconds with our optimized AI algorithms, perfect for real-time applications.
🎯 High Accuracy
Professional-grade results with fine details preserved, including hair, fur, and complex edges.
🔒 Secure & Private
Your images are processed securely and automatically deleted after processing to protect your privacy.
📱 Multiple Formats
Support for PNG, JPG, and other popular formats with transparent background options.
Base URL
https://api.clearbg.top
Authentication
Currently, the API is open and doesn't require authentication. Rate limiting may be implemented in the future.
API Endpoints
Check the health status of the API service.
Response Example
{
"status": "operational",
"timestamp": "2025-01-13T10:30:00Z",
"version": "1.0.0"
}
Remove background from an uploaded image using AI.
Parameters
image
file
Image file to process (JPG, PNG, etc.)
quality
string
Processing quality: "high", "medium", or "low" (default: "medium")
format
string
Output format: "png" or "jpg" (default: "png")
Response Example
{
"success": true,
"refined": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"white_bg": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"transparent": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...",
"processing_time": 2.5
}
Get storage status and usage information.
Response Example
{
"total_space": "100GB",
"used_space": "45GB",
"available_space": "55GB",
"file_count": 1250,
"last_cleanup": "2025-01-13T09:00:00Z"
}
Trigger storage cleanup to free up space.
Trigger emergency storage cleanup for immediate space recovery.
Quick Start
JavaScript Example
Here's a simple example of how to use the API with JavaScript:
const formData = new FormData();
formData.append('image', fileInput.files[0]);
formData.append('quality', 'high');
formData.append('format', 'png');
const response = await fetch('https://api.clearbg.top/remove-background/', {
method: 'POST',
body: formData
});
const result = await response.json();
if (result.success) {
// Use result.refined, result.white_bg, or result.transparent
console.log('Background removed successfully!');
}
Python Example
import requests
url = "https://api.clearbg.top/remove-background/"
files = {"image": open("image.jpg", "rb")}
data = {"quality": "high", "format": "png"}
response = requests.post(url, files=files, data=data)
result = response.json()
if result.get("success"):
print("Background removed successfully!")
# Process result["refined"], result["white_bg"], or result["transparent"]
cURL Example
curl -X POST "https://api.clearbg.top/remove-background/" \
-F "image=@/path/to/image.jpg" \
-F "quality=high" \
-F "format=png"
Error Handling
The API returns appropriate HTTP status codes and error messages:
- 200 OK: Request successful
- 400 Bad Request: Invalid parameters or file format
- 413 Payload Too Large: File size exceeds limits
- 500 Internal Server Error: Server-side processing error
Rate Limits
Currently, there are no rate limits imposed. However, we reserve the right to implement rate limiting in the future to ensure fair usage for all users.
File Size Limits
- Maximum file size: 10MB
- Supported formats: JPG, JPEG, PNG, WEBP
- Recommended dimensions: Up to 4096x4096 pixels
Support
For API support, questions, or feature requests, please contact us: