Synchronous API
One request returns your background-removal result. Simple code and straightforward operation make this a good starting point for everyday image processing.
https://api.remox.ai/v1.0/removebgProcessing larger images or building a system that needs to avoid long-held requests? View the asynchronous API →
Quickstart
- Request API access · Store your key in the server environment variable REMOX_API_KEY.
- Upload your image; the server waits for processing.
- Save the PNG response on success.
The request follows the conventions in the remove.bg documentation: X-API-Key authentication, image_file upload and size=auto. Use the REMOX parameters and limits documented here.
Reference: remove.bg API documentation ↗Synchronous examples
# 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.Examples allow a 75-second client timeout for the server’s 60-second wait. Generate and save an Idempotency-Key for each new operation; reuse it for retries.
Request reference
multipart/form-data · Both modes accept JPG, PNG and static WebP up to 20 MiB, with longest side ≤3840 px and shortest side ≤2160 px. Images are not resized. Async does not increase image limits or change AI processing speed.
| Field | Required | Accepted value |
|---|---|---|
| image_file | ✓ | Image file; field name is not file |
| size | — | auto |
| response_format | — | image (default) / json |
| Idempotency-Key | — | Recommended header, 8–128 characters: letters, digits, . _ : - |
Responses
200 · PNG
The default response contains image/png bytes and X-Task-ID. Non-2xx responses contain error JSON, not an image.
200 · JSON
Add response_format=json to the same request to wait for completion and receive the complete upstream result URL.
{
"requestId": "req_…",
"taskId": "task_…",
"data": {
"result_url": "https://storage.example/result.png?signature=…"
}
}Timeouts & retries
After 60 seconds, 504 may mean the task is still running. Query its status or retry with the same image and Idempotency-Key to avoid duplicate charges.
- If taskId is available, query its status below and download on completion.
- Without taskId, retry the synchronous POST with the same image and Idempotency-Key.
GET /v1.0/tasks/{taskId}
GET /v1.0/tasks/{taskId}/result
X-API-Key: YOUR_REMOX_API_KEYA 504 does not cancel the task. Do not create an async replacement: synchronous and asynchronous requests do not deduplicate across endpoints and a new submission is a separate billable operation.
Compatibility
The interface follows familiar remove.bg conventions but does not implement its entire API. Only documented parameters are accepted; image_url, Base64 input, shadow and refine are unsupported. response_format and data.result_url are REMOX extensions; result_b64 is not returned. The synchronous endpoint supports background removal only.
Need asynchronous processing or object erasure? View the async API →Asynchronous API
Submit a task, then query its result. Useful for larger images, longer processing and systems that prioritize concurrency and responsiveness without holding a request open until AI processing finishes.
Both modes accept JPG, PNG and static WebP up to 20 MiB, with longest side ≤3840 px and shortest side ≤2160 px. Images are not resized. Async does not increase image limits or change AI processing speed.
Prefer a simpler integration? Return to the synchronous API →
Four steps to process an image
- Upload
POST /v1.0/uploads → uploadId - Create task
POST /v1.0/tasks → 202 + taskId - Poll status
GET /v1.0/tasks/{taskId} - Download
GET /v1.0/tasks/{taskId}/result
Upload with multipart file, then create a task with JSON and a required Idempotency-Key. Creation returns 202 and taskId without waiting for AI completion. Poll GET /v1.0/tasks/{taskId} using pollAfterMs; check status even when HTTP is 200. Completed tasks provide result.downloadPath. Failed or timed_out tasks provide errors[].code and errors[].title.
Asynchronous examples
# Upload (file, not image_file). Requires jq.
BASE=https://api.remox.ai
UPLOAD_ID=$(curl --fail-with-body "$BASE/v1.0/uploads" \
-H "X-API-Key: $REMOX_API_KEY" -F 'file=@input.jpg' | jq -er '.uploadId')
# Save this key and uploadId before POST; reuse both if the response is lost.
IDEMPOTENCY_KEY=$(uuidgen)
curl --fail-with-body "$BASE/v1.0/tasks" \
-H "X-API-Key: $REMOX_API_KEY" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-H 'Content-Type: application/json' \
-d "{\"uploadId\":\"$UPLOAD_ID\"}" -o task.json
TASK_ID=$(jq -er '.taskId' task.json)
# Repeat GET after pollAfterMs (normally 2000 ms), until terminal status.
curl --fail-with-body "$BASE/v1.0/tasks/$TASK_ID" -H "X-API-Key: $REMOX_API_KEY"
# Download only when status is completed.
curl --fail-with-body "$BASE/v1.0/tasks/$TASK_ID/result" \
-H "X-API-Key: $REMOX_API_KEY" -o result.pngThe same seven example languages are available for both modes. cURL demonstrates each request; Python, Node.js, PHP, Go, C# and Java include upload, task creation, polling and download. See each example’s opening comments for dependencies and run instructions. Set REMOX_API_KEY on your server; never expose it in browser code. Retain uploadId, taskId and the idempotency key. Running the entire example again creates a new operation.
Request reference
| HTTP | Endpoint | Request & response |
|---|---|---|
| POST | /v1.0/uploads | multipart file → 201 uploadId |
| POST | /v1.0/tasks | JSON {uploadId} + Idempotency-Key → 202 taskId |
| POST | /v1.0/erase/tasks | JSON {uploadId, maskUploadId} + Idempotency-Key → 202 taskId |
Use file for uploads, not the synchronous image_file field. Creation requires Idempotency-Key: 8–128 letters, digits, . _ : -. Send X-API-Key on every request.
{
"requestId": "req_…",
"taskId": "task_…",
"status": "creating",
"progress": null,
"pollAfterMs": 2000,
"replayed": false
}Task status and results
creating → queued → processing → completed / failed / timed_out
202 means accepted locally, not guaranteed success. Poll according to pollAfterMs (normally 2000 ms); respect Retry-After on 429. Even HTTP 200 status queries require checking status; failure details are in errors.
{
"taskId": "task_…",
"status": "completed",
"pollAfterMs": 2000,
"result": {
"downloadPath": "/v1.0/tasks/task_…/result",
"mimeType": "image/png",
"expiresAt": "2026-12-01T00:00:00Z"
}
}After completion, download result.downloadPath or append ?response_format=json to /result to obtain data.result_url. Signed URLs may expire; download promptly. Downloads before completion return 409.
Retries and recovery
Retry creation with the same route, uploadId, maskUploadId (if any) and Idempotency-Key. Replays return 202 while pending or 200 when terminal; different input returns 409. Re-uploading produces a new uploadId. Synchronous and asynchronous creation do not deduplicate across endpoints: recover a synchronous timeout through its original taskId or original POST.
Uploads last 7 days, processing has a 35-minute deadline, task access lasts 90 days and results normally last 7 days. No webhook is provided. Stopping client polling does not cancel a task or immediately release credits.
Optional: object erasure
Upload the original image and a same-size mask separately: white erases, black preserves. Submit the following JSON with a new idempotency key; polling and downloads use the same task endpoints. Erasure preserves PNG/JPEG/WebP; save according to Content-Type.
POST /v1.0/erase/tasks
X-API-Key: YOUR_REMOX_API_KEY
Idempotency-Key: erase-example-0001
Content-Type: application/json
{"uploadId":"upl_…","maskUploadId":"upl_…"}Authentication
Keep your issued key on your server. Never expose it in a browser or app. Key rotation retains your customer identity and balance.
X-API-Key: YOUR_REMOX_API_KEYNo Secret is required. Omit X-Subuid, X-Platform-User and X-RapidAPI-User; the key resolves its customer and sub-0 balance. Legacy Key + Secret credentials cannot be used here.
Account & credits
Synchronous and asynchronous requests share the same customer sub-0 balance, quotas and configured price for the same operation. Uploading, polling, downloads and idempotent replays do not charge processing credits. Tasks reserve credits at creation, consume them on success and release them on failure or task expiry.
GET /v1.0/account · X-API-Keycredits.available / reserved / consumed
Errors
Inspect the errors array and task status before retrying. Keep requestId for support; never log your API key.
{
"requestId": "req_…",
"retryable": false,
"errors": [
{
"code": "invalid_credentials",
"title": "Invalid API key."
}
]
}| HTTP | errors[].code | Errors |
|---|---|---|
| 400 | invalid_request, invalid_file | Check the request body: image_file for synchronous processing, file for uploads, JSON uploadId for async creation. |
| 400 | invalid_size, invalid_response_format | Use size=auto and response_format=image or json. |
| 400 | invalid_idempotency_key, invalid_subject | Use an 8–128 character idempotency key (letters, digits, . _ : -). Omit subject/user headers. |
| 402 | insufficient_credits | Top up unexpired credits before creating a new task. |
| 403 | invalid_credentials | The key is missing, invalid, disabled, revoked or expired. Check your issued pure API key. |
| 403 | platform_disabled, platform_paused, scope_denied | Customer access is disabled/paused or the key lacks permission. Contact the provider. |
| 404 | not_found, upload_not_found | Endpoint/task is unknown, inaccessible to this customer, or the upload expired. |
| 409 | idempotency_conflict | This key was used for different input: image bytes for sync, or task type/upload IDs for async. Retain the original input on retries. |
| 409 | result_not_ready | The task is not complete. Query its status before downloading. |
| 410 | task_expired, result_expired | The task or download is no longer available. Task retention is 90 days; Worker results expire after 7 days. |
| 413 | file_too_large | Maximum image file size: 20 MiB (20 × 1024 × 1024 bytes). |
| 415 | invalid_image, animated_image_unsupported | Use a valid JPG, PNG or static WebP with the matching MIME type. |
| 422 | image_dimensions_exceeded | Resize before upload: longest side ≤3840 px and shortest side ≤2160 px (4K UHD). The API does not resize for you. |
| 429 | rate_limit_exceeded, hourly_quota_exhausted, inflight_limit_exceeded | Respect Retry-After when supplied. Limits depend on your customer configuration. |
| 502 | upload_failed, upstream_rejected, upstream_unavailable | Upstream upload or AI service failed. Check task state before retrying. |
| 502 | create_result_unknown, remote_service_error, invalid_result, result_unavailable, task_failed, task_timeout | Submission is uncertain, processing failed, the PNG is invalid/unavailable, or the task timed out. Inspect task status; do not blindly create a duplicate. |
| 503 | service_not_configured, credit_price_not_configured, server_error | Service configuration or a temporary internal error. Retain requestId and contact support if persistent. |
| 504 | sync_timeout | The synchronous wait ended after up to 60 seconds. The task may still be running; recover with taskId or the same Idempotency-Key. |
