Skip to content

Background Removal Pro

AI-powered background removal, replacement, blur, and shadow effects. Uses FOTOhub's deep learning segmentation for pixel-perfect subject isolation with clean edges, even for complex subjects like hair, fur, and transparent objects.

All endpoints accept image URLs and return processed image URLs. Results are stored for 24 hours.

Endpoints

EndpointDescriptionCredits
POST /v1/images/remove-backgroundAuto remove background2
POST /v1/images/remove-background/advancedRemove with click points and edge controls4
POST /v1/images/replace-backgroundRemove + replace with color/gradient/image/prompt4
POST /v1/images/blur-backgroundKeep subject, blur background (bokeh)2
POST /v1/images/add-shadowAdd shadow to transparent PNG2

Authentication: Bearer token (API key)
Base URL: https://apis.fotohub.app


Remove Background

POST /v1/images/remove-background

Automatically detects and segments the main subject, removing the background and returning a transparent PNG. No manual input needed — fully automatic one-click operation.

Parameters

ParameterTypeRequiredDefaultDescription
image_urlstringYesURL of the image to process. Must be publicly accessible. Supports JPEG, PNG, WebP. Max 50MB.
output_formatstringNopngOutput format: png (with transparency), webp (smaller file size with transparency).

Response

json
{
  "output_url": "https://s1.fotohub.app/storage/v1/object/public/photos/gpu-outputs/remover/a1b2c3d4e5f6.png",
  "credits_used": 2,
  "billing": {
    "method": "credits",
    "credits_used": 2,
    "usd_charged": 0,
    "pln_charged": 0
  },
  "size_bytes": 1548290,
  "processing_time_ms": 2340
}

Reading the billing block

method is credits while your plan's monthly allowance covers the request, and usd_charged is 0 because no money moved. Once the allowance is exhausted the same call returns "method": "wallet" with the USD amount in usd_charged (see Pricing). pln_charged is a legacy mirror of the same charge -- read usd_charged.

Code Examples

python
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_your_api_key")

result = client.images.remove_background(
    image_url="https://example.com/photo.jpg"
)

print(f"Transparent image: {result.output_url}")
print(f"Credits used: {result.credits_used}")
typescript
import { FotoHub } from "fotohub";

const client = new FotoHub({ apiKey: "fh_live_your_api_key" });

const result = await client.images.removeBackground({
  imageUrl: "https://example.com/photo.jpg",
});

console.log(`Transparent image: ${result.outputUrl}`);
console.log(`Credits used: ${result.creditsUsed}`);
bash
curl -X POST "https://apis.fotohub.app/v1/images/remove-background" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/photo.jpg"
  }'

Remove Background (Advanced)

POST /v1/images/remove-background/advanced

Fine-grained background removal with click points for subject hints and edge processing controls. Use when automatic detection needs guidance (multiple subjects, complex scenes, or specific selection needed).

Parameters

ParameterTypeRequiredDefaultDescription
image_urlstringYesURL of the image to process. Must be publicly accessible. Max 50MB.
pointsarrayNo[]Click points to guide segmentation. Each point has x (0-1), y (0-1), and label (1=foreground, 0=background).
featherintegerNo2Edge feathering radius in pixels (0-20). Higher values create softer edges.
smoothintegerNo0Edge smoothing passes (0-10). Reduces jagged edges on complex subjects.
shift_edgeintegerNo0Shift edge inward (negative) or outward (positive), range -10 to 10. Use negative values to remove background fringe.
decontaminatebooleanNofalseRemove color bleeding from background at edges. Useful for subjects photographed against colored backgrounds.
output_formatstringNopngOutput format: png, webp.

Points Array Format

Each point in the points array specifies a location and whether it belongs to the subject or background:

json
{
  "points": [
    {"x": 0.5, "y": 0.3, "label": 1},
    {"x": 0.1, "y": 0.1, "label": 0},
    {"x": 0.9, "y": 0.9, "label": 0}
  ]
}
  • x, y: Normalized coordinates (0.0 = top-left, 1.0 = bottom-right)
  • label: 1: This point is on the subject (foreground) — include it
  • label: 0: This point is on the background — exclude it

Tips:

  • Start with 1-2 foreground points on the main subject
  • Add background points to exclude unwanted areas
  • More points = more precise segmentation

Response

json
{
  "output_url": "https://s1.fotohub.app/storage/v1/object/public/photos/gpu-outputs/remover/x9y8z7w6.png",
  "credits_used": 4,
  "billing": {
    "method": "credits",
    "credits_used": 4,
    "usd_charged": 0,
    "pln_charged": 0
  },
  "size_bytes": 2105384,
  "processing_time_ms": 3120,
  "parameters": {
    "points_used": 3,
    "feather": 2,
    "smooth": 1,
    "shift_edge": -1,
    "decontaminate": true
  }
}

Code Examples

python
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_your_api_key")

result = client.images.remove_background_advanced(
    image_url="https://example.com/group-photo.jpg",
    points=[
        {"x": 0.3, "y": 0.5, "label": 1},   # Person on left
        {"x": 0.7, "y": 0.5, "label": 1},   # Person on right
        {"x": 0.5, "y": 0.05, "label": 0},  # Sky (background)
    ],
    feather=3,
    smooth=1,
    shift_edge=-1,
    decontaminate=True,
)

print(f"Output: {result.output_url}")
print(f"Points used: {result.parameters['points_used']}")
typescript
import { FotoHub } from "fotohub";

const client = new FotoHub({ apiKey: "fh_live_your_api_key" });

const result = await client.images.removeBackgroundAdvanced({
  imageUrl: "https://example.com/group-photo.jpg",
  points: [
    { x: 0.3, y: 0.5, label: 1 },   // Person on left
    { x: 0.7, y: 0.5, label: 1 },   // Person on right
    { x: 0.5, y: 0.05, label: 0 },  // Sky (background)
  ],
  feather: 3,
  smooth: 1,
  shiftEdge: -1,
  decontaminate: true,
});

console.log(`Output: ${result.outputUrl}`);
console.log(`Points used: ${result.parameters.pointsUsed}`);
bash
curl -X POST "https://apis.fotohub.app/v1/images/remove-background/advanced" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/group-photo.jpg",
    "points": [
      {"x": 0.3, "y": 0.5, "label": 1},
      {"x": 0.7, "y": 0.5, "label": 1},
      {"x": 0.5, "y": 0.05, "label": 0}
    ],
    "feather": 3,
    "smooth": 1,
    "shift_edge": -1,
    "decontaminate": true
  }'

Replace Background

POST /v1/images/replace-background

Removes the background and replaces it with a new one in a single API call. Supports solid colors, gradients, background images, and AI-generated backgrounds from a text prompt.

Parameters

ParameterTypeRequiredDefaultDescription
image_urlstringYesURL of the image to process. Max 50MB.
backgroundstringYesNew background. Accepts: hex color (#ffffff), CSS gradient (linear-gradient(#000, #fff)), image URL (https://...), or AI prompt text.
background_typestringNoautoExplicit type: color, gradient, image, prompt. If auto, type is detected from the background value.
featherintegerNo2Edge feathering radius (0-20).
output_formatstringNopngOutput: png, jpeg, webp. Use jpeg for opaque backgrounds (smaller file).

Background Types

TypeExample background valueDescription
color#f5f5f5 or #000000Solid color fill behind subject
gradientlinear-gradient(180deg, #667eea, #764ba2)CSS-style gradient
imagehttps://example.com/office-bg.jpgReplace with another image
promptProfessional studio with soft bokeh lightsAI-generates a background from text

Response

json
{
  "output_url": "https://s1.fotohub.app/storage/v1/object/public/photos/gpu-outputs/remover/composed123.png",
  "transparent_url": "https://s1.fotohub.app/storage/v1/object/public/photos/gpu-outputs/remover/transparent456.png",
  "background_type": "color",
  "credits_used": 4,
  "billing": {
    "method": "credits",
    "credits_used": 4,
    "usd_charged": 0,
    "pln_charged": 0
  },
  "processing_time_ms": 4200
}
FieldDescription
output_urlFinal composited image with new background
transparent_urlSubject on transparent background (bonus output)
background_typeDetected or specified background type

Code Examples

python
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_your_api_key")

# Solid color background
result = client.images.replace_background(
    image_url="https://example.com/product.jpg",
    background="#ffffff",
)

# AI-generated background from prompt
result = client.images.replace_background(
    image_url="https://example.com/portrait.jpg",
    background="Modern office with floor-to-ceiling windows, soft natural light, blurred city skyline",
    background_type="prompt",
)

# Use another image as background
result = client.images.replace_background(
    image_url="https://example.com/model.jpg",
    background="https://example.com/beach-sunset.jpg",
    background_type="image",
)

print(f"Result: {result.output_url}")
print(f"Transparent: {result.transparent_url}")
typescript
import { FotoHub } from "fotohub";

const client = new FotoHub({ apiKey: "fh_live_your_api_key" });

// Solid color background
const result = await client.images.replaceBackground({
  imageUrl: "https://example.com/product.jpg",
  background: "#ffffff",
});

// AI-generated background
const result2 = await client.images.replaceBackground({
  imageUrl: "https://example.com/portrait.jpg",
  background: "Modern office with floor-to-ceiling windows and soft light",
  backgroundType: "prompt",
});

console.log(`Result: ${result.outputUrl}`);
console.log(`Transparent: ${result.transparentUrl}`);
bash
# Solid white background
curl -X POST "https://apis.fotohub.app/v1/images/replace-background" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/product.jpg",
    "background": "#ffffff"
  }'

# AI prompt background
curl -X POST "https://apis.fotohub.app/v1/images/replace-background" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/portrait.jpg",
    "background": "Professional studio with soft gradient lighting",
    "background_type": "prompt"
  }'

Blur Background

POST /v1/images/blur-background

Keeps the main subject in sharp focus while applying Gaussian blur to the background. Creates a professional depth-of-field (bokeh) effect without needing a portrait-mode camera.

Parameters

ParameterTypeRequiredDefaultDescription
image_urlstringYesURL of the image to process. Max 50MB.
blur_radiusintegerNo15Gaussian blur radius (1-50). Higher = more blur. 5-10 for subtle, 15-25 for portrait, 30-50 for extreme.
featherintegerNo2Edge feathering between sharp subject and blurred background (0-20).
output_formatstringNojpegOutput: png, jpeg, webp. JPEG recommended (no transparency needed).

Response

json
{
  "output_url": "https://s1.fotohub.app/storage/v1/object/public/photos/gpu-outputs/remover/blurred789.jpg",
  "credits_used": 2,
  "billing": {
    "method": "credits",
    "credits_used": 2,
    "usd_charged": 0,
    "pln_charged": 0
  },
  "blur_radius": 15,
  "processing_time_ms": 2800
}

Code Examples

python
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_your_api_key")

result = client.images.blur_background(
    image_url="https://example.com/street-photo.jpg",
    blur_radius=20,
    feather=3,
)

print(f"Bokeh result: {result.output_url}")
typescript
import { FotoHub } from "fotohub";

const client = new FotoHub({ apiKey: "fh_live_your_api_key" });

const result = await client.images.blurBackground({
  imageUrl: "https://example.com/street-photo.jpg",
  blurRadius: 20,
  feather: 3,
});

console.log(`Bokeh result: ${result.outputUrl}`);
bash
curl -X POST "https://apis.fotohub.app/v1/images/blur-background" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/street-photo.jpg",
    "blur_radius": 20,
    "feather": 3
  }'

Add Shadow

POST /v1/images/add-shadow

Adds a realistic shadow to a transparent PNG image. Supports natural (AI-detected lighting direction), drop shadow, and contact shadow types. Input must have an alpha channel (transparent background).

Parameters

ParameterTypeRequiredDefaultDescription
image_urlstringYesURL of a transparent PNG image. Must have alpha channel.
shadow_typestringNonaturalShadow style: natural (AI analyzes subject shape and lighting), drop (simple offset shadow), contact (shadow at bottom edge only).
shadow_opacityfloatNo0.5Shadow opacity, 0.0 (invisible) to 1.0 (fully opaque).
shadow_offset_xintegerNo0Horizontal shadow offset in pixels (-50 to 50).
shadow_offset_yintegerNo10Vertical shadow offset in pixels (-50 to 50).
shadow_blurintegerNo10Shadow blur radius (0-50). 0 = hard shadow, 50 = very soft.
shadow_colorstringNo#000000Shadow color as hex code.
output_formatstringNopngOutput format: png, webp. PNG recommended to preserve transparency.

Shadow Types

TypeDescriptionBest for
naturalAI analyzes subject shape to determine realistic shadow direction and softnessProduct photos, people, objects with clear form
dropClassic drop shadow with configurable offset and blurFlat design, icons, UI elements
contactShadow only at the base/bottom of the subjectProducts on surfaces, standing objects

Response

json
{
  "output_url": "https://s1.fotohub.app/storage/v1/object/public/photos/gpu-outputs/remover/shadow456.png",
  "credits_used": 2,
  "billing": {
    "method": "credits",
    "credits_used": 2,
    "usd_charged": 0,
    "pln_charged": 0
  },
  "shadow_type": "natural",
  "processing_time_ms": 1850
}

Code Examples

python
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_your_api_key")

# Natural shadow (AI-detected lighting)
result = client.images.add_shadow(
    image_url="https://example.com/product-transparent.png",
    shadow_type="natural",
    shadow_opacity=0.4,
)

# Drop shadow with custom offset
result = client.images.add_shadow(
    image_url="https://example.com/icon-transparent.png",
    shadow_type="drop",
    shadow_offset_x=5,
    shadow_offset_y=8,
    shadow_blur=12,
    shadow_opacity=0.3,
    shadow_color="#1a1a2e",
)

print(f"With shadow: {result.output_url}")
typescript
import { FotoHub } from "fotohub";

const client = new FotoHub({ apiKey: "fh_live_your_api_key" });

// Natural shadow
const result = await client.images.addShadow({
  imageUrl: "https://example.com/product-transparent.png",
  shadowType: "natural",
  shadowOpacity: 0.4,
});

// Contact shadow for product on surface
const result2 = await client.images.addShadow({
  imageUrl: "https://example.com/shoe-transparent.png",
  shadowType: "contact",
  shadowBlur: 15,
  shadowOpacity: 0.6,
});

console.log(`With shadow: ${result.outputUrl}`);
bash
curl -X POST "https://apis.fotohub.app/v1/images/add-shadow" \
  -H "Authorization: Bearer fh_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://example.com/product-transparent.png",
    "shadow_type": "natural",
    "shadow_opacity": 0.4
  }'

Pricing

EndpointCreditsUSD
Remove Background (auto)2$0.1072
Remove Background (advanced)4$0.2144
Replace Background4$0.2144
Blur Background2$0.1072
Add Shadow2$0.1072

Billing notes:

  • 1 credit = $0.0536
  • Credits are deducted before processing. If processing fails, credits are refunded automatically.
  • All operations are single-image (no batch endpoint). For batch processing, call the endpoint multiple times.
  • USD wallet billing is used when credits are exhausted, up to your overage limit.

Rate Limits

Rate limits depend on your subscription tier:

Per-Tier Limits

EndpointFreeCreator (29 PLN/mo)Pro (79 PLN/mo)Business (199 PLN/mo)Enterprise
remove-background5/min20/min60/min200/minCustom
remove-background/advanced5/min20/min60/min200/minCustom
replace-background3/min15/min50/min150/minCustom
blur-background5/min20/min60/min200/minCustom
add-shadow5/min20/min60/min200/minCustom

Monthly Credits Included

TierMonthly CreditsBG Removals (basic)BG Removals (advanced)
Free502512
Creator500250125
Pro20001000500
Business800040002000
EnterpriseCustomCustomCustom

Overage Pricing

When monthly credits are exhausted, operations are billed from your USD wallet:

OperationCredit CostUSD Cost
Remove Background (auto)2 cr$0.1072
Remove Background (advanced)4 cr$0.2144
Replace Background4 cr$0.2144
Blur Background2 cr$0.1072
Add Shadow2 cr$0.1072

1 credit = $0.0536

Burst Limits

All tiers have a burst limit of 5x the per-minute rate for up to 10 seconds. Example: Pro tier can burst to 300 req/min for 10s before throttling to 60/min.

Rate Limit Headers

Every response includes:

X-RateLimit-Limit: 60
X-RateLimit-Remaining: 57
X-RateLimit-Reset: 1719936000

Exceeding the limit returns HTTP 429 with a Retry-After header (seconds until reset).

Enterprise

For higher limits, SLA guarantees, dedicated GPU capacity, and priority processing:

  • Email: [email protected]
  • Custom rate limits up to 2000 req/min
  • Guaranteed <2s processing time (P95)
  • Dedicated GPU model instance
  • Volume discounts starting at 50,000 operations/month

Supported Formats

Input:

  • JPEG (.jpg, .jpeg)
  • PNG (.png) — with or without alpha channel
  • WebP (.webp)
  • Maximum file size: 50MB
  • Maximum dimensions: 8192x8192 pixels
  • Recommended: 4096x4096 or smaller for fastest processing

Output:

  • PNG — preserves transparency (default for removal/shadow)
  • JPEG — smaller files, no transparency (default for blur)
  • WebP — best compression with transparency support

Error Responses

400 — Invalid Input

json
{
  "detail": "Provide image_url or image (base64)"
}

402 — Insufficient Credits

json
{
  "detail": "Insufficient credits. Required: 2, available: 0. Top up at fotohub.app/billing"
}

413 — Image Too Large

json
{
  "detail": "Image too large (max 50MB)"
}

502 — Processing Failed

json
{
  "detail": "Background processing failed: segmentation error"
}

503 — Service Unavailable

json
{
  "detail": "Background processing service unavailable"
}

504 — Timeout

json
{
  "detail": "Background processing timed out"
}

Use Cases

E-commerce Product Photos

Remove backgrounds from product images and replace with white/gradient for marketplace listings:

python
from fotohub import FotoHub

client = FotoHub(api_key="fh_live_your_api_key")

product_urls = [
    "https://example.com/product1.jpg",
    "https://example.com/product2.jpg",
    "https://example.com/product3.jpg",
]

for url in product_urls:
    # White background for Amazon/eBay listings
    result = client.images.replace_background(
        image_url=url,
        background="#ffffff",
        output_format="jpeg",
    )
    print(f"Processed: {result.output_url}")

Portrait Photography

Create professional headshots with blurred or replaced backgrounds:

python
# Blur for natural bokeh
result = client.images.blur_background(
    image_url="https://example.com/headshot.jpg",
    blur_radius=25,
    feather=4,
)

# Or replace with studio backdrop
result = client.images.replace_background(
    image_url="https://example.com/headshot.jpg",
    background="Professional gray gradient studio backdrop with soft rim lighting",
    background_type="prompt",
)

Design Assets

Create transparent PNGs with shadows for design compositions:

python
# Remove background
transparent = client.images.remove_background(
    image_url="https://example.com/object.jpg"
)

# Add shadow for realistic placement
with_shadow = client.images.add_shadow(
    image_url=transparent.output_url,
    shadow_type="contact",
    shadow_opacity=0.5,
    shadow_blur=15,
)

SDK Reference

Python SDK

bash
pip install fotohub

All background methods are under client.images.*:

MethodEndpoint
client.images.remove_background()POST /v1/images/remove-background
client.images.remove_background_advanced()POST /v1/images/remove-background/advanced
client.images.replace_background()POST /v1/images/replace-background
client.images.blur_background()POST /v1/images/blur-background
client.images.add_shadow()POST /v1/images/add-shadow

TypeScript SDK

bash
npm install fotohub
MethodEndpoint
client.images.removeBackground()POST /v1/images/remove-background
client.images.removeBackgroundAdvanced()POST /v1/images/remove-background/advanced
client.images.replaceBackground()POST /v1/images/replace-background
client.images.blurBackground()POST /v1/images/blur-background
client.images.addShadow()POST /v1/images/add-shadow