Nội dung tham chiếu kỹ thuật được viết bằng tiếng Anh; phần điều hướng và tiêu đề đã được dịch.

ClearCut API

Xóa nền ảnh và video chỉ với một yêu cầu HTTP. Tích hợp ClearCut vào ứng dụng, quy trình hoặc backend của bạn trong vài phút — không cần hạ tầng ML.

POSThttps://api.clearcutapi.com/api/v1/removebg

API dùng HTTP thuần với nội dung multipart hoặc JSON, nên hoạt động với mọi ngôn ngữ. Xác thực bằng khóa API, gửi ảnh hoặc video và nhận lại bản tách nền sạch.

Dễ dàng tích hợp

  • • Một lệnh gọi, mọi ngôn ngữ — đầu vào multipart, URL hoặc base64; kết quả trả về dạng JSON, URL lưu trữ hoặc byte thô.
  • • Thanh toán dễ dự đoán — chỉ tính tín dụng khi thành công; tín dụng video được giữ trước, đối soát và hoàn lại khi thất bại.
  • • Bất đồng bộ khi cần — video chạy nền với tiến độ, webhook và khả năng hủy.
  • • Kiểm soát cho production — giới hạn tốc độ theo khóa, hạn mức hằng tháng, danh sách IP và tên miền được phép.

Bắt đầu

1. Tạo tài khoản và lấy khóa API từ bảng điều khiển.

2. Gửi yêu cầu đầu tiên của bạn:

curl -X POST "https://api.clearcutapi.com/api/v1/removebg" \
  -H "X-API-Key: clearcut_live_YOUR_KEY" \
  -F "image_file=@/path/to/image.jpg" \
  -F "format=png" \
  -F "size=auto"

Phản hồi mặc định ở dạng JSON và có result.url được lưu trữ sẵn, hoặc đặt response_type=binary để nhận trực tiếp byte của ảnh.

Xác thực

Gửi khóa API của bạn trong header X-API-Key. Khóa được tạo trong bảng điều khiển và chỉ hiển thị một lần (được lưu dưới dạng băm SHA-256).

X-API-Key: clearcut_live_xxxxxxxxxxxxxxxxxxxxxxxxx

Tạo khóa bằng chương trình với token truy cập bảng điều khiển của bạn:

# Create an API key (use your dashboard JWT)
curl -X POST "https://api.clearcutapi.com/api/v1/api-keys" \
  -H "Authorization: Bearer <ACCESS_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"name": "Production", "mode": "live"}'
# -> the full key is returned ONCE in the "key" field

Xóa nền ảnh

POST/api/v1/removebg

Nhận tệp tải lên, URL hoặc chuỗi base64. Trả về bản tách nền trong suốt hoặc ảnh ghép lên nền màu/ảnh.

Tham sốMô tả
image_file / image_url / image_file_b64Source image — provide exactly one. JPG, PNG or WebP, up to 22 MB / 50 MP.
sizepreview | full | auto (default auto). Preview is ~0.25 MP and costs 0.25 credit.
formatpng | jpg | webp | zip | auto (default auto: PNG if transparent, else JPG).
typeauto | person | product | animal | car | graphic | transportation. person uses a portrait-tuned model.
bg_colortransparent | white | black | #RRGGBB (+0.5 credit when not transparent).
bg_image_urlComposite onto this image instead (+0.5 credit).
croptrue | false — crop to the subject.
marginPixels of padding around the cropped subject (0–500).
shadowtrue | false — add a soft drop shadow.
response_typejson (default) | url | binary — binary streams the file bytes.
webhook_urlOptional. Receives this job's job.completed / job.failed events, signed.
curl -X POST "https://api.clearcutapi.com/api/v1/removebg" \
  -H "X-API-Key: clearcut_live_YOUR_KEY" \
  -F "image_file=@/path/to/image.jpg" \
  -F "format=png" \
  -F "size=auto"

Phản hồi

{
  "success": true,
  "job_id": "job_3f9c2a71b0d84e6c9a1f5e2d7b40",
  "status": "completed",
  "result": {
    "url": "https://cdn.clearcutapi.com/results/.../job_3f9c....png",
    "format": "png",
    "width": 1200,
    "height": 1200,
    "expires_at": "2026-12-31T23:59:59Z"
  },
  "usage": { "credits_used": 1, "credits_remaining": 999 }
}

Xóa nền video

POST/api/v1/remove-video-bg

Asynchronous — the request validates the clip, reserves credits and returns a queued job. Poll GET /api/v1/jobs/{job_id} or listen for webhooks. Requires a Pro plan or higher. Transparent output defaults to an alpha-channel .webm (VP9); backgrounds default to .mp4. Audio is preserved.

Tham sốMô tả
video_file / video_url / video_file_b64Source video — exactly one. MP4, MOV, WebM or AVI; up to 200 MB, 60 s, 1080p.
formatwebm | mov | mp4 | gif | zip_frames (default: webm when transparent, mp4 otherwise).
backgroundtransparent | color | image (default transparent).
bg_colorHex color, white or black — required with background=color.
bg_image_urlBackground image — required with background=image.
fps15 | 24 | 30 — output frame rate (never above the source).
resolutionoriginal | 720p | 1080p — longest side 1280 or 1920 px.
webhook_urlOptional. Receives job.created / started / processing / completed / failed.

Credits: 5 per job + 1 per second, ×1.5 for HD (≥1280 px), +2 for a custom background. The estimate is reserved up front; unused credits are returned when the job finishes, and everything is refunded if it fails or you cancel it (POST /api/v1/jobs/{job_id}/cancel).

# 1. Start the job (returns job_id + status_url)
curl -X POST "https://api.clearcutapi.com/api/v1/remove-video-bg" \
  -H "X-API-Key: clearcut_live_YOUR_KEY" \
  -F "video_file=@/path/to/clip.mp4" \
  -F "format=webm" \
  -F "background=transparent"

# 2. Poll the status_url until status == "completed"
curl "https://api.clearcutapi.com/api/v1/jobs/JOB_ID" \
  -H "X-API-Key: clearcut_live_YOUR_KEY"

Trạng thái tác vụ

{
  "success": true,
  "job_id": "job_8d1e...",
  "type": "video",
  "status": "processing",          // queued | processing | completed | failed | cancelled | expired
  "progress": 45,
  "message": "Removing background from video frames.",
  "result": null,                  // filled in when completed: url, format, width, height, duration, poster_url
  "usage": { "credits_used": 24, "credits_remaining": 976 }
}

Định dạng đầu ra

Định dạngĐộ trong suốtGhi chú
PNGCó (≤10MP)Tốt nhất cho ảnh tách nền
JPGKhôngNhẹ nhất, tối đa 50MP
WebPCóGọn nhẹ, tối đa 50MP
ZIPCócolor.jpg + alpha.png
WebM (video)Có (VP9 alpha)Tốt nhất cho web; phát trực tiếp trên trang
MOV (video)Có (ProRes 4444)Quy trình biên tập
MP4 (video)KhôngCần nền màu/ảnh
GIF (video)1-bitBản xem trước ngắn (≤15 fps, ≤480 px)
ZIP framesCóframes/ + alpha/ + metadata.json

Định dạng ZIP

For apps that composite layers themselves. format=zip on images returns:

color.jpg       # full-color image (RGB, no alpha)
alpha.png       # 8-bit matte: 255 = subject, 0 = background
metadata.json   # width, height, file names

Apply alpha.png as the alpha channel of color.jpg to rebuild the cutout. Video jobs withformat=zip_frames return the same idea per frame:

frames/00001.jpg ...   # color frames
alpha/00001.png  ...   # matching mattes
metadata.json          # frame_count, fps, width, height

Tham chiếu API

URL gốc https://api.clearcutapi.com. Tài liệu OpenAPI tương tác có tại /docs trên máy chủ API.

Phương thứcĐường dẫnXác thựcMục đích
GET/api/v1/healthKhôngService health
POST/api/v1/removebgX-API-KeyRemove an image background (synchronous)
POST/api/v1/remove-video-bgX-API-KeyStart an async video job
GET/api/v1/jobs/{job_id}X-API-Key hoặc bearerJob status, progress and result
POST/api/v1/jobs/{job_id}/cancelX-API-Key hoặc bearerCancel a queued/processing job (refunds credits)
GET/api/v1/remove-video-bg/{job_id}X-API-KeyAlias of job status for video jobs
POST/api/v1/auth/registerKhôngCreate an account + workspace
POST/api/v1/auth/loginKhôngGet access + refresh tokens
POST/api/v1/auth/refreshRefresh tokenRotate tokens
POST/api/v1/auth/logoutBearerRevoke all sessions
GET/api/v1/meBearerCurrent user, workspace, role and credits
GET / POST/api/v1/api-keysBearerList / create API keys
PATCH / DELETE/api/v1/api-keys/{id}BearerEdit restrictions / revoke
POST/api/v1/api-keys/{id}/regenerateBearerRotate a key's secret
GET/api/v1/usageBearerUsage analytics
GET / POST/api/v1/webhooksBearerManage webhook endpoints

Giới hạn tốc độ

Limits apply per API key (your plan's limit, or a lower one you set on the key), per workspace across all keys, per IP address, and per endpoint (video submissions are capped at a quarter of the key limit). Keys can also carry a monthly call cap.

Every API response includes X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset.

HTTP/1.1 429 Too Many Requests
Retry-After: 60

{
  "success": false,
  "error": {
    "code": "rate_limit_exceeded",
    "message": "Rate limit reached (api key). Retry after 60 seconds.",
    "retry_after": 60,
    "request_id": "req_..."
  }
}

Exponential Backoff

On 429 or a 5xx, wait and retry with growing delays: honor Retry-Afterwhen present, otherwise wait 1s, 2s, 4s, 8s… (capped) with random jitter. Don't retry other 4xx errors — fix the request.

import random, time, requests

def remove_bg_with_retry(path, max_attempts=5):
    for attempt in range(max_attempts):
        with open(path, "rb") as fh:
            resp = requests.post(
                "https://api.clearcutapi.com/api/v1/removebg",
                headers={"X-API-Key": "clearcut_live_YOUR_KEY"},
                files={"image_file": fh},
            )
        if resp.status_code != 429 and resp.status_code < 500:
            return resp  # success, or a 4xx you should fix rather than retry
        retry_after = resp.headers.get("Retry-After")
        delay = float(retry_after) if retry_after else min(2 ** attempt, 30)
        time.sleep(delay + random.uniform(0, 0.5))  # jitter
    resp.raise_for_status()

Webhook

Register endpoints in the dashboard to receive signed event notifications (job.completed, job.failed,credits.low, and more). Verify theX-ClearCut-Signature header:

import hmac, hashlib, time

def verify(secret, body, header, tolerance=300):
    parts = dict(p.split("=", 1) for p in header.split(","))
    if abs(time.time() - int(parts["t"])) > tolerance:
        return False
    expected = hmac.new(
        secret.encode(), f"{parts['t']}.{body}".encode(), hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(expected, parts["v1"])

Events: job.created, job.started, job.processing, job.completed, job.failed,credits.low, api_key.rate_limited. Failed deliveries retry with exponential backoff.

You can also pass webhook_url on a single request. Those deliveries are signed with your workspace signing secret (Dashboard → Webhooks → Per-request webhook URLs).

Mã lỗi

Lỗi được trả về trong một cấu trúc nhất quán gồm code ổn định, thông báo và request_id.

missing_api_key · 401invalid_api_key · 401revoked_api_key · 401inactive_tenant · 403ip_not_allowed · 403domain_not_allowed · 403plan_limit · 403insufficient_credits · 402rate_limit_exceeded · 429monthly_limit_exceeded · 429invalid_file_type · 422file_too_large · 413image_too_large · 422video_too_long · 422invalid_image_url · 422invalid_video_url · 422invalid_base64 · 422no_image_source · 422multiple_image_sources · 422validation_error · 422processing_failed · 500storage_failed · 500webhook_failed · 500internal_error · 500

Quy trình

Chain steps into a reusable, versioned pipeline: remove background → QualityGuard gate → compose / AI background → enhance → marketplace export presets → human approval → publish to your store. Every run has a hard max_credits budget, a dry-run quote, step-by-step history and a CSV/JSON manifest. Nothing is published without an approval.

POST/api/v1/workflows/{id}/runs
# Quote first (nothing is charged)
curl -X POST "https://api.clearcutapi.com/api/v1/workflows/WORKFLOW_ID/runs"   -H "X-API-Key: clearcut_live_YOUR_KEY" -H "Content-Type: application/json"   -d '{"inputs": {"asset_ids": ["ASSET_ID"]}, "max_credits": 10, "dry_run": true}'

# Run it under a hard budget, then follow step-by-step progress
curl -X POST "https://api.clearcutapi.com/api/v1/workflows/WORKFLOW_ID/runs"   -H "X-API-Key: clearcut_live_YOUR_KEY" -H "Content-Type: application/json"   -H "Idempotency-Key: catalog-2026-10-24"   -d '{"inputs": {"asset_ids": ["ASSET_ID"]}, "max_credits": 10}'
curl "https://api.clearcutapi.com/api/v1/workflow-runs/RUN_ID" -H "X-API-Key: clearcut_live_YOUR_KEY"

SDK và thư viện

Official SDKs for Python and TypeScript/JavaScript send an Idempotency-Key on every job-creating call, retry 429 and 5xx with exponential backoff (honouring Retry-After), raise typed errors and verify webhook signatures.

# pip install clearcut-api
from clearcut import ClearCut, RateLimitError

cc = ClearCut("clearcut_live_YOUR_KEY")

result = cc.remove_background("product.jpg", format="png")
print(result.url, result.usage.credits_used)

# Async video: start and wait
job = cc.remove_video_background("clip.mp4", format="webm", wait=True)
print(job.result.url)

Prefer generating your own client? Use the OpenAPI schema or import the Postman collection from docs/postman/clearcut.postman_collection.json.

Nhật ký thay đổi API

2026-10-24
  • • Workflows and the Catalog Agent: /workflows, /workflow-runs, budgets, approvals, publishing.
  • • Video Studio: /studio/video/jobs with trim, reframe, blur/AI backgrounds, overlays and multi-export.
  • • AI backgrounds (/backgrounds/generate) and AI erase (/images/inpaint).
  • • Official Python and TypeScript SDKs, Postman collection.
  • • New webhook events: workflow.*, integration.publish_*, subscription.updated.
2026-10-23
  • • Video options: format (webm, mov, mp4, gif, zip_frames), background color/image, fps, resolution, webhook_url.
  • • GET /jobs/{id} accepts API keys and returns progress, message, result and usage. New POST /jobs/{id}/cancel.
  • • API key IP/domain allow-lists, monthly caps, regeneration; workspace, IP and endpoint rate limits.
  • • Per-request webhook_url on image and video requests. Job ids now start with job_.
  • • New error codes: monthly_limit_exceeded, ip_not_allowed, domain_not_allowed, plan_limit.
2026-06-09
  • • Video background removal (async jobs, transparent alpha WebM output, preserved audio).
  • • Signed webhooks for job lifecycle events.
  • • Stripe-ready billing and credit packages.
2026-06-08
  • • Initial release: image background removal, API keys, credits, usage analytics.