What can you do with it?

The /image-background-removal command enables you to automatically remove backgrounds from images using the advanced 851-labs background remover model. You can isolate subjects from photos, create transparent backgrounds for product images, prepare images for compositing, generate cutouts for graphic design, and clean up photos for professional use without manual editing.

How to use it?

Basic Command Structure

/image-background-removal [image]

Parameters

Required:
  • image - The image to process (URL or uploaded file)
Optional:
  • threshold - Threshold for hard segmentation: 0.0-1.0 (defaults to 0). If 0.0, uses soft alpha
  • reverse - If true, remove the foreground instead of the background (boolean, defaults to false)
  • background_type - Background type (defaults to “rgba”). Options: ‘rgba’, ‘map’, ‘green’, ‘white’, [R,G,B] array, ‘blur’, ‘overlay’, or path to an image
  • format - Output format (defaults to “png”). Examples: png, jpg
  • fileLinksExpireInDays - How long generated files remain accessible: 1-7 days (defaults to 7)
  • fileLinksExpireInMinutes - How long generated files remain accessible in minutes (takes precedence over days)

Response Format

The command returns:
{
    "output": [
        {
            "url": "https://generated-file-url",
            "mimeType": "image/png"
        }
    ]
}
Note: All processed images are automatically saved to your “Multimedia Artifact” file store and will be accessible for the duration specified by the fileLinksExpireInDays parameter.

Examples

Basic Background Removal

/image-background-removal
image: portrait-photo.jpg
Removes the background from a portrait photo, leaving only the subject with transparent background.

Product Photography

/image-background-removal
image: product-shoe.jpg
format: png
background_type: rgba
threshold: 0
Creates a clean product cutout with transparent background perfect for e-commerce listings.

White Background Replacement

/image-background-removal
image: model-headshot.jpg
background_type: white
format: jpg
threshold: 0.1
Replaces the original background with a clean white background for professional headshots.

Green Screen Effect

/image-background-removal
image: person-portrait.png
background_type: green
format: png
Replaces the background with green color for chroma key compositing in video editing.

Foreground Removal (Reverse)

/image-background-removal
image: landscape-with-person.jpg
reverse: true
background_type: rgba
format: png
Removes the foreground subject instead of the background, useful for creating background plates.

Custom Color Background

/image-background-removal
image: pet-photo.jpg
background_type: [135, 206, 235]
format: jpg
Sets a custom sky blue background using RGB values [135, 206, 235].

Blur Background Effect

/image-background-removal
image: group-photo.jpg
background_type: blur
format: jpg
threshold: 0.05
Creates a portrait mode effect by blurring the background while keeping subjects sharp.

Batch Processing Setup

/image-background-removal
image: team-member-1.jpg
format: png
background_type: rgba
fileLinksExpireInDays: 7
Processes team photos for website use with consistent transparent backgrounds that remain accessible for a week.

Notes

Model Capabilities:
  • High-quality edge detection and preservation
  • Supports various background replacement options
  • Excellent for both portrait and product photography
  • Fast processing (typically 5-15 seconds)
  • Handles complex subjects like hair and fur
Supported Image Formats:
  • Input: JPEG/JPG, PNG, WebP, GIF
  • Output: PNG (for transparency), JPG (for solid backgrounds)
Best Practices:
  • Use PNG format for transparent backgrounds
  • Use JPG for solid color backgrounds to reduce file size
  • Higher threshold values create harder edges
  • Lower threshold values (including 0) create softer, more natural edges
  • Works best with clear subject-background contrast
Limitations:
  • Processing time may vary based on image complexity
  • Very fine details like hair may require manual touch-up
  • Performance depends on lighting and contrast in original image

Model Parameters (851-labs/background-remover)

Background Removal Parameters

  • image (required): Input image (URI format)
  • threshold: Threshold for hard segmentation (0.0-1.0, default: 0). If 0.0, uses soft alpha
  • reverse: If true, remove the foreground instead of the background (boolean, default: false)
  • background_type: Background type (default: “rgba”). Options: ‘rgba’, ‘map’, ‘green’, ‘white’, [R,G,B] array, ‘blur’, ‘overlay’, or path to an image
  • format: Output format (default: “png”). Examples: png, jpg