Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/ai360/llms.txt

Use this file to discover all available pages before exploring further.

The Background Remover endpoint accepts a base64-encoded image, uploads it to ImageKit (under the minor-project folder), and returns the resulting CDN URL. Background removal is applied by appending ImageKit’s effect=bgremove URL transformation parameter to the returned URL — no additional server processing is required after the upload. This design means the raw upload URL is returned from the API; your frontend applies the bgremove transformation at render time by constructing the ImageKit transformation URL.

Request

POST /api/utilities/background-remover
Content-Type: application/json
file
string
required
The image to process, encoded as a base64 string. Common formats (PNG, JPEG, WebP) are all accepted by ImageKit. Do not include a data URL prefix (e.g. data:image/png;base64,) — pass the raw base64 content only, unless your ImageKit SDK version handles it transparently.

Response

A successful request returns HTTP 200 with the following body:
url
string
The ImageKit CDN URL of the uploaded image. To display the image with its background removed, append the ?tr=bgremove query parameter (or use ImageKit’s SDK transformation: [{ effect: "bgremove" }]) when constructing the final <img> src.
{
  "url": "https://ik.imagekit.io/your_id/minor-project/original_1718000000000.png"
}
The url returned is the original upload URL. To render the background-removed version, append ?tr=bgremove to the URL:
https://ik.imagekit.io/your_id/minor-project/original_1718000000000.png?tr=bgremove
ImageKit processes the transformation on the fly and caches the result on its CDN.

Error Responses

StatusBodyCause
400{ "error": "Missing image file" }The file field was absent or empty in the request body.
500{ "error": "Failed to remove background" }ImageKit upload failed or an unexpected server error occurred.
The three ImageKit environment variables below must all be configured on the server. Missing any one of them will cause the upload to fail.

Environment Variables

VariableDescription
NEXT_PUBLIC_IMAGEKIT_PUBLIC_KEYYour ImageKit public API key.
IMAGEKIT_PRIVATE_KEYYour ImageKit private API key (server-side only).
NEXT_PUBLIC_IMAGEKIT_URL_ENDPOINTYour ImageKit URL endpoint (e.g. https://ik.imagekit.io/your_id).

Example

Request
curl -X POST https://your-domain.com/api/utilities/background-remover \
  -H "Content-Type: application/json" \
  -d '{
    "file": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoH..."
  }'
Response
{
  "url": "https://ik.imagekit.io/your_id/minor-project/original_1718000000000.png"
}
Rendering the background-removed image
<img
  src="https://ik.imagekit.io/your_id/minor-project/original_1718000000000.png?tr=bgremove"
  alt="Image with background removed"
/>

Build docs developers (and LLMs) love