Synchronous API

Synchronous API

One request returns your background-removal result. Simple code and straightforward operation make this a good starting point for everyday image processing.

POSThttps://api.remox.ai/v1.0/removebg

Processing larger images or building a system that needs to avoid long-held requests? View the asynchronous API →

Quickstart

  1. Request API access · Store your key in the server environment variable REMOX_API_KEY.
  2. Upload your image; the server waits for processing.
  3. 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

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.

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.

FieldRequiredAccepted 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.

  1. If taskId is available, query its status below and download on completion.
  2. 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_KEY

A 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

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

  1. UploadPOST /v1.0/uploads → uploadId
  2. Create taskPOST /v1.0/tasks → 202 + taskId
  3. Poll statusGET /v1.0/tasks/{taskId}
  4. DownloadGET /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

cURL
# 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.png

The 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

HTTPEndpointRequest & response
POST/v1.0/uploadsmultipart file → 201 uploadId
POST/v1.0/tasksJSON {uploadId} + Idempotency-Key → 202 taskId
POST/v1.0/erase/tasksJSON {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_…"}
Rules shared by both modes

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_KEY

No 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-Key

credits.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."
    }
  ]
}
HTTPerrors[].codeErrors
400invalid_request, invalid_fileCheck the request body: image_file for synchronous processing, file for uploads, JSON uploadId for async creation.
400invalid_size, invalid_response_formatUse size=auto and response_format=image or json.
400invalid_idempotency_key, invalid_subjectUse an 8–128 character idempotency key (letters, digits, . _ : -). Omit subject/user headers.
402insufficient_creditsTop up unexpired credits before creating a new task.
403invalid_credentialsThe key is missing, invalid, disabled, revoked or expired. Check your issued pure API key.
403platform_disabled, platform_paused, scope_deniedCustomer access is disabled/paused or the key lacks permission. Contact the provider.
404not_found, upload_not_foundEndpoint/task is unknown, inaccessible to this customer, or the upload expired.
409idempotency_conflictThis key was used for different input: image bytes for sync, or task type/upload IDs for async. Retain the original input on retries.
409result_not_readyThe task is not complete. Query its status before downloading.
410task_expired, result_expiredThe task or download is no longer available. Task retention is 90 days; Worker results expire after 7 days.
413file_too_largeMaximum image file size: 20 MiB (20 × 1024 × 1024 bytes).
415invalid_image, animated_image_unsupportedUse a valid JPG, PNG or static WebP with the matching MIME type.
422image_dimensions_exceededResize before upload: longest side ≤3840 px and shortest side ≤2160 px (4K UHD). The API does not resize for you.
429rate_limit_exceeded, hourly_quota_exhausted, inflight_limit_exceededRespect Retry-After when supplied. Limits depend on your customer configuration.
502upload_failed, upstream_rejected, upstream_unavailableUpstream upload or AI service failed. Check task state before retrying.
502create_result_unknown, remote_service_error, invalid_result, result_unavailable, task_failed, task_timeoutSubmission is uncertain, processing failed, the PNG is invalid/unavailable, or the task timed out. Inspect task status; do not blindly create a duplicate.
503service_not_configured, credit_price_not_configured, server_errorService configuration or a temporary internal error. Retain requestId and contact support if persistent.
504sync_timeoutThe synchronous wait ended after up to 60 seconds. The task may still be running; recover with taskId or the same Idempotency-Key.