Skip to main content
POST
/
inpaint
Inpaint parts of an image
curl --request POST \
  --url https://modelslab.com/api/v6/images/inpaint \
  --header 'Content-Type: application/json' \
  --data '
{
  "key": "<string>",
  "model_id": "<string>",
  "init_image": "<string>",
  "mask_image": "<string>",
  "prompt": "<string>",
  "negative_prompt": "<string>",
  "enhance_prompt": "yes",
  "width": 512,
  "height": 512,
  "samples": 1,
  "num_inference_steps": 31,
  "safety_checker": false,
  "safety_checker_type": "sensitive_content_text",
  "seed": 123,
  "guidance_scale": 7.5,
  "use_karras_sigmas": true,
  "algorithm_type": "none",
  "vae": "<string>",
  "lora_strength": 123,
  "lora_model": "<string>",
  "clip_skip": 2,
  "base64": false,
  "temp": false,
  "webhook": "<string>",
  "track_id": "<string>",
  "ip_adapter_scale": 0.5,
  "ip_adapter_image": "<string>",
  "strength": 0.5
}
'
import requests

url = "https://modelslab.com/api/v6/images/inpaint"

payload = {
"key": "<string>",
"model_id": "<string>",
"init_image": "<string>",
"mask_image": "<string>",
"prompt": "<string>",
"negative_prompt": "<string>",
"enhance_prompt": "yes",
"width": 512,
"height": 512,
"samples": 1,
"num_inference_steps": 31,
"safety_checker": False,
"safety_checker_type": "sensitive_content_text",
"seed": 123,
"guidance_scale": 7.5,
"use_karras_sigmas": True,
"algorithm_type": "none",
"vae": "<string>",
"lora_strength": 123,
"lora_model": "<string>",
"clip_skip": 2,
"base64": False,
"temp": False,
"webhook": "<string>",
"track_id": "<string>",
"ip_adapter_scale": 0.5,
"ip_adapter_image": "<string>",
"strength": 0.5
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
key: '<string>',
model_id: '<string>',
init_image: '<string>',
mask_image: '<string>',
prompt: '<string>',
negative_prompt: '<string>',
enhance_prompt: 'yes',
width: 512,
height: 512,
samples: 1,
num_inference_steps: 31,
safety_checker: false,
safety_checker_type: 'sensitive_content_text',
seed: 123,
guidance_scale: 7.5,
use_karras_sigmas: true,
algorithm_type: 'none',
vae: '<string>',
lora_strength: 123,
lora_model: '<string>',
clip_skip: 2,
base64: false,
temp: false,
webhook: '<string>',
track_id: '<string>',
ip_adapter_scale: 0.5,
ip_adapter_image: '<string>',
strength: 0.5
})
};

fetch('https://modelslab.com/api/v6/images/inpaint', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://modelslab.com/api/v6/images/inpaint",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'key' => '<string>',
'model_id' => '<string>',
'init_image' => '<string>',
'mask_image' => '<string>',
'prompt' => '<string>',
'negative_prompt' => '<string>',
'enhance_prompt' => 'yes',
'width' => 512,
'height' => 512,
'samples' => 1,
'num_inference_steps' => 31,
'safety_checker' => false,
'safety_checker_type' => 'sensitive_content_text',
'seed' => 123,
'guidance_scale' => 7.5,
'use_karras_sigmas' => true,
'algorithm_type' => 'none',
'vae' => '<string>',
'lora_strength' => 123,
'lora_model' => '<string>',
'clip_skip' => 2,
'base64' => false,
'temp' => false,
'webhook' => '<string>',
'track_id' => '<string>',
'ip_adapter_scale' => 0.5,
'ip_adapter_image' => '<string>',
'strength' => 0.5
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://modelslab.com/api/v6/images/inpaint"

payload := strings.NewReader("{\n \"key\": \"<string>\",\n \"model_id\": \"<string>\",\n \"init_image\": \"<string>\",\n \"mask_image\": \"<string>\",\n \"prompt\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"enhance_prompt\": \"yes\",\n \"width\": 512,\n \"height\": 512,\n \"samples\": 1,\n \"num_inference_steps\": 31,\n \"safety_checker\": false,\n \"safety_checker_type\": \"sensitive_content_text\",\n \"seed\": 123,\n \"guidance_scale\": 7.5,\n \"use_karras_sigmas\": true,\n \"algorithm_type\": \"none\",\n \"vae\": \"<string>\",\n \"lora_strength\": 123,\n \"lora_model\": \"<string>\",\n \"clip_skip\": 2,\n \"base64\": false,\n \"temp\": false,\n \"webhook\": \"<string>\",\n \"track_id\": \"<string>\",\n \"ip_adapter_scale\": 0.5,\n \"ip_adapter_image\": \"<string>\",\n \"strength\": 0.5\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://modelslab.com/api/v6/images/inpaint")
.header("Content-Type", "application/json")
.body("{\n \"key\": \"<string>\",\n \"model_id\": \"<string>\",\n \"init_image\": \"<string>\",\n \"mask_image\": \"<string>\",\n \"prompt\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"enhance_prompt\": \"yes\",\n \"width\": 512,\n \"height\": 512,\n \"samples\": 1,\n \"num_inference_steps\": 31,\n \"safety_checker\": false,\n \"safety_checker_type\": \"sensitive_content_text\",\n \"seed\": 123,\n \"guidance_scale\": 7.5,\n \"use_karras_sigmas\": true,\n \"algorithm_type\": \"none\",\n \"vae\": \"<string>\",\n \"lora_strength\": 123,\n \"lora_model\": \"<string>\",\n \"clip_skip\": 2,\n \"base64\": false,\n \"temp\": false,\n \"webhook\": \"<string>\",\n \"track_id\": \"<string>\",\n \"ip_adapter_scale\": 0.5,\n \"ip_adapter_image\": \"<string>\",\n \"strength\": 0.5\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://modelslab.com/api/v6/images/inpaint")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"key\": \"<string>\",\n \"model_id\": \"<string>\",\n \"init_image\": \"<string>\",\n \"mask_image\": \"<string>\",\n \"prompt\": \"<string>\",\n \"negative_prompt\": \"<string>\",\n \"enhance_prompt\": \"yes\",\n \"width\": 512,\n \"height\": 512,\n \"samples\": 1,\n \"num_inference_steps\": 31,\n \"safety_checker\": false,\n \"safety_checker_type\": \"sensitive_content_text\",\n \"seed\": 123,\n \"guidance_scale\": 7.5,\n \"use_karras_sigmas\": true,\n \"algorithm_type\": \"none\",\n \"vae\": \"<string>\",\n \"lora_strength\": 123,\n \"lora_model\": \"<string>\",\n \"clip_skip\": 2,\n \"base64\": false,\n \"temp\": false,\n \"webhook\": \"<string>\",\n \"track_id\": \"<string>\",\n \"ip_adapter_scale\": 0.5,\n \"ip_adapter_image\": \"<string>\",\n \"strength\": 0.5\n}"

response = http.request(request)
puts response.read_body
{
  "status": "success",
  "generationTime": 123,
  "id": 123,
  "output": [
    "<string>"
  ],
  "proxy_links": [
    "<string>"
  ],
  "meta": {},
  "nsfw_content_detected": true,
  "webhook_status": "<string>",
  "tip": "<string>"
}
{
"status": "error",
"message": "<string>"
}
{
"status": "error",
"message": "<string>"
}
{
"status": "error",
"message": "<string>"
}
Inpainting endpoint result
You can find a list of the public models available and their IDs here

Request

Make a POST request to below endpoint and pass the required parameters as a request body.
curl
--request POST 'https://modelslab.com/api/v6/images/inpaint' \

Body

json
{  
    "key": "your_api_key",  
    "model_id": "lazymixv4-inpaint",  
    "prompt": "a cat sitting on a bench",  
    "negative_prompt": null,  
    "init_image": "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo.png",  
    "mask_image": "https://raw.githubusercontent.com/CompVis/stable-diffusion/main/data/inpainting_examples/overture-creations-5sI6fQgYIuo_mask.png",  
    "width": "512",  
    "height": "512",  
    "samples": "1",  
    "steps": "21",  
    "safety_checker": "no",  
    "guidance_scale": 7.5,  
    "strength": 0.7,  
    "scheduler": "UniPCMultistepScheduler",  
    "lora_model": null,  
    "use_karras_sigmas": "yes",  
    "vae": null,  
    "lora_strength": null,  
    "seed": null,  
    "webhook": null,  
    "track_id": null
} 

Body

application/json
key
string
required

Your API Key used for request authorization.

model_id
string
required

The ID of the model to be used. It can be a public model or one you have trained.

init_image
string<uri>
required

URL of the initial image.

mask_image
string<uri>
required

URL of the mask image for inpainting.

prompt
string

A text description of what you want in the generated image.

negative_prompt
string

Items you don't want in the image.

enhance_prompt
boolean
default:yes

If true, the prompt will be enhanced for better results. Default is (true).

width
integer
default:512

The width of the image in pixels.

Required range: x <= 1024
height
integer
default:512

The height of the image in pixels.

Required range: x <= 1024
samples
integer
default:1

The number of images to be returned in response. Maximum is 4.

Required range: x <= 4
num_inference_steps
integer
default:31

The number of denoising steps. Values range from 1 to 20, and any value above 20 will be capped at 20.

Required range: 1 <= x <= 20
safety_checker
boolean
default:false

A checker for NSFW images. If detected, such images will be replaced by a blank image.

safety_checker_type
enum<string>
default:sensitive_content_text

How to modify the image if NSFW content is found.

Available options:
blur,
sensitive_content_text,
pixelate,
black
seed
integer | null

Seed for reproducible results. The same seed generates the same image. Pass null for a random number.

guidance_scale
number
default:7.5

Scale for classifier-free guidance.

Required range: 1 <= x <= 20
use_karras_sigmas
boolean
default:true

Use Karras sigmas to generate images. Produces nice results.

algorithm_type
enum<string>
default:none

Used in DPMSolverMultistepScheduler scheduler.

Available options:
none,
dpmsolver+++
vae
string | null

Use a custom VAE for generating images. Default is null.

lora_strength
integer

Strength of the LoRa model(s). If multiple LoRa models, provide comma-separated values (0.1 to 1).

lora_model
string

LoRa model ID(s). Multiple LoRa models are supported; pass comma-separated values (e.g., 'contrast-fix,yae-miko-genshin').

clip_skip
integer
default:2

Number of CLIP layers to skip.

Required range: 1 <= x <= 8
base64
boolean
default:false

If true, response output is base64 string. Input images can also be base64.

temp
boolean
default:false

If true, stores image in temporary storage (cleaned every 24 hours).

webhook
string<uri>

URL to receive a POST API call once image generation is complete.

track_id
string

Unique ID used in webhook response to identify the request.

ip_adapter_id
enum<string>

IP adapter ID.

Available options:
ip-adapter_sdxl,
ip-adapter_sd15,
ip-adapter-plus-face_sd15,
ip-adapter-plus_sdxl_vit-h,
ip-adapter-plus-face_sdxl_vit-h
ip_adapter_scale
number

Scale for the IP adapter (0 to 1).

Required range: 0 <= x <= 1
ip_adapter_image
string<uri>

Valid image URL for IP adapter.

scheduler
enum<string>

Available schedulers for image generation.

Available options:
DDPMScheduler,
DDIMScheduler,
PNDMScheduler,
LMSDiscreteScheduler,
EulerDiscreteScheduler,
EulerAncestralDiscreteScheduler,
DPMSolverMultistepScheduler,
HeunDiscreteScheduler,
KDPM2DiscreteScheduler,
DPMSolverSinglestepScheduler,
KDPM2AncestralDiscreteScheduler,
UniPCMultistepScheduler,
DDIMInverseScheduler,
DEISMultistepScheduler,
IPNDMScheduler,
KarrasVeScheduler,
ScoreSdeVeScheduler,
LCMScheduler
strength
number

Prompt strength when using the initial image. Range from 0 to 1.

Required range: 0 <= x <= 1

Response

Inpainting generation response

status
enum<string>

Status of the image generation.

Available options:
success
generationTime
number

Time taken to generate the image in seconds.

id
integer

Unique identifier for the image generation request.

output
string<uri>[]

Array of generated image URLs.

Array of proxy image URLs.

meta
object

Metadata about the image generation including all parameters used.

nsfw_content_detected
boolean

Indicates if NSFW content was detected in the generated image.

webhook_status
string

Status of the webhook notification.

tip
string

Additional information or tips for the user.