背景移除 API
PixMiller REST API · v1
上传图片,AI 抠掉背景并返回透明 PNG。同步返回,通常几秒即可。
POST
https://api.pixmiller.com/v1/remove
1
鉴权与请求
在
X-Api-Key: YOUR_API_KEY 请求头中发送你的密钥。在账户页面创建和管理密钥。
| 参数 | 类型 | 必填参数 | 说明 |
|---|---|---|---|
image_file
|
file | 必填* | 待处理图片,multipart 上传。JPG / PNG / WebP,最大 20MB |
image_url
|
string | 必填* | 或一个公开图片 URL(image_file / image_url 二选一) |
size
|
string | 选填 | preview(免费,带水印)/ full(高清,1 点数)/ auto。默认 preview |
format
|
string | 选填 | auto(透明则 PNG,否则 JPG——默认)/ png / jpg |
bg_color
|
string | 选填 | 结果背景:transparent(默认)/ white / 任意 #RRGGBB |
2
代码示例
选择语言并复制——可直接运行。1curl -X POST "https://api.pixmiller.com/v1/remove" \2 -H "X-Api-Key: YOUR_API_KEY" \3 -F "[email protected]" \4 -F "size=full"
1import requests23resp = requests.post(4 "https://api.pixmiller.com/v1/remove",5 headers={"X-Api-Key": "YOUR_API_KEY"},6 files={"image_file": open("product.jpg", "rb")},7 data={"size": "full"},8)9print(resp.json()["url"])
1import fs from "node:fs";23const form = new FormData();4form.append("image_file", new Blob([fs.readFileSync("product.jpg")]), "product.jpg");5form.append("size", "full");6const resp = await fetch("https://api.pixmiller.com/v1/remove", {7 method: "POST",8 headers: { "X-Api-Key": "YOUR_API_KEY" },9 body: form,10});11console.log((await resp.json()).url);
3
响应
1{2 "url": "https://cdn.pixmiller.com/result/8Kd2pQ.png"3}
url
处理后图片的临时 URL(原图会在 3 天后自动删除)。
4
错误
错误会返回对应的 HTTP 状态码,JSON 响应体形如: {"errors":{"code":"…","message":"…"}}.
400
validation error
缺少或无效的 image_file、文件过大,或同时提供了多个图片来源。
401
authentication_failed
X-Api-Key 请求头缺失或无效。
402
not_enough_credit
请求了 size=full,但账户已无高清点数。
422
invalid_image
图片无法处理 —— 尺寸过小、格式不支持,或解码失败。
429
throttled
超出速率限制。请放慢请求,并在 Retry-After 指示的时间后重试。