Elimine fondos desde sus propias aplicaciones, tiendas o flujos de trabajo con una sola solicitud HTTPS.
URL base: https://bgcut.net/api/v1 · Obtenga su clave en Claves de API.
Autenticación
Cada solicitud debe incluir su clave de API en el encabezado X-Api-Key. Las claves se crean y revocan en su cuenta; puede asignar un nombre a cada clave para rotarlas por aplicación.
// 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());
El archivo de imagen (multipart/form-data). JPG, PNG, WebP, GIF, BMP, TIFF; máx. 25 MB / 30 MP.
image_url
string
URL pública de la imagen que se descargará en lugar de subirla.
image_file_b64
string
Imagen codificada en base64 (opcionalmente con el prefijo data:).
size
auto | preview | full
preview = hasta 640 px (usa su cuota mensual gratuita, sin créditos); full = resolución original (1 crédito); auto (predeterminado) = full si tiene créditos; de lo contrario, preview.
format
png | jpg | webp
Formato de salida. png conserva la transparencia; jpg se aplana sobre bg_color (blanco por defecto).
model
fast | hq | portrait
fast (predeterminado, ~1 s), hq (mayor calidad, más lento), portrait (optimizado para personas).
bg_color
string
Color hexadecimal del fondo, p. ej., #ffffff. Omítalo para obtener un fondo transparente.
bg_blur
number
Conserva el fondo original, pero lo desenfoca con este radio en píxeles (1–200), p. ej., 25 para un efecto de modo retrato. Anula bg_color.
crop
boolean
Recorta la salida al cuadro delimitador del sujeto.
crop_margin
integer
Margen adicional en píxeles alrededor del sujeto al recortar (0–200).
roi
string
Región de interés como fracciones x,y,w,h (0–1). La IA solo analiza el interior de este rectángulo; todo lo exterior se vuelve transparente.
feather
number
Suaviza los bordes con este radio en píxeles (0–5).
quality
integer
Calidad JPG/WebP de 50 a 100 (92 por defecto).
response
binary | json
binary (predeterminado) devuelve la imagen; json devuelve los metadatos junto con la imagen en base64.
Respuestas
Las solicitudes correctas devuelven HTTP 200 con los bytes de la imagen y estos encabezados:
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