Background Removal API — Human, Product & Universal Modes
收藏Background Removal API — Human, Product & Universal Modes 数据集概述
数据集名称
Background Removal API — Human, Product & Universal Modes
数据集提供方
APISphere
数据集类别
Video, Images
数据集概述
Remove backgrounds from images using universal, human, or product pipelines. Choose output format: transparent, white background, mask, or cropped subject.
主要功能与特点
- 三种处理管道:通用(universal)、人像(human)和产品(product),针对不同主体类型优化结果。
- 四种输出格式:透明背景(transparent)、白色背景(white_bg)、主体掩膜(mask)或主体裁剪(crop)。
- 单一端点:一个URL覆盖所有管道和格式组合。
- 直接二进制输出:接收可直接使用的已处理图像。
- 广泛的格式支持:接受JPEG、PNG、BMP、WEBP和GIF格式。
- 一致的错误格式:错误时返回标准的
meta、data、warnings、error信封结构。
目标用户
✅ 适用对象
- 需要自动化产品照片背景移除的电子商务平台。
- 提供背景移除功能的照片编辑应用。
- 创建透明背景素材的平面设计师。
- 需要分离主体的肖像和头像服务。
- 准备干净视觉素材的营销团队。
- 构建批量图像处理流程的开发人员。
❌ 不适用对象
- 用新图像替换背景(此API仅移除,不替换)。
- 分别分割多个不同的对象。
- 实时视频背景移除(此为单图像端点)。
- 仅提取头部区域(请使用头部提取端点)。
端点详情
- 端点:
POST /v1/remove-bg/universal - 描述:上传图像,选择检测管道和输出格式,接收背景移除后的结果。
请求参数
| 参数 | 类型 | 是否必需 | 默认值 | 描述 |
|---|---|---|---|---|
image |
file | 是 | — | 源图像(JPEG, PNG, BMP, WEBP, GIF)。最大10 MB。 |
subject |
string | 否 | universal |
检测管道:universal、human、product。 |
output_format |
string | 否 | transparent |
输出格式:transparent、white_bg、mask、crop。 |
输出格式详情
transparent:主体位于透明背景上(PNG格式)。white_bg:主体位于纯白色背景上。mask:显示检测到的主体区域的二进制掩膜。crop:裁剪至主体边界框。
响应
- 成功:直接返回二进制图像数据,
Content-Type为image/png或image/jpeg。 - 错误:返回包含
meta、data、warnings、error字段的标准错误信封。
验证与错误
- 缺少文件:
image字段为必填项,缺失则返回400错误。 - 无效格式:仅接受JPEG、PNG、BMP、WEBP和GIF文件,其他格式返回
400错误。 - 文件过大:超过10 MB的图像将被拒绝,返回
400错误。 - 无效主体类型:
subject必须为universal、human或product,无效值返回400错误。 - 无效输出格式:
output_format必须为transparent、white_bg、mask或crop,无效值返回400错误。 - 上游错误:如果处理服务超时或失败,则返回
502错误。 - 服务器错误:意外故障返回
500状态码,详细信息在error字段中。 - 所有错误响应均遵循相同的信封结构:
{ "meta": {...}, "data": null, "warnings": [], "error": { ... } }。
示例请求
curl -X POST "https://your-rapidapi-host/v1/remove-bg/universal" -H "X-RapidAPI-Key: YOUR_API_KEY" -F "image=@product-photo.jpg" -F "subject=product" -F "output_format=white_bg"
示例响应(错误情况)
{ "meta": { "requestId": "e7f8a9b0-c1d2-3456-e012-789012345678", "createdAt": "2026-02-17T17:40:22.456Z", "processingMs": 0 }, "data": null, "warnings": [], "error": { "code": "VALIDATION_ERROR", "message": "Missing or empty image file", "details": [ { "field": "image", "issue": "File is required and cannot be empty" } ] } }



