Background Removal API

Remove image backgrounds programmatically via API.

Overview

The Background Removal API uses advanced AI algorithms to automatically detect and remove image backgrounds, outputting transparent PNG format images. Supports various image types including people, products, and animals with hair-level precision.

Endpoint

POST https://api.aluo.ai/api/remove-bg

Request Parameters

Submit using multipart/form-data format. Two input methods supported (choose one):

ParameterTypeRequiredDescription
fileFileEitherImage file (JPG/PNG/WebP)
imageUrlstringEitherImage URL
uploadToCDNbooleanOptionalUpload to CDN (default: true)

Note: Maximum file size: 4096x4096 pixels. Supported formats: JPG, PNG, WebP.

Response Format

Success Response

{
  "code": 0,
  "success": true,
  "data": {
    "url": "https://cdn.aluo.ai/...",
    "originalFileName": "image.png",
    "processedFileName": "processed_image.png",
    "fileSize": 123456,
    "contentType": "image/png",
    "width": 1024,
    "height": 1024
  },
  "credits_deducted": 8,
  "credits_remaining": 42
}

Error Response

{
  "code": -1,
  "success": false,
  "error": "No file or imageUrl provided"
}

Example Requests

Method 1: Upload File

curl -X POST https://api.aluo.ai/api/remove-bg \
  -H "Authorization: Bearer sk-your-api-key-here" \
  -F "file=@/path/to/image.jpg"

Method 2: Use Image URL

curl -X POST https://api.aluo.ai/api/remove-bg \
  -H "Authorization: Bearer sk-your-api-key-here" \
  -F "imageUrl=https://example.com/product.jpg"

Node.js

const fs = require('fs');
const FormData = require('form-data');
const fetch = require('node-fetch');

const form = new FormData();
// 方式一:上传文件
form.append('file', fs.createReadStream('/path/to/image.jpg'));
// 方式二:使用 URL
// form.append('imageUrl', 'https://example.com/product.jpg');

const response = await fetch('https://api.aluo.ai/api/remove-bg', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk-your-api-key-here',
    ...form.getHeaders()
  },
  body: form
});

const result = await response.json();
console.log(result);

Python

import requests

headers = {
    'Authorization': 'Bearer sk-your-api-key-here'
}

# 方式一:上传文件
files = {
    'file': open('/path/to/image.jpg', 'rb')
}
response = requests.post(
    'https://api.aluo.ai/api/remove-bg',
    headers=headers,
    files=files
)

# 方式二:使用 URL
# data = {
#     'imageUrl': 'https://example.com/product.jpg'
# }
# response = requests.post(
#     'https://api.aluo.ai/api/remove-bg',
#     headers=headers,
#     data=data
# )

result = response.json()
print(result)

Credits & Processing Time

ItemFree UserPRO User
Credits Cost8 credits/image6 credits/image
Processing TimeUsually 10-30 seconds

Common Errors

Error MessageCauseSolution
No file or imageUrl providedNo image providedMust provide either file or imageUrl
Insufficient creditsNot enough creditsRecharge credits or upgrade to PRO
Authentication requiredInvalid API KeyCheck Authorization header