Flux Inpaint Serverless API
Flux Inpainting is a powerful image editing tool designed to effortlessly edit and enhance your images. It's perfect for tasks like removing unwanted objects, restoring damaged photos, and creating artistic effects.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-inpaint"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "base64": false,
12 "guidance_scale": 3.5,
13 "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inapint-ip.jpg",
14 "image_format": "jpeg",
15 "mask": "https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inpaint-mask.jpeg",
16 "negative_prompt": "bad quality, painting, blur",
17 "num_inference_steps": 25,
18 "prompt": "huge ship sailing",
19 "quality": 95,
20 "sampler": "euler",
21 "samples": 1,
22 "scheduler": "simple",
23 "seed": 12467,
24 "strength": 0.9
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/flux-inpaint"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "base64": false,
12 "guidance_scale": 3.5,
13 "image": "https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inapint-ip.jpg",
14 "image_format": "jpeg",
15 "mask": "https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inpaint-mask.jpeg",
16 "negative_prompt": "bad quality, painting, blur",
17 "num_inference_steps": 25,
18 "prompt": "huge ship sailing",
19 "quality": 95,
20 "sampler": "euler",
21 "samples": 1,
22 "scheduler": "simple",
23 "seed": 12467,
24 "strength": 0.9
25}
26
27response = requests.post(url, headers=headers, json=data)
28
29if response.status_code == 200:
30 result = response.json()
31 print(json.dumps(result, indent=2))
32else:
33 print(f"Error: {response.status_code}")
34 print(response.text)API Endpoint
https://api.segmind.com/v1/flux-inpaintParameters
imagerequiredstring (uri)Input image
"https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inapint-ip.jpg"maskrequiredstring (uri)Mask image
"https://segmind-sd-models.s3.amazonaws.com/display_images/flux-inpaint-mask.jpeg"promptrequiredstringDescription of the image to be generated
"huge ship sailing"base64optionalbooleanOutput as base64 encoded string
falseguidance_scaleoptionalnumberGuidance scale for the generation
3.5Range: 1 - 10image_formatoptionalstringOutput image format
"jpeg""jpeg""png""webp"negative_promptoptionalstringDescription of what to avoid in the image
"bad quality, painting, blur"num_inference_stepsoptionalintegerNumber of inference steps
25Range: 10 - 75qualityoptionalintegerImage quality setting for output
95Range: 10 - 100sampleroptionalstringSampling method for image generation
"euler""euler""euler_cfg_pp""euler_ancestra""leuler_ancestral_cfg_pp""heun""heunpp2""dpm_2""dpm_2_ancestral""lms""dpm_fast"+16 moresamplesoptionalintegerNumber of samples to generate
1Range: 1 - 4scheduleroptionalstringScheduler for image generation
"simple"seedoptionalintegerRandom seed for generation
12467strengthoptionalnumberStrength of the effect applied
0.9Range: 0 - 1Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out