Remove backgrounds from your own apps, shops or pipelines with a single HTTPS request.
Base URL: https://bgcut.net/api/v1 · Get your key under API keys.
Authentication
Every request must carry your API key in the X-Api-Key header. Keys are created and revoked in your account; each key can be named so you can rotate them per application.
// Never ship your API key in public front-end code – proxy through your server.
const input = document.querySelector('input[type=file]');
input.addEventListener('change', async () => {
const form = new FormData();
form.append('image_file', input.files[0]);
form.append('size', 'preview');
const res = await fetch('https://bgcut.net/api/v1/remove', { method: 'POST', headers: { 'X-Api-Key': 'bgc_YOUR_API_KEY' }, body: form });
const blob = await res.blob();
document.querySelector('img#out').src = URL.createObjectURL(blob);
});
// Java 11+ HttpClient, no external libraries
import java.net.URI;
import java.net.http.*;
import java.nio.file.*;
public class BgCut {
public static void main(String[] a) throws Exception {
String key = "bgc_YOUR_API_KEY";
String boundary = "----bgcut" + System.nanoTime();
byte[] file = Files.readAllBytes(Path.of("photo.jpg"));
String head = "--" + boundary + "\r\nContent-Disposition: form-data; name=\"image_file\"; filename=\"photo.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n";
String tail = "\r\n--" + boundary + "\r\nContent-Disposition: form-data; name=\"size\"\r\n\r\nauto\r\n--" + boundary + "--\r\n";
byte[] body = concat(head.getBytes(), file, tail.getBytes());
HttpRequest req = HttpRequest.newBuilder(URI.create("https://bgcut.net/api/v1/remove"))
.header("X-Api-Key", key)
.header("Content-Type", "multipart/form-data; boundary=" + boundary)
.POST(HttpRequest.BodyPublishers.ofByteArray(body)).build();
HttpResponse<byte[]> res = HttpClient.newHttpClient().send(req, HttpResponse.BodyHandlers.ofByteArray());
if (res.statusCode() == 200) Files.write(Path.of("result.png"), res.body());
else System.out.println(new String(res.body()));
}
static byte[] concat(byte[]... parts) { int n = 0; for (byte[] p : parts) n += p.length; byte[] out = new byte[n]; int o = 0; for (byte[] p : parts) { System.arraycopy(p, 0, out, o, p.length); o += p.length; } return out; }
}
using System.Net.Http;
using System.Net.Http.Headers;
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Api-Key", "bgc_YOUR_API_KEY");
using var form = new MultipartFormDataContent();
var fileContent = new ByteArrayContent(await File.ReadAllBytesAsync("photo.jpg"));
fileContent.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
form.Add(fileContent, "image_file", "photo.jpg");
form.Add(new StringContent("auto"), "size");
form.Add(new StringContent("png"), "format");
var res = await client.PostAsync("https://bgcut.net/api/v1/remove", form);
if (res.IsSuccessStatusCode)
await File.WriteAllBytesAsync("result.png", await res.Content.ReadAsByteArrayAsync());
else
Console.WriteLine(await res.Content.ReadAsStringAsync());
The image file (multipart/form-data). JPG, PNG, WebP, GIF, BMP, TIFF; max 25 MB / 30 MP.
image_url
string
Public URL of the image to fetch instead of uploading.
image_file_b64
string
Base64-encoded image (optionally with a data: prefix).
size
auto | preview | full
preview = up to 640 px (uses your free monthly quota, no credits); full = original resolution (1 credit); auto (default) = full when you have credits, otherwise preview.
format
png | jpg | webp
Output format. png keeps transparency; jpg is flattened on bg_color (default white).
model
fast | hq | portrait
lite (default, ~6 s, best balance), fast (~0.5 s preview quality), hq (~15 s, maximum quality), portrait (~0.3 s, people only).
bg_color
string
Hex colour for the background, e.g. #ffffff. Omit for transparent.
bg_blur
number
Keep the original background but blur it with this radius in pixels (1–200), e.g. 25 for a portrait-mode look. Overrides bg_color.
crop
boolean
Crop the output to the subject bounding box.
crop_margin
integer
Extra margin in pixels around the subject when cropping (0–200).
roi
string
Region of interest as fractions x,y,w,h (0–1). The AI only looks inside this rectangle; everything outside becomes transparent.
feather
number
Soften edges by this radius in pixels (0–5).
quality
integer
JPG/WebP quality 50–100 (default 92).
response
binary | json
binary (default) returns the image; json returns metadata plus the base64 image.
Responses
Successful requests return HTTP 200 with the image bytes and these headers:
HTTP/1.1 200 OK
Content-Type: image/png
X-Credits-Charged: 1
X-Credits-Remaining: 149
X-Free-Remaining: 5
X-Width: 3000
X-Height: 2000
X-Image-Id: 1f3a…
X-Type: hd