Linkit
Api

LoLo BG Remover

Remove image backgrounds using LoLo from the App Store actions flow

LoLo BG Remover API

LoLo is exposed as dedicated app action endpoints:

POST /api/v1/apps/lolo
POST /api/v1/apps/lolo/batch

It accepts an image, runs background removal through the LoLo Rust microservice, and returns a transparent PNG.


Authentication and Org Scope

  • Send Authorization: Bearer <token>.
  • Organization is derived from the authenticated token (same model used by other app endpoints).
  • Request is rejected if lolo-image-tools is not installed for the organization.

Request Formats

Content-Type: multipart/form-data with a file field.

Octet Stream

Content-Type: application/octet-stream with raw bytes and optional X-File-Name.

Query Parameters

ParameterTypeAllowed values
modelstringu2net, u2netp, isnet-general-use, isnet-anime, silueta, u2net-human-seg
qualitystringfast, balanced, high
sizeinteger64..2048

Validation Rules

Validation is enforced in UI and server:

  • Max upload bytes: LOLO_MAX_UPLOAD_BYTES (default 10MB)
  • Min dimensions: LOLO_MIN_WIDTH/LOLO_MIN_HEIGHT (default 64x64)
  • Max dimensions: LOLO_MAX_WIDTH/LOLO_MAX_HEIGHT (default 8192x8192)
  • Max pixels: LOLO_MAX_PIXELS (default 67,108,864)
  • Max files per batch request: hard limit 10 (LOLO_MAX_FILES_PER_REQUEST, clamped to 10)
  • Formats: PNG, JPEG, WebP

Successful Response

  • 200 OK
  • Content-Type: image/png
  • Content-Disposition: attachment; filename="<name>-bg-removed.png"

Metadata headers include:

  • X-LoLo-Source-Width, X-LoLo-Source-Height, X-LoLo-Input-Bytes
  • X-LoLo-Selected-Model, X-LoLo-Selected-Quality, X-LoLo-Selected-Size
  • X-LoLo-Model, X-LoLo-Inference-Ms, X-LoLo-Total-Ms, X-LoLo-Output-Bytes

Errors return JSON:

{ "error": "message", "code": 400 }

Batch Endpoint

POST /api/v1/apps/lolo/batch
  • Use multipart/form-data and repeat files fields.
  • Returns application/json with one item per processed image.
  • Each item includes image_base64 (PNG), per-image metrics, selected options, and request_id.
  • zip_filename is returned for frontend bulk ZIP download naming.

cURL Example

curl -X POST "https://linkit.works/api/v1/apps/lolo?model=u2netp&quality=balanced&size=1024" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -F "file=@/path/to/input.jpg" \
  --output result.png

Go Client Example

package main

import (
	"bytes"
	"context"
	"fmt"
	"io"
	"mime/multipart"
	"net/http"
	"os"
	"time"
)

func removeBackground(ctx context.Context, baseURL, token, inPath, outPath string) error {
	in, err := os.Open(inPath)
	if err != nil {
		return err
	}
	defer in.Close()

	var body bytes.Buffer
	writer := multipart.NewWriter(&body)
	part, err := writer.CreateFormFile("file", "input.jpg")
	if err != nil {
		return err
	}
	if _, err = io.Copy(part, in); err != nil {
		return err
	}
	if err = writer.Close(); err != nil {
		return err
	}

	req, err := http.NewRequestWithContext(
		ctx,
		http.MethodPost,
		baseURL+"/api/v1/apps/lolo?model=u2netp&quality=balanced&size=1024",
		&body,
	)
	if err != nil {
		return err
	}
	req.Header.Set("Authorization", "Bearer "+token)
	req.Header.Set("Content-Type", writer.FormDataContentType())

	client := &http.Client{Timeout: 45 * time.Second}
	res, err := client.Do(req)
	if err != nil {
		return err
	}
	defer res.Body.Close()

	if res.StatusCode != http.StatusOK {
		msg, _ := io.ReadAll(res.Body)
		return fmt.Errorf("lolo failed: status=%d body=%s", res.StatusCode, string(msg))
	}

	out, err := os.Create(outPath)
	if err != nil {
		return err
	}
	defer out.Close()

	_, err = io.Copy(out, res.Body)
	return err
}

For App Store actions UI, users can upload, control model/quality/size, preview output, and download the returned PNG directly.