API Documentation

Welcome to the RemoveBG API documentation. Our API provides fast, high-quality background removal for images using advanced AI technology. This documentation will guide you through integration.

Base URL https://fapihub.com/v2/rembg/

Quick Start

  1. 1 Get your API key from the API Keys page
  2. 2 Include your API key in the ApiKey header
  3. 3 Make your first request to remove a background

Authentication

All API requests require authentication. Include your API key in the ApiKey header with every request.

Header Format
ApiKey: your_api_token_here

Rate Limits

The API has monthly and minute request limits. The minute limit means that you can make X number of requests per minute. The monthly limit means that you can make X number of requests per month.

Remove Background

POST https://fapihub.com/v2/rembg/

Remove background from an image. This is a synchronous endpoint that returns the processed image directly in the response body.

Request

Headers

ApiKey *
Your API token, provided in the ApiKey header.
Example: ApiKey: your_api_token_here
Content-Type *
Must be multipart/form-data for file uploads.

Body Parameters

image * file
The image file to process. Send as multipart form data.
model string
Optional processing model. Allowed values: falcon, aurora, ghost. Default is falcon.
Supported only for /v2/rembg/ and /v2/rembg/mask/.

Code Examples

curl -X POST "https://fapihub.com/v2/rembg/" \
  -H "ApiKey: your_api_token" \
  -F "image=@/path/to/image.jpg" \
  -F "model=falcon" \
  -o result.png
import requests

response = requests.post(
    "https://fapihub.com/v2/rembg/",
    headers={"ApiKey": "your_api_token"},
    files={"image": open("/path/to/image.jpg", "rb")},
    data={"model": "falcon"}
)

if response.status_code == 200:
    with open("result.png", "wb") as f:
        f.write(response.content)
else:
    print("Error:", response.json())
const formData = new FormData();
formData.append("image", fileInput.files[0]);
formData.append("model", "falcon");

fetch("https://fapihub.com/v2/rembg/", {
  method: "POST",
  headers: {
    "ApiKey": "your_api_token"
  },
  body: formData
})
.then(response => response.blob())
.then(blob => {
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "result.png";
  a.click();
})
.catch(error => console.error("Error:", error));
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://fapihub.com/v2/rembg/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => [
    "ApiKey: your_api_token"
  ],
  CURLOPT_POSTFIELDS => [
    "image" => new CURLFile("/path/to/image.jpg"),
    "model" => "falcon"
  ]
]);

$response = curl_exec($curl);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);

if ($http_code == 200) {
  file_put_contents("result.png", $response);
} else {
  echo "Error: " . $response;
}
?>

Subject Mask

POST https://fapihub.com/v2/rembg/mask/

Generate a subject mask from an image. Returns a processed image directly in the response body.

Body Parameters

image * file
The image file to process.
model string
Optional model: falcon (default), aurora, or ghost.
curl -X POST "https://fapihub.com/v2/rembg/mask/" \
  -H "ApiKey: API_TOKEN" \
  -F "image=@image.jpg" \
  -F "model=falcon" \
  -o mask.png
import requests

response = requests.post(
    "https://fapihub.com/v2/rembg/mask/",
    headers={"ApiKey": "your_api_token"},
    files={"image": open("/path/to/image.jpg", "rb")},
    data={"model": "falcon"}
)

if response.status_code == 200:
    with open("mask.png", "wb") as f:
        f.write(response.content)
const formData = new FormData();
formData.append("image", fileInput.files[0]);
formData.append("model", "falcon");

fetch("https://fapihub.com/v2/rembg/mask/", {
  method: "POST",
  headers: { "ApiKey": "your_api_token" },
  body: formData
})
.then(response => response.blob())
.then(blob => {
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "mask.png";
  a.click();
});
<?php
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://fapihub.com/v2/rembg/mask/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["ApiKey: your_api_token"],
  CURLOPT_POSTFIELDS => [
    "image" => new CURLFile("/path/to/image.jpg"),
    "model" => "falcon"
  ]
]);
$response = curl_exec($curl);
file_put_contents("mask.png", $response);
curl_close($curl);
?>

Background Blur

POST https://fapihub.com/v2/rembg/blur/

Remove the background and apply a blur effect to what's left, or blur the existing background.

Body Parameters

image * file
The image file to process.
radius * integer
Blur radius (max 50).
curl -X POST "https://fapihub.com/v2/rembg/blur/" \
  -H "ApiKey: API_TOKEN" \
  -F "image=@image.jpg" \
  -F "radius=10"
import requests

response = requests.post(
    "https://fapihub.com/v2/rembg/blur/",
    headers={"ApiKey": "your_api_token"},
    files={"image": open("image.jpg", "rb")},
    data={"radius": 10}
)

if response.status_code == 200:
    with open("blurred.png", "wb") as f:
        f.write(response.content)
const formData = new FormData();
formData.append("image", fileInput.files[0]);
formData.append("radius", 10);

fetch("https://fapihub.com/v2/rembg/blur/", {
  method: "POST",
  headers: { "ApiKey": "your_api_token" },
  body: formData
})
.then(response => response.blob())
.then(blob => {
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "blurred.png";
  a.click();
});
<?php
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://fapihub.com/v2/rembg/blur/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["ApiKey: your_api_token"],
  CURLOPT_POSTFIELDS => [
    "image" => new CURLFile("image.jpg"),
    "radius" => 10
  ]
]);
$response = curl_exec($curl);
file_put_contents("blurred.png", $response);
curl_close($curl);
?>

Background Color

POST https://fapihub.com/v2/rembg/color/

Replace the background with a solid color.

Body Parameters

image * file
The image file to process.
bgcolor * string
Background color in RGB format.
Example: (255, 140, 0, 255)
curl -X POST "https://fapihub.com/v2/rembg/color/" \
  -H "ApiKey: API_TOKEN" \
  -F "image=@image.jpg" \
  -F "bgcolor=(255, 140, 0, 255)"
import requests

response = requests.post(
    "https://fapihub.com/v2/rembg/color/",
    headers={"ApiKey": "your_api_token"},
    files={"image": open("image.jpg", "rb")},
    data={"bgcolor": "(255, 140, 0, 255)"}
)

if response.status_code == 200:
    with open("colored.png", "wb") as f:
        f.write(response.content)
const formData = new FormData();
formData.append("image", fileInput.files[0]);
formData.append("bgcolor", "(255, 140, 0, 255)");

fetch("https://fapihub.com/v2/rembg/color/", {
  method: "POST",
  headers: { "ApiKey": "your_api_token" },
  body: formData
})
.then(response => response.blob())
.then(blob => {
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "colored.png";
  a.click();
});
<?php
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://fapihub.com/v2/rembg/color/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["ApiKey: your_api_token"],
  CURLOPT_POSTFIELDS => [
    "image" => new CURLFile("image.jpg"),
    "bgcolor" => "(255, 140, 0, 255)"
  ]
]);
$response = curl_exec($curl);
file_put_contents("colored.png", $response);
curl_close($curl);
?>

Background Gradient

POST https://fapihub.com/v2/rembg/gradient/

Replace the background with a color gradient.

Body Parameters

image * file
The image file to process.
top_color * string
Top color in RGB format.
bottom_color * string
Bottom color in RGB format.
curl -X POST "https://fapihub.com/v2/rembg/gradient/" \
  -H "ApiKey: API_TOKEN" \
  -F "image=@image.jpg" \
  -F "top_color=(255, 140, 0, 255)" \
  -F "bottom_color=(229, 46, 113, 255)"
import requests

response = requests.post(
    "https://fapihub.com/v2/rembg/gradient/",
    headers={"ApiKey": "your_api_token"},
    files={"image": open("image.jpg", "rb")},
    data={
        "top_color": "(255, 140, 0, 255)", 
        "bottom_color": "(229, 46, 113, 255)"
    }
)

if response.status_code == 200:
    with open("gradient.png", "wb") as f:
        f.write(response.content)
const formData = new FormData();
formData.append("image", fileInput.files[0]);
formData.append("top_color", "(255, 140, 0, 255)");
formData.append("bottom_color", "(229, 46, 113, 255)");

fetch("https://fapihub.com/v2/rembg/gradient/", {
  method: "POST",
  headers: { "ApiKey": "your_api_token" },
  body: formData
})
.then(response => response.blob())
.then(blob => {
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "gradient.png";
  a.click();
});
<?php
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://fapihub.com/v2/rembg/gradient/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["ApiKey: your_api_token"],
  CURLOPT_POSTFIELDS => [
    "image" => new CURLFile("image.jpg"),
    "top_color" => "(255, 140, 0, 255)",
    "bottom_color" => "(229, 46, 113, 255)"
  ]
]);
$response = curl_exec($curl);
file_put_contents("gradient.png", $response);
curl_close($curl);
?>

Subject Shadow

POST https://fapihub.com/v2/rembg/shadow/

Apply a realistic shadow to the subject.

Body Parameters

image * file
The image file to process.
shadow_color * string
Shadow color in RGB format.
offset * string
Offset in pixels (x, y).
blur_radius * integer
Blur radius for the shadow.
curl -X POST "https://fapihub.com/v2/rembg/shadow/" \
  -H "ApiKey: API_TOKEN" \
  -F "image=@image.jpg" \
  -F "shadow_color=(0, 0, 0, 150)" \
  -F "offset=(10, 10)" \
  -F "blur_radius=15"
import requests

response = requests.post(
    "https://fapihub.com/v2/rembg/shadow/",
    headers={"ApiKey": "your_api_token"},
    files={"image": open("image.jpg", "rb")},
    data={
        "shadow_color": "(0, 0, 0, 150)", 
        "offset": "(10, 10)", 
        "blur_radius": 15
    }
)

if response.status_code == 200:
    with open("shadowed.png", "wb") as f:
        f.write(response.content)
const formData = new FormData();
formData.append("image", fileInput.files[0]);
formData.append("shadow_color", "(0, 0, 0, 150)");
formData.append("offset", "(10, 10)");
formData.append("blur_radius", 15);

fetch("https://fapihub.com/v2/rembg/shadow/", {
  method: "POST",
  headers: { "ApiKey": "your_api_token" },
  body: formData
})
.then(response => response.blob())
.then(blob => {
  const url = window.URL.createObjectURL(blob);
  const a = document.createElement("a");
  a.href = url;
  a.download = "shadowed.png";
  a.click();
});
<?php
$curl = curl_init();
curl_setopt_array($curl, [
  CURLOPT_URL => "https://fapihub.com/v2/rembg/shadow/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_POST => true,
  CURLOPT_HTTPHEADER => ["ApiKey: your_api_token"],
  CURLOPT_POSTFIELDS => [
    "image" => new CURLFile("image.jpg"),
    "shadow_color" => "(0, 0, 0, 150)",
    "offset" => "(10, 10)",
    "blur_radius" => 15
  ]
]);
$response = curl_exec($curl);
file_put_contents("shadowed.png", $response);
curl_close($curl);
?>

Responses

Binary image data (the processed image with background removed)

{
  "error": {
    "code": "invalid_image",
    "message": "The uploaded file is not a valid image format",
    "request_id": "req_abc123"
  }
}
{
  "error": {
    "code": "invalid_api_key",
    "message": "The provided API key is invalid or expired",
    "request_id": "req_abc123"
  }
}
{
  "error": {
    "code": "insufficient_credits",
    "message": "Your account has insufficient credits. Please upgrade your plan.",
    "request_id": "req_abc123"
  }
}
{
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Too many requests. Please wait before making more requests.",
    "request_id": "req_abc123",
    "retry_after": 60
  }
}