# AI Expand

## Overview

<figure><img src="/files/HfcBg0EDk7XkRIyCHQzg" 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`:

| ![](/files/FU5sUQ8Z7Xi8lwaRqpCp) | ![](/files/2mFq8g57TsgZQiVIbapL) |
| :------------------------------: | :------------------------------: |
|        *(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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.photoroom.com/image-editing-api-plus-plan/ai-expand.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
