remove.bg closes Dec 1 ·pay per photo here →
Back to API Keys

API Documentation

Remove.bg compatible REST API

Endpoint

POST https://zerobg.ai/api/v1/removebg

Authentication

Include your API key in the request header

X-Api-Key: YOUR_API_KEY

Request Parameters

ParameterTypeDescription
image_fileFileImage file (JPG, PNG, WebP). Either this or image_url required.
image_urlStringURL of the image. Either this or image_file required.
sizeStringpreview (max 720px) or full (original size). Default: full
formatStringpng or webp. Default: png

Response

Success (200)

Returns the processed image as binary data with Content-Type: image/png

Headers include:
  • X-Credits-Remaining: Number of credits remaining
  • X-Processing-Time: Processing time in seconds

Error Responses

{ "error": { "type": "authentication_error" | "authorization_error" | "insufficient_credits" | ..., "message": "Error description" } }

Code Examples

cURL (File Upload)

curl -X POST \
  -H "X-Api-Key: YOUR_API_KEY" \
  -F "image_file=@/path/to/image.jpg" \
  -F "size=full" \
  https://zerobg.ai/api/v1/removebg --output result.png

cURL (URL)

curl -X POST \
  -H "X-Api-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_url": "https://example.com/image.jpg", "size": "full"}' \
  https://zerobg.ai/api/v1/removebg

Python

import requests

url = "https://zerobg.ai/api/v1/removebg"
files = {"image_file": open("input.jpg", "rb")}
headers = {"X-Api-Key": "YOUR_API_KEY"}
data = {"size": "full", "format": "png"}

response = requests.post(url, files=files, headers=headers, data=data)

if response.status_code == 200:
    with open("output.png", "wb") as f:
        f.write(response.content)
    print("Success! Output saved to output.png")
else:
    print(f"Error: {response.json()}")

Node.js

const FormData = require('form-data');
const fs = require('fs');
const axios = require('axios');

async function removeBackground() {
  const formData = new FormData();
  formData.append('image_file', fs.createReadStream('input.jpg'));
  formData.append('size', 'full');

  const response = await axios.post(
    'https://zerobg.ai/api/v1/removebg',
    formData,
    {
      headers: {
        'X-Api-Key': 'YOUR_API_KEY',
        ...formData.getHeaders(),
      },
      responseType: 'arraybuffer',
    }
  );

  fs.writeFileSync('output.png', response.data);
  console.log('Success! Output saved to output.png');
}

removeBackground();

Rate Limits & Credits

  • • Each API call consumes 1 credit from your account
  • • API access is available for Pro and Business plans only
  • • Rate limit: 10 requests per second
  • • Maximum file size: 25MB
  • • Supported formats: JPG, PNG, WebP