AI Eraser
Remove unwanted objects from images with AI precision. Upload an image and mask to seamlessly erase specific areas while maintaining natural-looking results.
Credit Cost
Each AI Eraser request costs 1 credit. Ensure you have sufficient credits before making requests.
Endpoint
HTTP Method
POST https://api.mnmlai.dev/v1/ai-eraserRequest
Send a POST request with multipart/form-data containing your image and mask files for precise object removal.
Required Parameters
| Parameter | Type | Description |
|---|---|---|
image | File | The original image from which objects will be removed (multipart/form-data) |
mask | File | A mask image indicating which areas to erase (white areas = erase, black areas = keep) |
Optional Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
output_format | String | "png" | Output image format: "png" | "jpg" | "jpeg" |
Response
The AI Eraser endpoint processes your image asynchronously. You'll receive a request ID that you can use to check the status and retrieve the processed image.
Success Response (200 OK)
{
"status": "success",
"id": "era_1703123456789_abc12345"
}Examples
Basic Example
curl -X POST https://api.mnmlai.dev/v1/ai-eraser \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F "image=@/path/to/image.jpg" \
-F "mask=@/path/to/mask.png"Advanced Example with Output Format
curl -X POST https://api.mnmlai.dev/v1/ai-eraser \
-H "Accept: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F "image=@/path/to/image.jpg" \
-F "mask=@/path/to/mask.png" \
-F "output_format=jpg"Node.js Example
const FormData = require('form-data');
const fs = require('fs');
const axios = require('axios');
const form = new FormData();
form.append('image', fs.createReadStream('image.jpg'));
form.append('mask', fs.createReadStream('mask.png'));
form.append('output_format', 'png');
const response = await axios.post(
'https://api.mnmlai.dev/v1/ai-eraser',
form,
{
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
...form.getHeaders()
}
}
);
console.log('Request ID:', response.data.id);Python Example
import requests
url = 'https://api.mnmlai.dev/v1/ai-eraser'
files = {
'image': open('image.jpg', 'rb'),
'mask': open('mask.png', 'rb')
}
data = {
'output_format': 'png'
}
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY'
}
response = requests.post(url, headers=headers, files=files, data=data)
result = response.json()
print(f"Request ID: {result['id']}")Processing Status
After submitting your request, use the Status Check endpoint with the returned ID to monitor processing progress:
Status Check Endpoint
GET https://api.mnmlai.dev/v1/status/{id}Best Practices
Image Requirements
- • Use high-quality images for best results (minimum 256px width)
- • Ensure the image and mask have the same dimensions
- • Supported formats: JPG, PNG, GIF (max 8MB each)
- • Images are automatically resized to 1024px width for processing
Mask Creation Tips
- • Use white areas to mark objects you want to remove
- • Use black areas to mark areas you want to keep
- • Create precise masks for better results
- • Avoid very small or very large mask areas
Processing Tips
- • Use PNG format for masks to ensure precise boundaries
- • Choose appropriate output format based on your needs
- • Test with smaller images first to optimize your workflow
- • Each request costs 5 credits, so plan accordingly
Error Handling
Common Error Responses
// 400 Bad Request - Missing required parameters
{
"status": "error",
"code": "MISSING_IMAGE",
"message": "Image file is required"
}
// 400 Bad Request - Missing mask
{
"status": "error",
"code": "MISSING_MASK",
"message": "Mask image is required"
}
// 400 Bad Request - Insufficient credits
{
"status": "error",
"code": "NO_CREDITS",
"message": "You do not have enough credits to use this feature",
"details": {
"credits": 2
}
}
// 400 Bad Request - Invalid image type
{
"status": "error",
"code": "INVALID_IMAGE_TYPE",
"message": "Invalid image type",
"details": {
"receivedType": "image/bmp",
"allowedTypes": ["image/jpeg", "image/png", "image/gif"]
}
}
// 400 Bad Request - Image too large
{
"status": "error",
"code": "IMAGE_TOO_LARGE",
"message": "Image file is too large",
"details": {
"size": 10485760,
"maxSize": 8388608,
"unit": "bytes"
}
}
// 401 Unauthorized - Invalid API key
{
"status": "error",
"code": "UNAUTHORIZED",
"message": "User ID not found in request"
}
// 500 Internal Server Error
{
"status": "error",
"code": "INTERNAL_SERVER_ERROR",
"message": "An unexpected error occurred",
"details": {
"error": "Error message",
"timestamp": "2024-01-01T00:00:00.000Z"
}
}Related Endpoints
Explore other AI-powered image processing tools: