Background Eraser

Background Eraser helps in flawless background removal with exceptional accuracy.

~0.78s
~$0.001
 1import requests
 2import json
 3
 4url = "https://api.segmind.com/v1/background-eraser"
 5headers = {
 6    "x-api-key": "YOUR_API_KEY",
 7    "Content-Type": "application/json"
 8}
 9
10data = {
11    "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/background-eraser-ip.png",
12    "return_mask": true,
13    "invert_mask": false,
14    "grow_mask": 0,
15    "base64": false
16}
17
18response = requests.post(url, headers=headers, json=data)
19
20if response.status_code == 200:
21    result = response.json()
22    print(json.dumps(result, indent=2))
23else:
24    print(f"Error: {response.status_code}")
25    print(response.text)

API Endpoint

POSThttps://api.segmind.com/v1/background-eraser

Parameters

imagerequired
string (uri)

upload your input image

return_maskrequired
boolean

Check this to obtain the mask as the output.

Default: true
base64optional
boolean

Base64 encoding of the output image.

Default: false
grow_maskoptional
integer

Selectively expand image regions

Default: 0Range: 0 - 50
invert_maskoptional
boolean

Refers to inverting the mask.

Default: false

Response Type

Returns: Text/JSON

Common Error Codes

The API returns standard HTTP status codes. Detailed error messages are provided in the response body.

400

Bad Request

Invalid parameters or request format

401

Unauthorized

Missing or invalid API key

403

Forbidden

Insufficient permissions

404

Not Found

Model or endpoint not found

406

Insufficient Credits

Not enough credits to process request

429

Rate Limited

Too many requests

500

Server Error

Internal server error

502

Bad Gateway

Service temporarily unavailable

504

Timeout

Request timed out