Magic Eraser Serverless API
LaMA Object Removal- AI Magic Eraser
~0.78s
~$0
1import requests
2import json
3
4url = "https://api.segmind.com/v1/magic-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/ai-majic-erase-ip.jpg",
12 "mask": "https://segmind-sd-models.s3.amazonaws.com/display_images/ai-majic-erase-mask.jpeg",
13 "invert_mask": false,
14 "grow_mask": 10,
15 "seed": 468685,
16 "base64": false
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/magic-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/ai-majic-erase-ip.jpg",
12 "mask": "https://segmind-sd-models.s3.amazonaws.com/display_images/ai-majic-erase-mask.jpeg",
13 "invert_mask": false,
14 "grow_mask": 10,
15 "seed": 468685,
16 "base64": false
17}
18
19response = requests.post(url, headers=headers, json=data)
20
21if response.status_code == 200:
22 result = response.json()
23 print(json.dumps(result, indent=2))
24else:
25 print(f"Error: {response.status_code}")
26 print(response.text)API Endpoint
POST
https://api.segmind.com/v1/magic-eraserParameters
imagerequiredstring (uri)Upload your input image
maskrequiredstring (uri)Upload your mask image (part of the image to be removed)
base64optionalbooleanBase64 encoding of the output image.
Default:
falsegrow_maskoptionalintegerSelectively expand image regions
Default:
10Range: 0 - 100invert_maskoptionalbooleanRefers to the inverting the mask.
Default:
falseseedoptionalintegerSeed for image generation.
Default:
-1Range: -1 - 999999999999999Response Type
Returns: Image
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