---
title: "Generative Fill"
method: POST
path: "/gen_fill"
tags: ["Image Editing"]
---

# Generative Fill

`POST /gen_fill`

**Description**

The *GenFill Route* enables the generation of objects by prompt in a specific region of an image.

You can define the area for object generation by using a mask that outlines the region where the object will be created. Our model is optimized to work seamlessly with blob-shaped masks.

Masks can be created by allowing users to draw directly on the image with a brush, for example. To access the SDK that demonstrates how to implement a brush feature in your interface, please refer to the following <a href="https://github.com/Bria-AI/js-api-sdk/blob/main/manual_brush_ui" target="_blank">link</a>.

This capability is powered by our fast ControlNet inpainting model. HF model card is available <a href="https://huggingface.co/briaai/BRIA-2.3-ControlNet-Inpainting" target="_blank">here</a>. And the HF demo space can be found <a href="https://huggingface.co/spaces/briaai/BRIA-Generative-Fill-API" target="_blank">here</a>.

## Headers

- `api_token` string, required

## Request body

- object
  - `image_url` string — The URL of the input image. If both image_url and image_file are provided, image_url will be used. Accepted formats are jpeg, jpg, png, webp.
  - `file` string — The file of the input image, in base64 format. Used if image_url is not provided. Accepted formats are jpeg, jpg, png, webp.
  - `mask_url` string — The URL of the binary mask image that represents the area in which the object will be generated. If both mask_url and mask_file are provided, mask_url will be used. Accepted formats are jpeg, jpg, png, webp. The area in which the object will be generated should have the value 255 (white), while the rest of the image should have the value 0 (black). **Note:** The input image and mask must have the same aspect ratio.
  - `mask_file` string — The file of the binary mask image that represents the area in which the object will be generated, in base64 format. This parameter is used if mask_url is not provided. Accepted formats are jpeg, jpg, png, webp. The area in which the object will be generated should have the value 255 (white), while the rest of the image should have the value 0 (black). **Note:** The input image and mask must have the same aspect ratio.
  - `mask_type` 'manual' | 'automatic' — 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'.
  - `prompt` string — The prompt you would like to use to generate the object within the masked region.
  - `negative_prompt` string — The prompt you would like to use to specify details or attributes to avoid in the object generated within the masked region.
  - `num_results` integer — The number of images you would like to generate.
  - `sync` boolean — Determines the response mode. When true, responses are synchronous. With false, responses are asynchronous, immediately providing URLs for images that are generated in the background. It is recommended to use sync=false for optimal performance. When generating more than 1 result, you should use the value false.
  - `seed` integer — You can choose whether you want your generated results 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.

## Response `200`

Successful operation.

- object
  - `urls` string[] — An array of URLs representing the updated visuals generated by the request. These URLs are temporary and will eventually expire.
  - `seed` integer[] — An array of integers representing the seeds used to generate each result. These seeds ensure reproducibility and are compatible with the results URL structure.

## Other responses

- `400` — Bad request. Missing or invalid parameters.
- `401` — Unauthorized. Invalid API key or authentication token.
- `404` — Not found. Image could not be found at the provided URL.
- `415` — Unsupported media type. Invalid file type. Supported file types are jpeg, jpg, png, webp.
- `429` — Request limit exceeded. Your account has reached its maximum allowed requests. Please upgrade your plan or try again later.
- `460` — Failed to download image.
- `500` — Internal server error. An error occurred on the server.

---

[API](https://skmtc.net/bria-ai/apis/the-bria-api.md) · [All operations](https://skmtc.net/bria-ai/apis/the-bria-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/bria-ai/the-bria-api/versions/2768230345a5/schema)
