Remove Background: Multiple Variants

Generate multiple output versions from a single image in one request.

This example generates 3 variants in one API call:

  • full — 12MP PNG, transparent background, high quality
  • thumbnail — 0.25MP WebP, auto-cropped to object
  • white_bg — 12MP JPG with white background
import requests

API_KEY = "YOUR_API_KEY"

# Get token with multiple output variants
token_response = requests.post(
    "https://backgroundcut.co/api/v3/remove-bg/token/",
    headers={
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json"
    },
    json={
        "output_variants": [
            {
                "variant_name": "full",
                "max_resolution": 12000000,
                "format": "png",
                "quality": "high"
            },
            {
                "variant_name": "thumbnail",
                "max_resolution": 250000,
                "format": "webp",
                "quality": "medium",
                "autocrop": True
            },
            {
                "variant_name": "white_bg",
                "max_resolution": 12000000,
                "format": "jpg",
                "background_color": "#ffffff",
                "output_compression": 85
            }
        ]
    },
    timeout=60
)
token_response.raise_for_status()
access_token = token_response.json()["access_token"]

# Send image
with open("photo.jpg", "rb") as f:
    result = requests.post(
        "https://api.backgroundcut.co/v3/remove-bg/",
        files={"image": f},
        data={"token": access_token},
        timeout=300
    )

result.raise_for_status()
output = result.json()

# Each variant is available under its name
print("Full PNG:", output["output_urls"]["full"])
print("Thumbnail:", output["output_urls"]["thumbnail"])
print("White BG:", output["output_urls"]["white_bg"])
Response
{
    "status": "success",
    "unique_filename": "abc123-def456-...",
    "input_url": "https://...",
    "output_urls": {
        "full": "https://...result.png",
        "thumbnail": "https://...result.webp",
        "white_bg": "https://...result.jpg"
    }
}
Variant Options Reference
variant_name *Required. Your identifier for this variant.
max_resolutionDefault: 12000000 (12MP). Range: 250,000 to 25,000,000.
formatDefault: png. Options: png, jpg, webp
background_colorDefault: transparent. Hex like #ffffff or transparent.
qualityDefault: high. Options: high, medium, low
output_compressionDefault: 90. Range: 1–100 (for jpg/webp).
autocropDefault: false. Crop to object bounds (+0.5 credits).