> For the complete documentation index, see [llms.txt](https://incubiq.gitbook.io/opensourceais/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://incubiq.gitbook.io/opensourceais/apis/ais/image-utilities/ai_rembg.md).

# ai\_rembg

{% embed url="<https://github.com/danielgatis/rembg>" %}
Official GitHub repo where this AI was taken from
{% endembed %}

{% hint style="success" %}
This AI can run AI alongside a Daemon on CPU only
{% endhint %}

## Get the JSON config file for this AI

<mark style="color:blue;">`GET`</mark> `https://opensourceais.com/api/v1/public/config/rembg`

You should not need to call this endpoint. This is just a FYI to understand all input parameters sent to the AI.

{% tabs %}
{% tab title="200: OK The full JSON config file" %}

```json
{
    "data": {
        "engine": "rembg",
        "version": "1.0.4",
        "name": "Remove Background",
        "description": "Image Utility",
        "isFree": false,
        "requiresGPU": false,
        "aParam": [
            {
                "in": "url_upload",
                "out": "-filename",
                "isMandatory": true,
                "type": "string",
                "default": null,
                "accept": {
                    "$max": 2048
                },
                "ui": {
                    "title": "Image input",
                    "widget": "uiSelectPicture",
                    "column": 1
                }
            },
            {
                "in": "output",
                "out": "-o",
                "isMandatory": true,
                "type": "function",
                "default": "$output_uid.ext"
            },
            {
                "in": "idir",
                "out": "-idir",
                "isMandatory": false,
                "type": "string",
                "default": "./_input/"
            },
            {
                "in": "odir",
                "out": "-odir",
                "isMandatory": false,
                "type": "string",
                "default": "./_output/"
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

## Post a request to Remove Background via OpenSourceAIs

<mark style="color:green;">`POST`</mark> `https://opensourceais.com/api/v1/private/client/ai/rembg`

#### Request Body

| Name        | Type   | Description                                                                    |
| ----------- | ------ | ------------------------------------------------------------------------------ |
| url\_upload | String | A well formed URI starting with https\://... and accessing a PNG or JPG image. |

{% tabs %}
{% tab title="201: Created Confirmation that the request was processed" %}

```json
{
    "data": {
        "uid": 1678361974000,
        "created_at": "2023-03-09T11:39:44.000Z"
    }
}
```

{% endtab %}

{% tab title="400: Bad Request  This error should not happen unless authentication is tampered with" %}

```json
{
     data: null,
     status: 400,
     statusText: "A client token is required"
}
```

{% endtab %}

{% tab title="409: Conflict Could not add request to backlog" %}

```json
{
     data: null,
     status: 409,
     statusText: "Could not add to backlog"
}

```

{% endtab %}
{% endtabs %}
