This is the RESTful API for our AI Solution for Background or Foreground Removal. This solution allows clients to remove background or foreground from images without need to resize it, keeping or removing then just the main object visible.
Apart from the standard RapidAPI security headers, one (and only one) of the following parameters must be sent in order for this API to function correctly:
image_url
| Form data
– this should be a fully qualified, publicly-accessible URL to an image, which should be passed in the form body.image_base64
| Form data
– this should be a URL and filename - safe base64(url) encoded image.Also, there are some other optional Form data parameters that we are able to set up on your API request:
output_format
| default: url
– Image format from the image result (url
or base64
).to_remove
| default: background
– Element to remove the input image result (background
or foreground
).color_removal
| default: transparent
– Color from the removed or erased part (transparent
or white
).If you successfully send a valid request, you will receive a response similar to the example below:
{
"error": "false",
"correlation_id": "02011199-9769-4999-b2c7-8d32cb17fc49",
"response": {
"image_url": "https://example.com/image.png"
}
}
The response can be broken down as follows:
error
– indicates whether there was an error or not (will still result in an HTTP 200 response code even if there was an error).correlation_id
– a randomly generated identifier for identification and support purposes.response.image_url
– image public-accessible URL pointing to the output image.These are the different error situations that can occur:
HTTP 429
– too many concurrent requestsHTTP 200
| error_id: 001
– internal system errorHTTP 200
| error_id: 002
– invalid image providedHTTP 200
| error_id: 003
– invalid URL or required parameters not specified.You should implement a retry strategy (ideally with exponential back-off) if you receive one of the above errors. For example, retry up to 3 times with a progressively longer sleep time between attempts.