Skip to main content

L402 API

Pay with Bitcoin, get AI results. Copy-paste the commands below.

Before You Start

Lightning Wallet

Phoenix, Muun, Wallet of Satoshi, Alby, or any LN wallet. Agents: CLW

Terminal or Tool

A command line, Postman, or lnget (recommended)

Private & No Signup

No account, no subscription, no personal data. Pay only when you use it

Want to try this without a terminal? Use Object Removal on the web — pay with any Lightning wallet, no setup needed.

Smart Object Removal via L402

Remove unwanted objects from images by describing what to remove — no mask needed. Combines Grounding DINO object detection (ECCV 2024) with Bria Eraser neural inpainting. Just say "person", "car", or "watermark" and the object is detected, masked, and erased automatically.

API Endpoint: https://sats4ai.com/api/l402/remove-object

How it works

  • Send an image + text describing what to remove (e.g. "person", "car", "watermark")
  • Grounding DINO detects the object and generates a pixel mask automatically
  • Bria Eraser removes the object and fills the area with neural inpainting
  • Returns JSON with image URL
  • 15 sats per image

Step 1: Initial Request (get Invoice)

Send your base64 image and describe what to remove. You will receive a 402 Payment Required response with a Lightning invoice.

Request body:

{
  "image": "<base64-encoded-image>",
  "query": "person"
}

Example curl command:

curl -X POST https://sats4ai.com/api/l402/remove-object \
-H "Content-Type: application/json" \
-d '{
  "image": "<base64-encoded-image>",
  "query": "person"
}' \
-i

Step 2: Pay the Lightning Invoice

Pay the invoice with any Lightning wallet. Save the preimage your wallet provides after payment.

Step 3: Re-send with Payment Proof

The JSON payload must be identical to Step 1.

curl -X POST https://sats4ai.com/api/l402/remove-object \
-H "Content-Type: application/json" \
-H "Authorization: L402 <YOUR_MACAROON>:<YOUR_PREIMAGE>" \
-d '{
  "image": "<base64-encoded-image>",
  "query": "person"
}'

Successful response includes image_url (URL to cleaned image — download promptly).

Easier: Use lnget

lnget handles the full L402 flow automatically.

IMAGE_B64=$(base64 -w0 photo.png)

lnget -X POST https://sats4ai.com/api/l402/remove-object \
  --json "{\"image\":\"$IMAGE_B64\",\"query\":\"car\"}"

Python Example

import requests, base64

# Encode image
with open("photo.png", "rb") as f:
    image_b64 = base64.b64encode(f.read()).decode()

payload = { "image": image_b64, "query": "watermark" }

# Step 1 — get invoice
r = requests.post("https://sats4ai.com/api/l402/remove-object",
    json=payload,
    headers={"Content-Type": "application/json"})

# Step 2 — pay invoice with your Lightning wallet, get preimage

# Step 3 — re-send with auth
r2 = requests.post("https://sats4ai.com/api/l402/remove-object",
    json=payload,
    headers={
        "Content-Type": "application/json",
        "Authorization": "L402 <macaroon>:<preimage>"
    })
result = r2.json()
print(result["image_url"])  # URL to cleaned image (download promptly)

Request Parameters

image: string required

Base64-encoded image data (PNG, JPEG, WEBP) or data URI.

query: string required

Describe what to remove from the image. Examples: "person", "car", "watermark", "text", "dog". Can be comma-separated for multiple objects.

box_threshold: number optional

Detection confidence threshold (0-1, default 0.25). Raise to require higher confidence matches.

text_threshold: number optional

Text matching threshold (0-1, default 0.25). Controls how closely the query must match.

Pricing

15 sats per image (detection + removal).

Use Cases

  • Remove watermarks from stock photos
  • Erase unwanted people or objects from photos
  • Clean up product images for e-commerce
  • Remove text overlays from screenshots
  • Agent-driven image cleanup pipelines