AI Cut: Basic
Point-based segmentation. Pay 2 credits once, then refine unlimited times for free.
1. Get token — 2 credits
2. Upload image — initialize session
3. Segment — green dots include, red dots exclude (FREE)
import requests
API_KEY = "YOUR_API_KEY"
# Step 1 — Get AI Cut token (2 credits)
token_response = requests.post(
"https://backgroundcut.co/api/v3/ai-cut/token/",
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=60
)
token_response.raise_for_status()
access_token = token_response.json()["access_token"]
# Step 2 — Initialize session (upload image)
with open("photo.jpg", "rb") as f:
init_response = requests.post(
"https://api.backgroundcut.co/v3/ai-cut/initialize/",
files={"image": f},
data={"token": access_token},
timeout=300
)
init_response.raise_for_status()
unique_filename = init_response.json()["unique_filename"]
# Step 3 — Segment with points (FREE, unlimited)
# Green dots = include, Red dots = exclude
segment_response = requests.post(
"https://api.backgroundcut.co/v3/ai-cut/segment/",
json={
"unique_filename": unique_filename,
"greenDots": [{"x": 250, "y": 300}],
"redDots": [],
"request_number": 1
},
timeout=300
)
result = segment_response.json()
print("Segmented:", result["output_url"])
# Refine — still FREE
refine_response = requests.post(
"https://api.backgroundcut.co/v3/ai-cut/segment/",
json={
"unique_filename": unique_filename,
"greenDots": [{"x": 250, "y": 300}, {"x": 270, "y": 320}],
"redDots": [{"x": 50, "y": 50}],
"request_number": 2
},
timeout=300
)
refined = refine_response.json()
print("Refined:", refined["output_url"])Segment Response
{
"status": "completed",
"unique_filename": "abc123-...",
"output_url": "https://...",
"request_number": 1
} Each call to /v3/ai-cut/segment/ should include all points (green and red) from the session, not just new ones. Increment request_number with each call.