Skip to main content

Prerequisite

Before calling background endpoints, complete Authentication and token flow.

Supported endpoints

  • POST /api/v1/background/remove/url
  • POST /api/v1/background/remove/base64
  • POST /api/v1/background/remove/multipart
All three endpoints require:
  • Header Authorization: <managed_token>

Remove by URL and decode in memory

Use one example below. Each snippet sends POST /background/remove/url and decodes image_base64 in memory.
import base64
import requests
from io import BytesIO
from PIL import Image

response = requests.post(
    "https://api.cutbg.net/api/v1/background/remove/url",
    headers={
        "Authorization": "<managed_token>",
        "Content-Type": "application/json"
    },
    json={"image_url": "https://example.com/photo.jpg"},
    timeout=30
)
response.raise_for_status()

image_base64 = response.json()["image_base64"]
image_bytes = base64.b64decode(image_base64)
image = Image.open(BytesIO(image_bytes))  # in-memory PIL image