cURL
curl "https://api.ruseo.cn/api/rembg?key=YOUR_API_KEY&image=demo&url=https%3A%2F%2Fexample.com%2Fphoto.jpg&model=u2net&return_url=true"
基于rembg一键AI抠图去背景,支持上传图片或URL,返回透明背景PNG。可选择返回图片URL(默认)或直接返回二进制PNG数据。
https://api.ruseo.cn/api/rembg
接口调用前需要确认的核心配置。
/api/rembgrembg必填参数必须传入,示例值可直接用于联调。
| 参数名 | 必填 | 类型 | 说明 | 示例值 |
|---|---|---|---|---|
key |
是 | string | VIP会员专享API,需要审核通过的ApiKey。请注册账号并升级VIP后使用。 | YOUR_API_KEY |
image |
否 | file | 上传的图片文件(multipart/form-data),与url二选一 | |
url |
否 | string | 图片远程URL,与image二选一 | https://example.com/photo.jpg |
model |
否 | string | 抠图模型。u2net=通用(默认) u2netp=轻量快速 u2net_human_seg=人像 u2net_cloth_seg=服装 isnet-general-use=高精度 isnet-anime=动漫 silueta=轻量人像 | u2net |
return_url |
否 | string | true=返回JSON含URL(默认) false=直接返回PNG二进制图片流 | true |
优先使用示例地址测试请求参数是否正确。
https://api.ruseo.cn/api/rembg?key=YOUR_API_KEY&image=demo&url=https%3A%2F%2Fexample.com%2Fphoto.jpg&model=u2net&return_url=true
curl "https://api.ruseo.cn/api/rembg?key=YOUR_API_KEY&image=demo&url=https%3A%2F%2Fexample.com%2Fphoto.jpg&model=u2net&return_url=true"
$url = 'https://api.ruseo.cn/api/rembg?key=YOUR_API_KEY&image=demo&url=https%3A%2F%2Fexample.com%2Fphoto.jpg&model=u2net&return_url=true';
$response = file_get_contents($url);
$data = json_decode($response, true);
fetch('https://api.ruseo.cn/api/rembg?key=YOUR_API_KEY&image=demo&url=https%3A%2F%2Fexample.com%2Fphoto.jpg&model=u2net&return_url=true')
.then(res => res.json())
.then(data => console.log(data));
实际返回内容以接口脚本处理结果为准。
{
"code": 0,
"msg": "success",
"data": {
"route": "rembg",
"example": true
}
}
| 参数名 | 类型 | 说明 | 示例值 |
|---|---|---|---|
result_url |
string | 抠图完成后的图片URL | https://api.ruseo.cn/results/abc.png |
result_base_url |
string | 抠图后图片的相对路径 | /results/abc.png |
original_size |
string | 原始图片尺寸(宽x高) | 800x600 |
process_time_ms |
integer | 处理耗时(毫秒) | 4500 |
点击左侧“发送请求”查看结果...