openapi: 3.0.0
info:
  title: Background Remover API
  description: |-
    Complete API collection for background removal from images.

    ## Features
    - Remove background from uploaded image files
    - Remove background from image URLs
    - Support for multiple models (u2net, u2netp, silueta, isnet-general-use)
    - Advanced options (alpha matting, mask processing, background color)
    - High-quality background removal

    ## Authentication
    All requests require an API key in the `x-api-co-id` header.

    ## Base URL
    ```
    https://use.api.co.id/bg-remover
    ```

    ## File Requirements
    - **Supported formats**: JPG, JPEG, PNG, WEBP
    - **Maximum file size**: 10 MB
    - **Output format**: PNG (with transparency)

    ## Rate Limits
    - **Free users**: 20 requests per month
    - **Premium users**: 1000 requests per month

    ## Parameters
    - `model`: Model name (default: u2netp)
    - `a`: Enable Alpha Matting (default: false)
    - `af`: Foreground Threshold (0-255, default: 240)
    - `ab`: Background Threshold (0-255, default: 10)
    - `ae`: Erode Size (default: 10)
    - `om`: Only Mask (default: false)
    - `ppm`: Post Process Mask (default: false)
    - `bgc`: Background Color in format R,G,B,A (e.g., "255,255,255,255")
    - `extras`: Extra JSON parameters
  version: 1.0.0
servers:
  - url: https://use.api.co.id
tags:
  - name: Background Removal
    description: Background removal endpoints for processing images.
paths:
  /bg-remover/remove:
    post:
      tags:
        - Background Removal
      summary: Remove Background from File
      description: 'Remove background from an uploaded image file. Maximum file size: 10 MB. Supported formats: JPG, JPEG, PNG, WEBP.'
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: 'Image file to process. Maximum size: 10 MB. Supported formats: JPG, JPEG, PNG, WEBP'
                model:
                  type: string
                  nullable: true
                  description: Model name (u2net, u2netp, silueta, isnet-general-use)
                a:
                  type: boolean
                  nullable: true
                  description: Enable Alpha Matting
                af:
                  type: integer
                  nullable: true
                  description: 'Foreground Threshold (0-255)'
                  maximum: 255
                ab:
                  type: integer
                  nullable: true
                  description: 'Background Threshold (0-255)'
                  maximum: 255
                ae:
                  type: integer
                  nullable: true
                  description: Erode Size
                om:
                  type: boolean
                  nullable: true
                  description: Only Mask
                ppm:
                  type: boolean
                  nullable: true
                  description: Post Process Mask
                bgc:
                  type: string
                  nullable: true
                  description: 'Background Color in format R,G,B,A (e.g., "255,255,255,255")'
                extras:
                  type: string
                  nullable: true
                  description: Extra JSON parameters
      parameters:
        - name: x-api-co-id
          in: header
          schema:
            type: string
          description: Your API key for authentication
          example: '{{api_key}}'
      responses:
        '200':
          description: Successful response - PNG image with background removed
          content:
            image/png:
              schema:
                type: string
                format: binary
              examples:
                success:
                  summary: Success - Background Removed
                  description: Returns PNG image data with background removed
        '400':
          description: Bad Request - Invalid file or parameters
          content:
            application/json:
              examples:
                missing_file:
                  summary: Error - Missing File
                  value:
                    is_success: false
                    message: 'File is required. Please upload an image file using ''file'' field in multipart/form-data'
                    data: null
                invalid_file_type:
                  summary: Error - Invalid File Type
                  value:
                    is_success: false
                    message: 'Invalid file type. Only JPG, JPEG, PNG, and WEBP image files are allowed'
                    data: null
                file_too_large:
                  summary: Error - File Too Large
                  value:
                    is_success: false
                    message: 'File size exceeds maximum limit of 10 MB'
                    data: null
        '401':
          description: Unauthorized - Missing or invalid API key
          content:
            application/json:
              examples:
                missing_api_key:
                  summary: Error - Missing API Key
                  value:
                    is_success: false
                    message: User not authenticated
                    data: null
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              examples:
                rate_limit_exceeded:
                  summary: Error - Rate Limit Exceeded
                  value:
                    is_success: false
                    message: 'Monthly Background Remover limit exceeded. Please upgrade to premium for more requests.'
                    data: null
    get:
      tags:
        - Background Removal
      summary: Remove Background from URL
      description: Remove background from an image by providing its URL. Returns processed image with background removed as PNG (with transparency).
      parameters:
        - name: x-api-co-id
          in: header
          schema:
            type: string
          description: Your API key for authentication
          example: '{{api_key}}'
        - name: url
          in: query
          required: true
          schema:
            type: string
            format: uri
          description: URL of the image to process
          example: https://example.com/image.jpg
        - name: model
          in: query
          schema:
            type: string
            nullable: true
          description: Model name (u2net, u2netp, silueta, isnet-general-use)
        - name: a
          in: query
          schema:
            type: boolean
            nullable: true
          description: Enable Alpha Matting (true/false)
        - name: af
          in: query
          schema:
            type: integer
            nullable: true
          description: 'Foreground Threshold (0-255)'
          maximum: 255
        - name: ab
          in: query
          schema:
            type: integer
            nullable: true
          description: 'Background Threshold (0-255)'
          maximum: 255
        - name: ae
          in: query
          schema:
            type: integer
            nullable: true
          description: Erode Size
        - name: om
          in: query
          schema:
            type: boolean
            nullable: true
          description: Only Mask (true/false)
        - name: ppm
          in: query
          schema:
            type: boolean
            nullable: true
          description: Post Process Mask (true/false)
        - name: bgc
          in: query
          schema:
            type: string
            nullable: true
          description: Background Color in format R,G,B,A (e.g., "255,255,255,255")
        - name: extras
          in: query
          schema:
            type: string
            nullable: true
          description: Extra JSON parameters
      responses:
        '200':
          description: Successful response - PNG image with background removed
          content:
            image/png:
              schema:
                type: string
                format: binary
              examples:
                success:
                  summary: Success - Background Removed from URL
                  description: Returns PNG image data with background removed
        '400':
          description: Bad Request - Missing or invalid URL
          content:
            application/json:
              examples:
                missing_url:
                  summary: Error - Missing URL Parameter
                  value:
                    is_success: false
                    message: url parameter is required
                    data: null
                invalid_url:
                  summary: Error - Invalid URL
                  value:
                    is_success: false
                    message: Invalid URL format
                    data: null
        '401':
          description: Unauthorized - Missing or invalid API key
          content:
            application/json:
              examples:
                missing_api_key:
                  summary: Error - Missing API Key
                  value:
                    is_success: false
                    message: User not authenticated
                    data: null
        '429':
          description: Too Many Requests - Rate limit exceeded
          content:
            application/json:
              examples:
                rate_limit_exceeded:
                  summary: Error - Rate Limit Exceeded
                  value:
                    is_success: false
                    message: 'Monthly Background Remover limit exceeded. Please upgrade to premium for more requests.'
                    data: null
  /bg-remover/models:
    get:
      tags:
        - Background Removal
      summary: List Available Models
      description: Get list of available background removal models.
      parameters:
        - name: x-api-co-id
          in: header
          schema:
            type: string
          description: Your API key for authentication
          example: '{{api_key}}'
      responses:
        '200':
          description: Successful response - List of available models
          content:
            application/json:
              examples:
                success:
                  summary: Success - Models Listed
                  value:
                    is_success: true
                    message: Success
                    data:
                      models:
                        - u2net
                        - u2netp
                        - silueta
                        - isnet-general-use
                      default: u2netp
        '401':
          description: Unauthorized - Missing or invalid API key
          content:
            application/json:
              examples:
                missing_api_key:
                  summary: Error - Missing API Key
                  value:
                    is_success: false
                    message: User not authenticated
                    data: null
