# Bria Expand Image

> Bria Expand expands images beyond their borders in high quality. 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/expand`
- **Model ID**: `fal-ai/bria/expand`
- **Category**: image-to-image
- **Kind**: inference
**Tags**: outpainting



## 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_):
  The URL of the input image.
  - Examples: "https://storage.googleapis.com/falserverless/model_tests/orange.png"

- **`canvas_size`** (`list<integer>`, _required_):
  The desired size of the final image, after the expansion. should have an area of less than 5000x5000 pixels.
  - Array of integer
  - Examples: [1200,674]

- **`aspect_ratio`** (`Enum`, _optional_):
  The desired aspect ratio of the final image. Will be used over original_image_size and original_image_location if provided.
  - Options: `"1:1"`, `"2:3"`, `"3:2"`, `"3:4"`, `"4:3"`, `"4:5"`, `"5:4"`, `"9:16"`, `"16:9"`

- **`original_image_size`** (`list<integer>`, _optional_):
  The desired size of the original image, inside the full canvas. Ensure that the ratio of input image foreground or main subject to the canvas area is greater than 15% to achieve optimal results. Will be ignored if aspect_ratio is provided.
  - Array of integer
  - Examples: [610,855]

- **`original_image_location`** (`list<integer>`, _optional_):
  The desired location of the original image, inside the full canvas. Provide the location of the upper left corner of the original image. The location can also be outside the canvas (the original image will be cropped). Will be ignored if aspect_ratio is provided.
  - Array of integer
  - Examples: [301,-66]

- **`prompt`** (`string`, _optional_):
  Text on which you wish to base the image expansion. This parameter is optional. Bria currently supports prompts in English only, excluding special characters. Default value: `""`
  - Default: `""`

- **`seed`** (`integer`, _optional_):
  You can choose whether you want your generated expension to be random or predictable. You can recreate the same result in the future by using the seed value of a result from the response. You can exclude this parameter if you are not interested in recreating your results. This parameter is optional.
  - Range: `0` to `2147483647`

- **`negative_prompt`** (`string`, _optional_):
  The negative prompt you would like to use to generate images. Default value: `""`
  - Default: `""`

- **`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`



**Required Parameters Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/model_tests/orange.png",
  "canvas_size": [
    1200,
    674
  ]
}
```

**Full Example**:

```json
{
  "image_url": "https://storage.googleapis.com/falserverless/model_tests/orange.png",
  "canvas_size": [
    1200,
    674
  ],
  "original_image_size": [
    610,
    855
  ],
  "original_image_location": [
    301,
    -66
  ]
}
```


### Output Schema

The API returns the following output format:

- **`image`** (`Image`, _required_):
  The generated image
  - Examples: {"file_size":1471342,"width":1200,"url":"https://v3.fal.media/files/koala/8np-spgxxG-I1r3cjthRV_afa402a35ea742cdb5c3e219b2b19bfb.png","height":674,"content_type":"image/png","file_name":"afa402a35ea742cdb5c3e219b2b19bfb.png"}

- **`seed`** (`integer`, _required_):
  Seed value used for generation.



**Example Response**:

```json
{
  "image": {
    "file_size": 1471342,
    "width": 1200,
    "url": "https://v3.fal.media/files/koala/8np-spgxxG-I1r3cjthRV_afa402a35ea742cdb5c3e219b2b19bfb.png",
    "height": 674,
    "content_type": "image/png",
    "file_name": "afa402a35ea742cdb5c3e219b2b19bfb.png"
  }
}
```


## Usage Examples

### cURL

```bash
curl --request POST \
  --url https://fal.run/fal-ai/bria/expand \
  --header "Authorization: Key $FAL_KEY" \
  --header "Content-Type: application/json" \
  --data '{
     "image_url": "https://storage.googleapis.com/falserverless/model_tests/orange.png",
     "canvas_size": [
       1200,
       674
     ]
   }'
```

### 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/expand",
    arguments={
        "image_url": "https://storage.googleapis.com/falserverless/model_tests/orange.png",
        "canvas_size": [1200, 674]
    },
    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/expand", {
  input: {
    image_url: "https://storage.googleapis.com/falserverless/model_tests/orange.png",
    canvas_size: [1200, 674]
  },
  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/expand)
- [API Documentation](https://fal.ai/models/fal-ai/bria/expand/api)
- [OpenAPI Schema](https://fal.ai/api/openapi/queue/openapi.json?endpoint_id=fal-ai/bria/expand)

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