{"openapi":"3.1.0","info":{"title":"RemoveBG.vn API","description":"REST API tách nền ảnh bằng AI.\n\n**Xác thực:** gửi header `X-API-Key: rbg_xxx` ở mọi request (lấy key tại trang [Dashboard](/dashboard)).\n\nRate limit theo gói: Free 50 request/tháng & 5 request/phút · Pro 5000/tháng & 60/phút · Enterprise unlimited.","version":"1.0.0"},"paths":{"/":{"get":{"tags":["Web"],"summary":"Index","operationId":"index__get","responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}}}}},"/api-documentation":{"get":{"tags":["Web"],"summary":"Api Documentation","operationId":"api_documentation_api_documentation_get","responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}}}}},"/dashboard":{"get":{"tags":["Web"],"summary":"Dashboard","operationId":"dashboard_dashboard_get","responses":{"200":{"description":"Successful Response","content":{"text/html":{"schema":{"type":"string"}}}}}}},"/web/remove-background":{"post":{"tags":["Web"],"summary":"Web Remove Background","description":"Endpoint nội bộ cho trang chủ — không cần API key.\nBảo mật bằng rate limit theo IP.","operationId":"web_remove_background_web_remove_background_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_web_remove_background_web_remove_background_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/web/remove-background-batch":{"post":{"tags":["Web"],"summary":"Web Remove Background Batch","description":"Xử lý nhiều ảnh cùng lúc cho Web UI (tối đa 10 ảnh).\nTrả về kết quả từng ảnh + link ZIP tải tất cả ảnh thành công.","operationId":"web_remove_background_batch_web_remove_background_batch_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_web_remove_background_batch_web_remove_background_batch_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/web/save-edit":{"post":{"tags":["Web"],"summary":"Web Save Edit","description":"Lưu ảnh kết quả sau khi người dùng chỉnh sửa tay (vẽ xóa) trên Web UI.\nClient gửi PNG từ canvas; server kiểm tra và lưu như một kết quả bình thường.","operationId":"web_save_edit_web_save_edit_post","requestBody":{"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_web_save_edit_web_save_edit_post"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/web/feedback":{"post":{"tags":["Web"],"summary":"Web Feedback","description":"Nhận góp ý chất lượng kết quả từ Web UI (👍/👎 + bình luận tùy chọn).\nDùng để thống kê model nào cho kết quả được hài lòng nhất ở dashboard.","operationId":"web_feedback_web_feedback_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/FeedbackIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/download/{filename}":{"get":{"tags":["Web"],"summary":"Download Result","description":"Tải ảnh kết quả về máy (Content-Disposition: attachment).","operationId":"download_result_download__filename__get","parameters":[{"name":"filename","in":"path","required":true,"schema":{"type":"string","title":"Filename"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/remove-background":{"post":{"tags":["REST API v1"],"summary":"Tách nền từ ảnh upload (multipart/form-data)","operationId":"remove_background_v1_remove_background_post","parameters":[{"name":"X-API-Key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_remove_background_v1_remove_background_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveBGResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/remove-background-url":{"post":{"tags":["REST API v1"],"summary":"Tách nền từ URL ảnh (JSON body)","operationId":"remove_background_url_v1_remove_background_url_post","parameters":[{"name":"X-API-Key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveByUrlIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveBGResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/account/credits":{"get":{"tags":["REST API v1"],"summary":"Xem số credits còn lại","operationId":"account_credits_v1_account_credits_get","parameters":[{"name":"X-API-Key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditsResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/account/usage":{"get":{"tags":["REST API v1"],"summary":"Lịch sử sử dụng API (phân trang)","operationId":"account_usage_v1_account_usage_get","parameters":[{"name":"page","in":"query","required":false,"schema":{"type":"integer","minimum":1,"description":"Số trang","default":1,"title":"Page"},"description":"Số trang"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":100,"minimum":1,"description":"Số dòng mỗi trang (1-100)","default":20,"title":"Limit"},"description":"Số dòng mỗi trang (1-100)"},{"name":"date_from","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Lọc từ ngày, định dạng YYYY-MM-DD","title":"Date From"},"description":"Lọc từ ngày, định dạng YYYY-MM-DD"},{"name":"date_to","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Lọc đến ngày, định dạng YYYY-MM-DD","title":"Date To"},"description":"Lọc đến ngày, định dạng YYYY-MM-DD"},{"name":"X-API-Key","in":"header","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"X-Api-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/UsageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/register":{"post":{"tags":["Auth & API Keys"],"summary":"Register","operationId":"register_auth_register_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RegisterIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/login":{"post":{"tags":["Auth & API Keys"],"summary":"Login","operationId":"login_auth_login_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LoginIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/logout":{"post":{"tags":["Auth & API Keys"],"summary":"Logout","operationId":"logout_auth_logout_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}}}},"/auth/keys":{"get":{"tags":["Auth & API Keys"],"summary":"List Keys","operationId":"list_keys_auth_keys_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}}},"post":{"tags":["Auth & API Keys"],"summary":"Create Key","operationId":"create_key_auth_keys_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}}}}},"/auth/keys/{key_id}/revoke":{"post":{"tags":["Auth & API Keys"],"summary":"Revoke Key","operationId":"revoke_key_auth_keys__key_id__revoke_post","parameters":[{"name":"key_id","in":"path","required":true,"schema":{"type":"string","title":"Key Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/auth/plan":{"post":{"tags":["Auth & API Keys"],"summary":"Change Plan","operationId":"change_plan_auth_plan_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/MessageResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/model-status":{"get":{"tags":["Admin"],"summary":"Trạng thái model + phiên bản rembg","operationId":"model_status_admin_model_status_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/admin/models/{key}/download":{"post":{"tags":["Admin"],"summary":"Tải trước một model","operationId":"download_model_admin_models__key__download_post","parameters":[{"name":"key","in":"path","required":true,"schema":{"type":"string","title":"Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"Body_remove_background_v1_remove_background_post":{"properties":{"image":{"type":"string","contentMediaType":"application/octet-stream","title":"Image","description":"File ảnh: JPG, PNG hoặc WEBP — tối đa 10MB"},"return_format":{"type":"string","title":"Return Format","description":"png | jpg | base64","default":"png"},"size":{"type":"string","title":"Size","description":"auto | full | preview","default":"auto"},"bg_color":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bg Color","description":"Màu nền thay thế, vd: #ffffff. Bỏ trống = trong suốt"},"model":{"type":"string","title":"Model","description":"auto | high | ultra | portrait | anime | fast (hoặc tên model rembg)","default":"auto"},"alpha_matting":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Alpha Matting","description":"true = viền mềm hơn (tóc, lông). Bỏ trống = theo cấu hình server"}},"type":"object","required":["image"],"title":"Body_remove_background_v1_remove_background_post"},"Body_web_remove_background_batch_web_remove_background_batch_post":{"properties":{"files":{"items":{"type":"string","contentMediaType":"application/octet-stream"},"type":"array","title":"Files"},"bg_color":{"type":"string","title":"Bg Color","default":"transparent"},"size":{"type":"string","title":"Size","default":"auto"},"output_format":{"type":"string","title":"Output Format","default":"png"},"model":{"type":"string","title":"Model","default":"auto"},"alpha_matting":{"type":"string","title":"Alpha Matting","default":""}},"type":"object","required":["files"],"title":"Body_web_remove_background_batch_web_remove_background_batch_post"},"Body_web_remove_background_web_remove_background_post":{"properties":{"image":{"type":"string","contentMediaType":"application/octet-stream","title":"Image"},"bg_color":{"type":"string","title":"Bg Color","default":"transparent"},"size":{"type":"string","title":"Size","default":"auto"},"output_format":{"type":"string","title":"Output Format","default":"png"},"model":{"type":"string","title":"Model","default":"auto"},"alpha_matting":{"type":"string","title":"Alpha Matting","default":""}},"type":"object","required":["image"],"title":"Body_web_remove_background_web_remove_background_post"},"Body_web_save_edit_web_save_edit_post":{"properties":{"image":{"type":"string","contentMediaType":"application/octet-stream","title":"Image"}},"type":"object","required":["image"],"title":"Body_web_save_edit_web_save_edit_post"},"CreditsData":{"properties":{"total_credits":{"type":"integer","title":"Total Credits"},"used_credits":{"type":"integer","title":"Used Credits"},"remaining_credits":{"type":"integer","title":"Remaining Credits"},"plan":{"type":"string","title":"Plan"}},"type":"object","required":["total_credits","used_credits","remaining_credits","plan"],"title":"CreditsData"},"CreditsResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"data":{"anyOf":[{"$ref":"#/components/schemas/CreditsData"},{"type":"null"}]},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"}},"type":"object","required":["success"],"title":"CreditsResponse"},"FeedbackIn":{"properties":{"rating":{"type":"string","title":"Rating","description":"\"up\" (tốt) hoặc \"down\" (chưa tốt)"},"comment":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Comment","description":"Bình luận bổ sung (không bắt buộc)"},"model":{"anyOf":[{"type":"string","maxLength":60},{"type":"null"}],"title":"Model","description":"Model AI đã dùng cho kết quả này"},"result_filename":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Result Filename","description":"Tên file kết quả được đánh giá"}},"type":"object","required":["rating"],"title":"FeedbackIn"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"LoginIn":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"password":{"type":"string","title":"Password"}},"type":"object","required":["email","password"],"title":"LoginIn"},"MessageResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"},"data":{"anyOf":[{},{"type":"null"}],"title":"Data"}},"type":"object","required":["success"],"title":"MessageResponse","description":"Response dạng chung cho auth / quản lý key."},"PlanIn":{"properties":{"plan":{"type":"string","title":"Plan","description":"free | pro | enterprise"}},"type":"object","required":["plan"],"title":"PlanIn"},"RegisterIn":{"properties":{"email":{"type":"string","format":"email","title":"Email"},"password":{"type":"string","maxLength":128,"minLength":8,"title":"Password","description":"Mật khẩu tối thiểu 8 ký tự"}},"type":"object","required":["email","password"],"title":"RegisterIn"},"RemoveBGData":{"properties":{"image_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Image Url"},"base64":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Base64"},"credits_used":{"type":"integer","title":"Credits Used","default":1},"credits_remaining":{"type":"integer","title":"Credits Remaining","default":0},"processing_time":{"type":"string","title":"Processing Time","default":""},"image_size":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Image Size"}},"type":"object","title":"RemoveBGData"},"RemoveBGResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"data":{"anyOf":[{"$ref":"#/components/schemas/RemoveBGData"},{"type":"null"}]},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"}},"type":"object","required":["success"],"title":"RemoveBGResponse"},"RemoveByUrlIn":{"properties":{"image_url":{"type":"string","title":"Image Url","description":"URL công khai của ảnh (http/https)"},"return_format":{"type":"string","title":"Return Format","description":"png | jpg | base64","default":"png"},"size":{"type":"string","title":"Size","description":"auto | full | preview","default":"auto"},"bg_color":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Bg Color","description":"Màu nền thay thế, vd: #ffffff (bỏ trống = trong suốt)"},"model":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Model","description":"auto | high | ultra | portrait | anime | fast (hoặc tên model rembg, vd: isnet-general-use)"},"alpha_matting":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Alpha Matting","description":"true = viền mềm hơn (tóc, lông). Bỏ trống = theo cấu hình server"}},"type":"object","required":["image_url"],"title":"RemoveByUrlIn"},"UsageData":{"properties":{"usage":{"items":{"$ref":"#/components/schemas/UsageItem"},"type":"array","title":"Usage"},"total":{"type":"integer","title":"Total"},"page":{"type":"integer","title":"Page"},"limit":{"type":"integer","title":"Limit"}},"type":"object","required":["usage","total","page","limit"],"title":"UsageData"},"UsageItem":{"properties":{"id":{"type":"string","title":"Id"},"endpoint":{"type":"string","title":"Endpoint"},"timestamp":{"type":"string","title":"Timestamp"},"credits_used":{"type":"integer","title":"Credits Used"},"image_size":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Image Size"},"status":{"type":"string","title":"Status"},"processing_time":{"type":"number","title":"Processing Time"}},"type":"object","required":["id","endpoint","timestamp","credits_used","status","processing_time"],"title":"UsageItem"},"UsageResponse":{"properties":{"success":{"type":"boolean","title":"Success"},"data":{"anyOf":[{"$ref":"#/components/schemas/UsageData"},{"type":"null"}]},"message":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Message"}},"type":"object","required":["success"],"title":"UsageResponse"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}}},"tags":[{"name":"REST API v1","description":"Endpoint cho ứng dụng khách tích hợp"},{"name":"Auth & API Keys","description":"Đăng ký / đăng nhập / quản lý API key"},{"name":"Web","description":"Trang HTML và endpoint nội bộ cho Web UI"},{"name":"Admin","description":"Quản trị AI model (dashboard) — yêu cầu đăng nhập"}]}