> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modelslab.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Inpainting

> Generates and returns an image from an image and a mask.

<img src="https://mintcdn.com/mod/i8dYICFkuz1vpdrI/images/image-generation/realtime-stable-diffusion/assets/images/Realtime-inpainting-620336ac69c1ce8e66904c1d1942eebc.jpg?fit=max&auto=format&n=i8dYICFkuz1vpdrI&q=85&s=eb8717c80895dfb3b5108a7fd17ea302" alt="Inpainting endpoint result" width="691" height="518" data-path="images/image-generation/realtime-stable-diffusion/assets/images/Realtime-inpainting-620336ac69c1ce8e66904c1d1942eebc.jpg" />

<Note>
  This API currently supports the following image formats: **`PNG`** and **`JPG`**.
</Note>

## Request

Make a `POST` request to below endpoint and pass the required parameters as a request body.

```curl curl theme={null}
--request POST 'https://modelslab.com/api/v6/realtime/inpaint' \
```

## Body

```json json theme={null}
{  
    "key": "your_api_key",  
    "prompt": "a cat sitting on a bench",  
    "negative_prompt": "bad quality",  
    "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,  
    "safety_checker": false,  
    "strength": 0.7,  
    "base64": false,  
    "seed": null,  
    "webhook": null,  
    "track_id": null
}
```


## OpenAPI

````yaml POST /realtime/inpaint
openapi: 3.1.0
info:
  title: ModelsLab Real-Time Stable Diffusion API
  description: >-
    A comprehensive API for real-time AI-driven image generation, including
    text-to-image, image-to-image, inpainting, and fetching queued results.
  license:
    name: MIT
  version: 6.0.0
servers:
  - url: https://modelslab.com/api/v6
    description: Real-Time Stable Diffusion API v6 server
security: []
paths:
  /realtime/inpaint:
    post:
      summary: Inpaint parts of an image (Real-Time)
      description: >-
        Generates and returns an image from an initial image and a mask, based
        on provided URLs. You can also add a text description (prompt) and
        negative prompt to guide the generation.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RealtimeInpaintRequest'
      responses:
        '200':
          description: Inpainting generation response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: >-
                      #/components/schemas/RealtimeImageGenerationSuccessResponse
                  - $ref: >-
                      #/components/schemas/RealtimeImageGenerationProcessingResponse
                  - $ref: '#/components/schemas/RealtimeImageGenerationErrorResponse'
        '400':
          $ref: '#/components/responses/StandardErrorResponse'
        '401':
          $ref: '#/components/responses/StandardErrorResponse'
        '500':
          $ref: '#/components/responses/StandardErrorResponse'
components:
  schemas:
    RealtimeInpaintRequest:
      type: object
      allOf:
        - $ref: '#/components/schemas/RealtimeCommonImageGenerationParams'
      required:
        - key
        - prompt
        - init_image
        - mask_image
      properties:
        init_image:
          type: string
          format: uri
          description: Link to the initial image.
        mask_image:
          type: string
          format: uri
          description: Link to the mask image for inpainting.
        strength:
          type: number
          minimum: 0
          maximum: 1
          description: >-
            Prompt strength when using the initial image. 1.0 corresponds to
            full destruction of information in the init image.
    RealtimeImageGenerationSuccessResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
          description: Status of the image generation.
        generationTime:
          type: number
          description: Time taken to generate the image in seconds.
        id:
          type: integer
          description: Unique identifier for the image generation request.
        output:
          type: array
          items:
            type: string
            format: uri
          description: Array of generated image URLs.
        proxy_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of proxy image URLs.
        meta:
          type: object
          description: Metadata about the image generation including all parameters used.
          additionalProperties: true
        nsfw_content_detected:
          type: boolean
          description: Indicates if NSFW content was detected in the generated image.
    RealtimeImageGenerationProcessingResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - processing
          description: Status of the image generation.
        tip:
          type: string
          description: Information about faster processing options.
        eta:
          type: number
          description: Estimated time for completion in seconds.
        message:
          type: string
          description: Processing status message.
        fetch_result:
          type: string
          format: uri
          description: URL to fetch the result when processing.
        id:
          type: integer
          description: Unique identifier for the image generation request.
        output:
          type: array
          items:
            type: string
          description: Empty array during processing.
        meta:
          type: object
          description: Metadata about the image generation including all parameters used.
          additionalProperties: true
        future_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of future image URLs for queued requests.
    RealtimeImageGenerationErrorResponse:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: Error message description.
    RealtimeCommonImageGenerationParams:
      type: object
      properties:
        key:
          type: string
          description: Your API Key used for request authorization.
        prompt:
          type: string
          description: >-
            Text prompt with description of the things you want in the image to
            be generated.
        negative_prompt:
          type: string
          description: Items you don't want in the image.
        width:
          type: integer
          default: 512
          maximum: 1024
          description: 'Width of the generated image in pixels. Max: 1024.'
        height:
          type: integer
          default: 512
          maximum: 1024
          description: 'Height of the generated image in pixels. Max: 1024.'
        samples:
          type: integer
          default: 1
          maximum: 4
          description: Number of images to be returned in response. Maximum value is 4.
        safety_checker:
          type: boolean
          default: false
          description: >-
            A checker for NSFW images. If such an image is detected, it will be
            replaced by a blank image.
        seed:
          oneOf:
            - type: integer
            - type: 'null'
          description: >-
            Seed is used to reproduce results; the same seed will give you the
            same image in return. Pass 'null' for a random number.
        instant_response:
          type: boolean
          default: false
          description: >-
            Queue response instantly before processing finishes instead of
            waiting a minimum amount of time.
        base64:
          type: boolean
          default: false
          description: Get response as base64 string.
        webhook:
          type: string
          format: uri
          description: URL to get a POST API call once the image generation is complete.
        track_id:
          type: string
          description: >-
            This ID is returned in the response to the webhook API call and is
            used to identify the webhook request.
  responses:
    StandardErrorResponse:
      description: >-
        Bad request (invalid parameters), unauthorized (invalid API key), or
        internal server error.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RealtimeImageGenerationErrorResponse'

````