示例结果
API 在示例图片上的实际响应记录。



请求与响应
POST https://api.stack.foldbun.com/v1/remove-background,使用 Bearer API 密钥。
请求
# macOS:把 "base64 -w0 sneaker.webp" 换成 "base64 -i sneaker.webp" curl https://api.stack.foldbun.com/v1/remove-background \ -H "Authorization: Bearer $FOLDBUN_API_KEY" \ -H "Content-Type: application/json" \ -d @- <<EOF {"model": "birefnet", "image": {"base64": "$(base64 -w0 sneaker.webp)"}, "options": {"output": "cutout"}} EOF
import base64, os, requests with open("sneaker.webp", "rb") as f: image = base64.b64encode(f.read()).decode() r = requests.post( "https://api.stack.foldbun.com/v1/remove-background", headers={"Authorization": f"Bearer {os.environ['FOLDBUN_API_KEY']}"}, json={"model": "birefnet", "image": {"base64": image}, "options": {"output": "cutout"}}, timeout=60, ) r.raise_for_status() print(r.json()) open("sneaker-cutout.png", "wb").write(base64.b64decode(r.json()["data"]))
响应(节选)
{
"id": "call_01a1913f-131f-7b89-9f1e-7423a3895c99",
"model": "birefnet",
"image": {"height": 1008, "id": "img_d239eb4c…6504", "width": 1791},
"data": {"$file": "sneaker-cutout.webp"},
"format": "png",
"height": 1008,
"width": 1791,
"cost": 1,
"balance": 1233.56
}请求字段
| 字段 | 说明 |
|---|---|
| image | {"base64": "…"},或之前响应返回的 {"id": "img_…"}。 |
| options.output | cutout(默认):主体的 RGBA 图像。matte:8 位灰度 alpha 蒙版。 |
| options.format | png(默认)或 webp。 |
价格示例
| 调用 | 额度 |
|---|---|
| 1 张图 1 | 1 按储值折合约 US$0.001 |
| 1,000 张图 1,000 × 1 | 1000 按储值折合约 US$1.00 |
限制
- 图片
- JPEG、PNG、静态 WebP;最大 20 MiB、4,000 万像素
- 坐标
- 按 EXIF 摆正后的原图的像素;蒙版可以比图小,并附带自己的尺寸
- 每次调用的图片数
- 1
- 输出
- PNG 或 WebP,以 base64 放在
data中,并附width和height - 速率限制
- 取决于账户档位,见
GET /v1/models
常见问题
BiRefNet 如何计费?
每张图 1.0 额度。该模型属于付费池,有余额的账户可用。调用失败不收费。
cutout 和 matte 有什么区别?
cutout 返回主体的 RGBA 图像。matte 返回 8 位灰度 alpha 蒙版,可应用到原图上。
支持哪些输出格式?
png(默认)和 webp。图像以 base64 编码放在 data 中,并附 width 和 height。
相关模型
Foldbun Stack — 按量计费的视觉模型 API
通过 REST API 调用 BiRefNet,请求与响应格式见文档。
阅读文档获取 API 密钥即将推出