> ## 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.

# Background Removal & Create mask

> This endpoint removes background from image and create mask.

### Remove Background Mask

<img src="https://mintcdn.com/mod/i8dYICFkuz1vpdrI/images/image-editing/assets/images/Background-Removal-b950c09956614c3e222247b679b7b1c0.jpg?fit=max&auto=format&n=i8dYICFkuz1vpdrI&q=85&s=206816cbb7df455a939a94cb8ce19971" alt="removebg-createmask endpoint result" width="691" height="518" data-path="images/image-editing/assets/images/Background-Removal-b950c09956614c3e222247b679b7b1c0.jpg" />

## Request

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

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

<Note>
  If you want only mask as a output then set the parameter `only_mask`:`true`
</Note>

## Body

```json json theme={null}
{    
    "key":"",    
    "seed":12345,    
    "image":"https://assets.modelslab.ai/generations/31d4567d-b60a-4d09-9650-987fc0aae2cf",    
    "post_process_mask": false,    
    "only_mask": false,    
    "alpha_matting":false,    
    "webhook": null,    
    "track_id": null  
}
```


## OpenAPI

````yaml POST /image_editing/removebg_mask
openapi: 3.1.0
info:
  title: ModelsLab Image Editing API
  description: >-
    Image editing endpoints for ModelsLab API including background removal,
    super resolution, face generation, fashion try-on, and various image
    manipulation tools
  license:
    name: MIT
  version: 6.0.0
servers:
  - url: https://modelslab.com/api/v6
    description: Image Editing API v6 server
security: []
paths:
  /image_editing/removebg_mask:
    post:
      summary: Background removal and create mask
      description: This endpoint removes background from image and create mask
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RemoveBgMaskRequest'
      responses:
        '200':
          description: Background removal response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ImageEditingSuccessResponse'
                  - $ref: '#/components/schemas/ImageEditingProcessingResponse'
                  - $ref: '#/components/schemas/ImageEditingErrorResponse'
components:
  schemas:
    RemoveBgMaskRequest:
      type: object
      required:
        - key
        - image
      properties:
        key:
          type: string
          description: Your API Key used for request authorization
        image:
          type: string
          description: Link or valid base64 data for the image
        alpha_matting:
          type: boolean
          default: false
          description: Whether to perform alpha matting
        post_process_mask:
          type: boolean
          default: false
          description: Whether to post-process the mask image
        only_mask:
          type: boolean
          default: false
          description: Whether to return only the mask image
        inverse_mask:
          type: boolean
          default: false
          description: This will inverse the generated mask
        seed:
          type: integer
          description: Seed for reproducible results
        base64:
          type: boolean
          default: false
          description: Get response as base64 string
        alpha_matting_foreground_threshold:
          type: integer
          minimum: 0
          maximum: 240
          default: 240
        alpha_matting_background_threshold:
          type: integer
          minimum: 0
          maximum: 20
          default: 20
        alpha_matting_erode_size:
          type: integer
          minimum: 0
          maximum: 5
          default: 5
        webhook:
          type: string
          format: uri
          description: URL to receive POST API call when complete
        track_id:
          type: integer
          description: ID for webhook identification
    ImageEditingSuccessResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
        generationTime:
          type: number
          description: Time taken to generate the image in seconds
        id:
          type: integer
          description: Unique identifier for the 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 generation process
          additionalProperties: true
    ImageEditingProcessingResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - processing
        tip:
          type: string
          description: Information about the processing status
        eta:
          type: integer
          description: Estimated time remaining in seconds
        message:
          type: string
          description: Processing status message
        fetch_result:
          type: string
          format: uri
          description: URL to fetch the result when ready
        id:
          type: integer
          description: Unique identifier for the generation request
        output:
          type: array
          items:
            type: string
          description: Empty array during processing
        future_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of future image URLs
        proxy_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of proxy image URLs
        meta:
          type: object
          description: Metadata about the generation process
          additionalProperties: true
    ImageEditingErrorResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: Error message describing what went wrong

````