Easy Integration
Our API is easy to integrate into your existing workflows. Here are some examples.
import requests
headers = {
'accept': 'application/json',
'X-API-Key': 'YOUR_API_KEY',
# requests won't add a boundary if this header is set when you pass files=
# 'Content-Type': 'multipart/form-data',
}
files = {
'file': open('input-image.jpg', 'rb'),
}
response = requests.post('https://api.withoutbg.com/v1.0/image-without-background', headers=headers, files=files)
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Scanner;
class Main {
public static void main(String[] args) throws IOException {
URL url = new URL("https://api.withoutbg.com/v1.0/image-without-background");
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("POST");
httpConn.setRequestProperty("accept", "application/json");
httpConn.setRequestProperty("X-API-Key", "YOUR_API_KEY");
httpConn.setRequestProperty("Content-Type", "multipart/form-data");
InputStream responseStream = httpConn.getResponseCode() / 100 == 2
? httpConn.getInputStream()
: httpConn.getErrorStream();
Scanner s = new Scanner(responseStream).useDelimiter("\\A");
String response = s.hasNext() ? s.next() : "";
System.out.println(response);
}
}
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.withoutbg.com/v1.0/image-without-background');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'accept: application/json',
'X-API-Key: YOUR_API_KEY',
'Content-Type: multipart/form-data',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'file' => new CURLFile('input-image.jpg'),
]);
$response = curl_exec($ch);
curl_close($ch);
extern crate reqwest;
use reqwest::{header, blocking::multipart};
fn main() -> Result<(), Box> {
let mut headers = header::HeaderMap::new();
headers.insert("accept", "application/json".parse().unwrap());
headers.insert("X-API-Key", "YOUR_API_KEY".parse().unwrap());
headers.insert("Content-Type", "multipart/form-data".parse().unwrap());
let form = multipart::Form::new()
.file("file", "input-image.jpg")?;
let client = reqwest::blocking::Client::builder()
.redirect(reqwest::redirect::Policy::none())
.build()
.unwrap();
let res = client.post("https://api.withoutbg.com/v1.0/image-without-background")
.headers(headers)
.multipart(form)
.send()?
.text()?;
println!("{}", res);
Ok(())
}
const form = new FormData();
form.append('file', File([''], 'input-image.jpg'));
fetch('https://api.withoutbg.com/v1.0/image-without-background', {
method: 'POST',
headers: {
'accept': 'application/json',
'X-API-Key': 'YOUR_API_KEY',
'Content-Type': 'multipart/form-data'
},
body: form
});
package main
import (
"bytes"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
)
func main() {
form := new(bytes.Buffer)
writer := multipart.NewWriter(form)
fw, err := writer.CreateFormFile("input-image.jpg", filepath.Base("input-image.jpg"))
if err != nil {
log.Fatal(err)
}
fd, err := os.Open("input-image.jpg")
if err != nil {
log.Fatal(err)
}
defer fd.Close()
_, err = io.Copy(fw, fd)
if err != nil {
log.Fatal(err)
}
writer.Close()
client := &http.Client{}
req, err := http.NewRequest("POST", "https://api.withoutbg.com/v1.0/image-without-background", form)
if err != nil {
log.Fatal(err)
}
req.Header.Set("accept", "application/json")
req.Header.Set("X-API-Key", "YOUR_API_KEY")
req.Header.Set("Content-Type", writer.FormDataContentType())
resp, err := client.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
bodyText, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", bodyText)
}
curl -X 'POST'
http://api.withoutbg.com/v1.0/image-without-background
-H 'X-API-Key: YOUR_API_KEY'
-F 'file=@input-image.jpg'
-o output-image.png
using System.Net.Http;
using System.Net.Http.Headers;
HttpClient client = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, "https://api.withoutbg.com/v1.0/image-without-background");
request.Headers.Add("accept", "application/json");
request.Headers.Add("X-API-Key", "YOUR_API_KEY");
MultipartFormDataContent content = new MultipartFormDataContent();
content.Add(new ByteArrayContent(File.ReadAllBytes("input-image.jpg")), "file", Path.GetFileName("input-image.jpg"));
request.Content = content;
request.Content.Headers.ContentType = new MediaTypeHeaderValue("multipart/form-data");
HttpResponseMessage response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
string responseBody = await response.Content.ReadAsStringAsync();
To see alternative endpoints, check the documentation page.
We truly care about your privacy.
Here is how:
FAQ
Technology
It is a supervised machine learning algorithm, meaning that it is learning from the examples we provide.
Our image background removal model is designed to handle complex backgrounds, including those with gradients or textures. In most cases, our model is able to successfully remove the background while preserving the foreground object. However, for the best results, we recommend using the service with images that have smooth and solid backgrounds, if possible. This can help to ensure that the image background removal is as accurate and seamless as possible and that the final output meets your expectations.
API
You can use any programming language. Please find various examples on the documentation page.
We provide an endpoint for getting available credits and expiration dates. Every processing costs 1 credit.
While your service aims to preserve the original quality of the foreground object as much as possible, it is important to note that there may still be some minor loss of detail or resolution in certain cases. If you prefer, you may request only the alpha channel, and process it on your side.
The service returns an Insufficient Credit
error.
Pricing
Yes. When you sign up, you get 50 free credits.
Privacy
We process your images in memory. We do not store them.
No tracking code on our website. Your browsing habits are not tracked.
Company
Frankfurt, Germany