去背景 API 文档
使用一个 API Key 提交图片,获取透明背景 PNG。
POST
https://api.remox.ai/v1.0/removebg快速开始
申请 API 接入 →将已签发的 Key 保存在服务端,不要暴露在浏览器或 App 中。更换 Key 后,客户身份和余额不变。
REMOX_API_KEY支持 JPG、PNG 和静态 WebP。上传前自行调整尺寸,接口不会自动缩放。
代码示例 →身份验证
将已签发的 Key 保存在服务端,不要暴露在浏览器或 App 中。更换 Key 后,客户身份和余额不变。
| 字段 | 允许值 |
|---|---|
| X-API-Key | remox_live_… / remox_test_… |
| Secret / X-Subuid / X-Platform-User / X-RapidAPI-User | — |
| image_url / Base64 / shadow / refine | — |
代码示例
cURL
# Set REMOX_API_KEY in your environment first.
curl 'https://api.remox.ai/v1.0/removebg' \
-H "X-API-Key: $REMOX_API_KEY" \
-H 'Idempotency-Key: image-0001' \
-F 'image_file=@/path/to/input.jpg' \
-F 'size=auto' \
--max-time 75 --fail-with-body \
-D response-headers.txt -o remox-result.png
# On non-2xx, the output file contains error JSON, not a PNG.支持 JPG、PNG 和静态 WebP。上传前自行调整尺寸,接口不会自动缩放。
input.jpg → image/jpeg · PNG → image/png · WebP → image/webp请求参数
POST /v1.0/removebg · multipart/form-data支持 JPG、PNG 和静态 WebP。上传前自行调整尺寸,接口不会自动缩放。
| 字段 | 必填 | 允许值 |
|---|---|---|
| image_file | ✓ | JPG / PNG / WebP · ≤20 MiB (20 × 1024 × 1024 bytes) · max(width, height) ≤1920 px · min(width, height) ≤1080 px |
| size | — | auto |
| response_format | — | image / json |
| Idempotency-Key | — | 8–128 · A–Z a–z 0–9 . _ : - |
返回结果
200 · PNG
response_format=image · Content-Type: image/pngX-Request-ID · X-Task-ID · X-Idempotency-Key
200 · JSON
response_format=json{
"requestId": "req_…",
"taskId": "task_…",
"data": {
"result_url": "https://storage.example/result.png?signature=…&expires=…"
}
}data.result_url ≠ result_b64超时与重试
60 秒后返回 504,任务可能仍在运行。查询状态,或使用相同图片和 Idempotency-Key 重试,避免重复扣费。
GET /v1.0/tasks/{taskId}{
"requestId": "req_…",
"taskId": "task_…",
"status": "completed",
"progress": null,
"pollAfterMs": 2000,
"result": {
"downloadPath": "/v1.0/tasks/task_…/result",
"mimeType": "image/png",
"expiresAt": "2026-10-17T00:00:00.000Z"
}
}GET /v1.0/tasks/{taskId}/result
GET /v1.0/tasks/{taskId}/result?response_format=jsoncreating → queued → processing → completed / failed / timed_out
Retry-After · pollAfterMs: 2000 · X-API-Key
账户与积分
创建任务时预留积分,成功后扣除,失败或任务到期后释放。同步等待超时本身不会释放积分。
| 字段 | 允许值 |
|---|---|
| credits | available / reserved / consumed |
| GET /v1.0/account | X-API-Key |
| POST → AI | 300 ms |
| POST → 504 | 60 s |
| task → timed_out | 35 min |
| task_expired | 90 d |
| result_expired (Worker) | 7 d |
错误处理
重试前检查 errors 数组和任务状态。保留 requestId 以便排查,不要记录 API Key。
{
"requestId": "req_…",
"retryable": false,
"errors": [
{
"code": "invalid_credentials",
"title": "Invalid API key."
}
]
}| HTTP | errors[].code | 错误处理 |
|---|---|---|
| 400 | invalid_request, invalid_file | 请求参数不正确 |
| 400 | invalid_size, invalid_response_format | 请求参数不正确 |
| 400 | invalid_idempotency_key, invalid_subject | 请求参数不正确 |
| 402 | insufficient_credits | 有效积分不足,请充值 |
| 403 | invalid_credentials | Key 无效或访问受限 |
| 403 | platform_disabled, platform_paused, scope_denied | Key 无效或访问受限 |
| 404 | not_found, upload_not_found | 接口、任务或上传不存在 |
| 409 | idempotency_conflict | 重复请求冲突或任务未完成 |
| 409 | result_not_ready | 重复请求冲突或任务未完成 |
| 410 | task_expired, result_expired | 任务或结果已过期 |
| 413 | file_too_large | 图片文件过大 |
| 415 | invalid_image, animated_image_unsupported | 图片无效或不支持动态图 |
| 422 | image_dimensions_exceeded | 图片尺寸超限,请先缩放 |
| 429 | rate_limit_exceeded, hourly_quota_exhausted, inflight_limit_exceeded | 请求频率或额度超限 |
| 502 | upload_failed, upstream_rejected, upstream_unavailable | 上游调用或结果获取失败 |
| 502 | create_result_unknown, remote_service_error, invalid_result, result_unavailable, task_failed, task_timeout | 上游调用或结果获取失败 |
| 503 | service_not_configured, credit_price_not_configured, server_error | 服务配置异常或暂不可用 |
| 504 | sync_timeout | 同步等待超时,请查询任务状态 |
retryable: 429 / 5xx
60 秒后返回 504,任务可能仍在运行。查询状态,或使用相同图片和 Idempotency-Key 重试,避免重复扣费。
兼容性
此接口仅支持纯 Key 去背景,不完整兼容 remove.bg 的全部功能。JSON 结果地址是 REMOX 扩展。
申请 API 接入 →