{
  "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": "curl https://api.cometapi.com/bria/image/edit/replace_background \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"image\": \"https://your-image-host/source.jpg\",\n    \"prompt\": \"in a cozy living room\"\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\n# Replace replace_background with the action you need: erase, gen_fill,\n# increase_resolution, remove_background, ...\nresponse = requests.post(\n    \"https://api.cometapi.com/bria/image/edit/replace_background\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n        \"image\": \"https://your-image-host/source.jpg\",\n        \"prompt\": \"in a cozy living room\",\n    },\n)\n\ntask = response.json()\nprint(task[\"request_id\"])  # poll GET /bria/{request_id} until status COMPLETED\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "// Replace replace_background with the action you need: erase, gen_fill,\n// increase_resolution, remove_background, ...\nconst response = await fetch(\"https://api.cometapi.com/bria/image/edit/replace_background\", {\n    method: \"POST\",\n    headers: {\n        Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n        \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify({\n        image: \"https://your-image-host/source.jpg\",\n        prompt: \"in a cozy living room\",\n    }),\n});\n\nconst task = await response.json();\nconsole.log(task.request_id); // poll GET /bria/{request_id} until status COMPLETED\n"
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  }
}
