Skip to main content
POST
/
inpaint
Inpainting
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>",
  "width": 512,
  "height": 512,
  "samples": 1,
  "steps": 21,
  "guidance_scale": 7.5,
  "strength": 0.7,
  "scheduler": "DPMSolverMultistepScheduler",
  "use_karras_sigmas": "yes",
  "algorithm_type": "sde-dpmsolver++",
  "clip_skip": 2,
  "safety_checker": "yes",
  "seed": 123,
  "webhook": "<string>",
  "track_id": "<string>"
}
'
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>",
    "width": 512,
    "height": 512,
    "samples": 1,
    "steps": 21,
    "guidance_scale": 7.5,
    "strength": 0.7,
    "scheduler": "DPMSolverMultistepScheduler",
    "use_karras_sigmas": "yes",
    "algorithm_type": "sde-dpmsolver++",
    "clip_skip": 2,
    "safety_checker": "yes",
    "seed": 123,
    "webhook": "<string>",
    "track_id": "<string>"
}
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>',
    width: 512,
    height: 512,
    samples: 1,
    steps: 21,
    guidance_scale: 7.5,
    strength: 0.7,
    scheduler: 'DPMSolverMultistepScheduler',
    use_karras_sigmas: 'yes',
    algorithm_type: 'sde-dpmsolver++',
    clip_skip: 2,
    safety_checker: 'yes',
    seed: 123,
    webhook: '<string>',
    track_id: '<string>'
  })
};

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>',
    'width' => 512,
    'height' => 512,
    'samples' => 1,
    'steps' => 21,
    'guidance_scale' => 7.5,
    'strength' => 0.7,
    'scheduler' => 'DPMSolverMultistepScheduler',
    'use_karras_sigmas' => 'yes',
    'algorithm_type' => 'sde-dpmsolver++',
    'clip_skip' => 2,
    'safety_checker' => 'yes',
    'seed' => 123,
    'webhook' => '<string>',
    'track_id' => '<string>'
  ]),
  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  \"width\": 512,\n  \"height\": 512,\n  \"samples\": 1,\n  \"steps\": 21,\n  \"guidance_scale\": 7.5,\n  \"strength\": 0.7,\n  \"scheduler\": \"DPMSolverMultistepScheduler\",\n  \"use_karras_sigmas\": \"yes\",\n  \"algorithm_type\": \"sde-dpmsolver++\",\n  \"clip_skip\": 2,\n  \"safety_checker\": \"yes\",\n  \"seed\": 123,\n  \"webhook\": \"<string>\",\n  \"track_id\": \"<string>\"\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  \"width\": 512,\n  \"height\": 512,\n  \"samples\": 1,\n  \"steps\": 21,\n  \"guidance_scale\": 7.5,\n  \"strength\": 0.7,\n  \"scheduler\": \"DPMSolverMultistepScheduler\",\n  \"use_karras_sigmas\": \"yes\",\n  \"algorithm_type\": \"sde-dpmsolver++\",\n  \"clip_skip\": 2,\n  \"safety_checker\": \"yes\",\n  \"seed\": 123,\n  \"webhook\": \"<string>\",\n  \"track_id\": \"<string>\"\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  \"width\": 512,\n  \"height\": 512,\n  \"samples\": 1,\n  \"steps\": 21,\n  \"guidance_scale\": 7.5,\n  \"strength\": 0.7,\n  \"scheduler\": \"DPMSolverMultistepScheduler\",\n  \"use_karras_sigmas\": \"yes\",\n  \"algorithm_type\": \"sde-dpmsolver++\",\n  \"clip_skip\": 2,\n  \"safety_checker\": \"yes\",\n  \"seed\": 123,\n  \"webhook\": \"<string>\",\n  \"track_id\": \"<string>\"\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
See available schedulers for Pony models.

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": "pony-realism",
    "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": "DPMSolverMultistepScheduler",
    "use_karras_sigmas": "yes",
    "algorithm_type": "sde-dpmsolver++",
    "clip_skip": "2",
    "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 Pony model to be used. Use pony_realism for the Pony Realism model.

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.

width
integer
default:512

The width of the image in pixels. Must be between 512-1024 and divisible by 8.

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

The height of the image in pixels. Must be between 512-1024 and divisible by 8.

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

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

Required range: x <= 4
steps
integer
default:21

Number of inference steps for inpainting.

guidance_scale
number
default:7.5

How closely to follow the prompt. Higher values = more literal interpretation.

Required range: 1 <= x <= 20
strength
number
default:0.7

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

Required range: 0 <= x <= 1
scheduler
string
default:DPMSolverMultistepScheduler

Scheduler to use for denoising.

use_karras_sigmas
enum<string>
default:yes

Apply Karras sigmas to the scheduler.

Available options:
yes,
no
algorithm_type
string
default:sde-dpmsolver++

Algorithm type for the scheduler.

clip_skip
integer
default:2

Number of CLIP layers to skip. Affects style interpretation.

Required range: 1 <= x <= 4
safety_checker
enum<string>
default:yes

Enable NSFW content filter.

Available options:
yes,
no
seed
integer | null

Random seed for reproducible results. Pass null for a random number.

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.

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.