# Bria Eraser

> Bria Eraser enables precise removal of unwanted objects from images while maintaining high-quality outputs. Trained exclusively on licensed data for safe and risk-free commercial use. Access the model's source code and weights: https://bria.ai/contact-us


## Overview

- **Endpoint**: `https://fal.run/fal-ai/bria/eraser`
- **Model ID**: `fal-ai/bria/eraser`
- **Category**: image-to-image
- **Kind**: inference
**Tags**: image editing, object removal



## Pricing

- **Price**: $0.04 per generations

For more details, see [fal.ai pricing](https://fal.ai/pricing).

## API Information

This model can be used via our HTTP API or more conveniently via our client libraries.
See the input and output schema below, as well as the usage examples.


### Input Schema

The API accepts the following input parameters:


- **`image_url`** (`string`, _required_):
  Input Image to erase from
  - Examples: "https://storage.googleapis.com/falserverless/bria/bria_eraser_img.png"

- **`mask_url`** (`string`, _required_):
  The URL of the binary mask image that represents the area that will be cleaned.
  - Examples: "https://storage.googleapis.com/falserverless/bria/bria_eraser_mask.png"

- **`mask_type`** (`MaskTypeEnum`, _optional_):
  You can use this parameter to specify the type of the input mask from the list. 'manual' opttion should be used in cases in which the mask had been generated by a user (e.g. with a brush tool), and 'automatic' mask type should be used when mask had been generated by an algorithm like 'SAM'. Default value: `"manual"`
  - Default: `"manual"`
  - Options: `"manual"`, `"automatic"`

- **`sync_mode`** (`boolean`, _optional_):
  If `True`, the media will be returned as a data URI and the output data won't be available in the request history.
  - Default: `false`

- **`preserve_alpha`** (`boolean`, _optional_):
  If set to true, attempts to preserve the alpha channel of the input image.
  - Default: `false`



**Required Parameters Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_img.png",
  "mask_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_mask.png"
}
```

**Full Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_img.png",
  "mask_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_mask.png",
  "mask_type": "manual"
}
```


### Output Schema

The API returns the following output format:

- **`image`** (`Image`, _required_):
  The generated image
  - Examples: {"url":"https://storage.googleapis.com/falserverless/bria/bria_eraser_res.png","content_type":"image/png"}



**Example Response**:

```json
{
  "image": {
    "url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_res.png",
    "content_type": "image/png"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/bria/eraser \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_img.png",
     "mask_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_mask.png"
   }'
```

### Python

Ensure you have the Python client installed:

```bash
pip install fal-client
```

Then use the API client to make requests:

```python
import fal_client

def on_queue_update(update):
    if isinstance(update, fal_client.InProgress):
        for log in update.logs:
           print(log["message"])

result = fal_client.subscribe(
    "fal-ai/bria/eraser",
    arguments={
        "image_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_img.png",
        "mask_url": "https://storage.googleapis.com/falserverless/bria/bria_eraser_mask.png"
    },
    with_logs=True,
    on_queue_update=on_queue_update,
)
print(result)
```

### JavaScript

Ensure you have the JavaScript client installed:

```bash
npm install --save @fal-ai/client
```

Then use the API client to make requests:

```javascript
import { fal } from "@fal-ai/client";

const result = await fal.subscribe("fal-ai/bria/eraser", {
  input: {
    image_url: "https://storage.googleapis.com/falserverless/bria/bria_eraser_img.png",
    mask_url: "https://storage.googleapis.com/falserverless/bria/bria_eraser_mask.png"
  },
  logs: true,
  onQueueUpdate: (update) => {
    if (update.status === "IN_PROGRESS") {
      update.logs.map((log) => log.message).forEach(console.log);
    }
  },
});
console.log(result.data);
console.log(result.requestId);
```


## Additional Resources

### Documentation

- [Model Playground](https://fal.ai/models/fal-ai/bria/eraser)
- [API Documentation](https://fal.ai/models/fal-ai/bria/eraser/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/bria/eraser)

### fal.ai Platform

- [Platform Documentation](https://docs.fal.ai)
- [Python Client](https://docs.fal.ai/clients/python)
- [JavaScript Client](https://docs.fal.ai/clients/javascript)
