Skip to main content
Remove background from an image. This is a synchronous endpoint that returns the processed image directly in the response body.
https://fapihub.com/v2/rembg/

Result

Image
Image

Headers

ApiKey
string
required
Your API token.

Body

image
file
required
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 Samples

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;
}
?>

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
  }
}