# AI Expand

## Overview

<figure><img src="https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FOWCZ427MIWzdeSTL14CO%2FSplit-%20AI%20Expand.gif?alt=media&#x26;token=dcfc0dc7-6075-4305-bb29-9273a1d39a52" alt=""><figcaption></figcaption></figure>

The Image Editing API allows you to expand an input image.

AI Expand works by seamlessly expanding the background to fill every empty pixel of the result image.

To expand an image, set the argument `expand.mode` to the value `ai.auto`:

| ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2Fspe7s1H6t3zi9YYktv7o%2Finput.png?alt=media\&token=da2cf808-1949-4874-9ea2-49e625cd76a9) | ![](https://2855892273-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1SYxn7dWbQYsNtUdJE3f%2Fuploads%2FNk3rLrl1InSZ69BTS5bI%2Fai-expand.png?alt=media\&token=a9733a75-4ef3-4b08-a165-e9e834463247) |
| :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|                                                                                                  *(original image)*                                                                                                 |                                                                                                    *(expanded image)*                                                                                                   |

If you want to give it a try, here's the code to reproduce the example above:

```bash
curl --request POST \
  --url https://image-api.photoroom.com/v2/edit \
  --header 'x-api-key: YOUR_API_KEY' \
  --form 'imageFile=@"/path/to/image.jpeg"' \
  --form 'outputSize="1920x1080"' \
  --form 'referenceBox="originalImage"' \
  --form 'removeBackground="false"' \
  --form 'expand.mode="ai.auto"' \
  --output result-ai-expand.png
```

<a href="https://try-api.photoroom.com/?outputSize=1920x1080&#x26;referenceBox=originalImage&#x26;removeBackground=false&#x26;expand.mode=ai.auto" class="button primary">Try it now!</a>

{% hint style="warning" %}
In order to expand an image, you need to either:

* set `removeBackground` to `false`
* provide a `background.imageUrl`
  {% endhint %}

## Additional Parameters

### **`expand.seed`**

If you make several calls to the Image Editing API with the same image, you will notice that it will generate a different expanded background each time.

This is great when you're looking for inspiration, but it might become an issue when you need consistency.

In order to reduce the randomness, you can set a fixed value for the seed that the API's random generator will use. The value of the argument `expand.seed` can be any positive integer.

If you provide a value for `expand.seed`, then the API should produce similar-looking backgrounds for the same image.
