> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Edit images with Bria

> Use Bria Image Editing API via CometAPI to erase, gen_fill, expand, enhance, upscale, or replace backgrounds with POST /bria/image/edit/{action}.

## Overview

Bria's Image Editing API provides a comprehensive suite of tools for manipulating and enhancing images.

<Note>
  After a successful API call, use the returned `request_id` to query results via the [Query Status](/api/image/bria/query-status) endpoint.

  The `sync` parameter is fixed on this interface — you do not need to specify it.
</Note>

### Supported operations

| Operation             | Description                      | Documentation                                                                              |
| --------------------- | -------------------------------- | ------------------------------------------------------------------------------------------ |
| `erase`               | Remove objects from images       | [Bria Erase Docs](https://docs.bria.ai/image-editing/v2-endpoints/erase)                   |
| `gen_fill`            | Generative fill for masked areas | [Bria Gen Fill Docs](https://docs.bria.ai/image-editing/v2-endpoints/gen-fill)             |
| `expand`              | Expand image canvas              | [Bria Expand Docs](https://docs.bria.ai/image-editing/v2-endpoints/image-expansion)        |
| `enhance`             | Enhance image quality            | [Bria Enhance Docs](https://docs.bria.ai/image-editing/v2-endpoints/enhance)               |
| `increase_resolution` | Upscale image resolution         | [Bria Upscale Docs](https://docs.bria.ai/image-editing/v2-endpoints/increase-resolution)   |
| `replace_background`  | Replace image background         | [Bria Background Docs](https://docs.bria.ai/image-editing/v2-endpoints/background-replace) |

Please refer to the official documentation for the parameter list specific to each operation.


## OpenAPI

````yaml api/openapi/image/bria/post-image-editing.openapi.json POST /bria/image/edit/{action}
openapi: 3.1.0
info:
  title: Image Editing API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /bria/image/edit/{action}:
    post:
      summary: Image Editing
      operationId: image_editing
      parameters:
        - name: action
          in: path
          required: true
          description: >-
            Editing action to perform. Supported values: `erase`, `gen_fill`,
            `expand`, `enhance`, `increase_resolution`, `replace_background`.
          schema:
            type: string
        - name: Content-Type
          in: header
          required: false
          description: Must be `application/json`.
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                image:
                  type: string
                  description: >-
                    Source image as a public URL or base64-encoded data URI.
                    Accepted formats: JPEG, PNG, WebP. Maximum 12 MB.
                mask:
                  type: string
                  description: >-
                    Mask image as a public URL or base64. White areas mark the
                    region to edit; black areas are preserved. Required for
                    `erase`, `gen_fill`, and `expand` actions.
                prompt:
                  type: string
                  description: >-
                    Text description of the desired edit. Required for
                    `gen_fill` and `replace_background` actions.
                num_results:
                  type: integer
                  description: 'Number of result variants to generate. Default: 1.'
                sync:
                  type: boolean
                  description: >-
                    When `true`, the response blocks until results are ready.
                    When `false` (default), returns immediately with placeholder
                    URLs that can be polled.
            examples:
              eraser:
                summary: eraser
                value:
                  image: >-
                    https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png
                  mask: >-
                    https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png
              gen_fill:
                summary: gen_fill
                value:
                  image: >-
                    https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/original_image.png
                  mask: >-
                    https://raw.githubusercontent.com/cometapi-dev/.github/refs/heads/main/assets/img/mask_image.png
                  prompt: textual description
              increase_resolution:
                summary: increase_resolution
                value:
                  image: https://images.unsplash.com/photo-1506905925346-21bda4d32df4
              replace_background:
                summary: replace_background
                value:
                  image: https://images.unsplash.com/photo-1506905925346-21bda4d32df4
                  prompt: in a living room interior, on a kitchen counter
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties: {}
              example:
                request_id: <request_id>
      x-codeSamples:
        - lang: Shell
          label: Default
          source: >
            # Replace replace_background with the action you need: erase,
            gen_fill,

            # increase_resolution, remove_background, ...

            curl https://api.cometapi.com/bria/image/edit/replace_background \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -H "Content-Type: application/json" \
              -d '{
                "image": "https://your-image-host/source.jpg",
                "prompt": "in a cozy living room"
              }'
        - lang: Python
          label: Default
          source: >
            import os

            import requests


            # Replace replace_background with the action you need: erase,
            gen_fill,

            # increase_resolution, remove_background, ...

            response = requests.post(
                "https://api.cometapi.com/bria/image/edit/replace_background",
                headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
                json={
                    "image": "https://your-image-host/source.jpg",
                    "prompt": "in a cozy living room",
                },
            )


            task = response.json()

            print(task["request_id"])  # poll GET /bria/{request_id} until
            status COMPLETED
        - lang: JavaScript
          label: Default
          source: >
            // Replace replace_background with the action you need: erase,
            gen_fill,

            // increase_resolution, remove_background, ...

            const response = await
            fetch("https://api.cometapi.com/bria/image/edit/replace_background",
            {
                method: "POST",
                headers: {
                    Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
                    "Content-Type": "application/json",
                },
                body: JSON.stringify({
                    image: "https://your-image-host/source.jpg",
                    prompt: "in a cozy living room",
                }),
            });


            const task = await response.json();

            console.log(task.request_id); // poll GET /bria/{request_id} until
            status COMPLETED
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````