Background Removal API
Remove image backgrounds programmatically with a single API call. Built for developers who need clean, production-ready cutouts at scale.
Why Use This API
Fast Processing
Get results in 1-3 seconds. AI-powered segmentation handles complex edges, hair, and transparent objects.
Simple Integration
One endpoint. Send an image, get a transparent PNG back. Works with any language or framework.
High Quality Output
Clean edges with no artifacts. Handles hair, fur, semi-transparent objects, and complex backgrounds.
Privacy First
Images are processed and deleted immediately. No storage, no logging, no third-party sharing.
Quick Start
Start removing backgrounds in under a minute. Here's how:
- Get your API key — Sign up free to receive your key
- Send a request — POST an image to the endpoint
- Get the result — Receive a transparent PNG in the response
curl -X POST https://precisioncounter.com/api/v1/remove-background \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "image=@photo.jpg" \
-o result.png
import requests
response = requests.post(
"https://precisioncounter.com/api/v1/remove-background",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"image": open("photo.jpg", "rb")}
)
with open("result.png", "wb") as f:
f.write(response.content)
const fs = require("fs");
const FormData = require("form-data");
const form = new FormData();
form.append("image", fs.createReadStream("photo.jpg"));
const response = await fetch(
"https://precisioncounter.com/api/v1/remove-background",
{
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_KEY",
...form.getHeaders()
},
body: form
}
);
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("result.png", buffer);
API Reference
Base URL
https://precisioncounter.com/api/v1
Authentication
All requests require an API key passed in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Remove Background
Removes the background from an uploaded image and returns a transparent PNG.
Request Parameters
| Parameter | Type | Description |
|---|---|---|
| image required | file | The image file to process. Accepted formats: PNG, JPG, JPEG, WebP. Max size: 10 MB. |
| output_format optional | string | Output format. Default: png. Options: png, webp. |
| quality optional | string | Processing quality. Default: standard. Options: standard, hd. |
Response
200 OK — Returns the processed image as binary data with Content-Type: image/png.
Response Headers
| Header | Value |
|---|---|
| Content-Type | image/png or image/webp |
| X-Credits-Remaining | Number of API credits remaining |
| X-Processing-Time | Processing time in milliseconds |
Code Examples
Python (with error handling)
import requests
import sys
API_KEY = "YOUR_API_KEY"
API_URL = "https://precisioncounter.com/api/v1/remove-background"
def remove_background(input_path, output_path="result.png"):
"""Remove background from an image file."""
with open(input_path, "rb") as img:
response = requests.post(
API_URL,
headers={"Authorization": f"Bearer {API_KEY}"},
files={"image": img},
data={"output_format": "png", "quality": "hd"}
)
if response.status_code == 200:
with open(output_path, "wb") as f:
f.write(response.content)
print(f"Saved to {output_path}")
print(f"Credits remaining: {response.headers.get('X-Credits-Remaining')}")
else:
print(f"Error {response.status_code}: {response.json()['error']}")
remove_background("photo.jpg")
const fs = require("fs");
const FormData = require("form-data");
const fetch = require("node-fetch");
const API_KEY = "YOUR_API_KEY";
const API_URL = "https://precisioncounter.com/api/v1/remove-background";
async function removeBackground(inputPath, outputPath = "result.png") {
const form = new FormData();
form.append("image", fs.createReadStream(inputPath));
form.append("output_format", "png");
form.append("quality", "hd");
const response = await fetch(API_URL, {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
...form.getHeaders()
},
body: form
});
if (response.ok) {
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync(outputPath, buffer);
console.log(`Saved to ${outputPath}`);
console.log(`Credits: ${response.headers.get("x-credits-remaining")}`);
} else {
const error = await response.json();
console.error(`Error ${response.status}: ${error.error}`);
}
}
removeBackground("photo.jpg");
<?php
$api_key = "YOUR_API_KEY";
$url = "https://precisioncounter.com/api/v1/remove-background";
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer $api_key"
],
CURLOPT_POSTFIELDS => [
"image" => new CURLFile("photo.jpg"),
"output_format" => "png"
]
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode === 200) {
file_put_contents("result.png", $response);
echo "Background removed successfully\n";
} else {
echo "Error $httpCode: $response\n";
}
?>
package main
import (
"bytes"
"fmt"
"io"
"mime/multipart"
"net/http"
"os"
)
func removeBackground(inputPath, outputPath string) error {
file, _ := os.Open(inputPath)
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, _ := writer.CreateFormFile("image", inputPath)
io.Copy(part, file)
writer.Close()
req, _ := http.NewRequest("POST",
"https://precisioncounter.com/api/v1/remove-background", body)
req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, err := http.DefaultClient.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
if resp.StatusCode == 200 {
out, _ := os.Create(outputPath)
defer out.Close()
io.Copy(out, resp.Body)
fmt.Printf("Saved to %s\n", outputPath)
}
return nil
}
func main() {
removeBackground("photo.jpg", "result.png")
}
require "net/http"
require "uri"
api_key = "YOUR_API_KEY"
uri = URI("https://precisioncounter.com/api/v1/remove-background")
form_data = [
["image", File.open("photo.jpg", "rb")],
["output_format", "png"]
]
req = Net::HTTP::Post.new(uri)
req["Authorization"] = "Bearer #{api_key}"
req.set_form(form_data, "multipart/form-data")
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
http.request(req)
end
if res.code == "200"
File.binwrite("result.png", res.body)
puts "Background removed successfully"
else
puts "Error #{res.code}: #{res.body}"
end
using var client = new HttpClient();
client.DefaultRequestHeaders.Add("Authorization", "Bearer YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var imageContent = new ByteArrayContent(File.ReadAllBytes("photo.jpg"));
imageContent.Headers.ContentType = new("image/jpeg");
form.Add(imageContent, "image", "photo.jpg");
form.Add(new StringContent("png"), "output_format");
var response = await client.PostAsync(
"https://precisioncounter.com/api/v1/remove-background", form);
if (response.IsSuccessStatusCode)
{
var result = await response.Content.ReadAsByteArrayAsync();
File.WriteAllBytes("result.png", result);
Console.WriteLine("Background removed successfully");
}
Error Handling
The API returns standard HTTP status codes with JSON error bodies:
| Status | Meaning | Description |
|---|---|---|
| 200 | Success | Image processed successfully. Response body is the output image. |
| 400 | Bad Request | Missing image file, unsupported format, or file too large. |
| 401 | Unauthorized | Missing or invalid API key. |
| 429 | Rate Limited | Too many requests. Wait and retry with exponential backoff. |
| 500 | Server Error | Internal processing error. Retry the request. |
Error Response Format
{
"error": "Invalid file format. Accepted: png, jpg, jpeg, webp",
"code": "INVALID_FORMAT",
"status": 400
}
Rate Limits
| Plan | Requests / Minute | Max File Size | Max Resolution |
|---|---|---|---|
| Free | 10 | 10 MB | 4096 x 4096 px |
| Pro | 60 | 25 MB | 8192 x 8192 px |
Rate limit headers are included in every response:
X-RateLimit-Limit: 10 X-RateLimit-Remaining: 7 X-RateLimit-Reset: 1708646400
Use Cases
- E-commerce product photos
- Profile picture processing
- Design tool integrations
- Photo editing apps
- Marketing material creation
- Mobile app backends
- Automated image pipelines
- Game asset preparation
Pricing
Get free API credits when you sign up. No credit card required.
Frequently Asked Questions
output_format parameter.quality: "hd" parameter for the best edge quality.