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

# gpt-image-2-edit

> Edit an existing image with GPT Image 2 using a text prompt. Accepts a multipart/form-data body.

Supports up to 16 input images per request (`image[]`). Input formats: PNG, JPEG. Images must be provided as multipart/form-data file uploads.



## OpenAPI

````yaml api-reference/model-api/openai/openapi/gpt-image-2-edit/openapi.yaml POST /v1/images/edits
openapi: 3.1.0
info:
  title: GPT Image 2 — Edit
  description: Edit an existing image using GPT Image 2 via Anyfast API
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security:
  - bearerAuth: []
paths:
  /v1/images/edits:
    post:
      summary: Edit Image
      description: >-
        Edit an existing image with GPT Image 2 using a text prompt. Accepts a
        multipart/form-data body.


        Supports up to 16 input images per request (`image[]`). Input formats:
        PNG, JPEG. Images must be provided as multipart/form-data file uploads.
      operationId: editGptImage2
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                image:
                  type: string
                  format: binary
                  description: >-
                    Single source image file to edit (PNG or JPEG). Use
                    `image[]` instead when providing multiple images.
                image[]:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: >-
                    Multiple source image files (PNG or JPEG). Up to 16 images
                    per request. Use instead of `image` for multi-image input.
                mask:
                  type: string
                  format: binary
                  description: >-
                    Mask image file with an alpha channel. Indicates which areas
                    of the source image to edit. Must be the same format and
                    same size as the source image (< 50MB). **Requires selecting
                    the Direct group.**
                model:
                  type: string
                  enum:
                    - gpt-image-2
                  description: Model ID.
                  example: gpt-image-2
                prompt:
                  type: string
                  description: Text description of the edit you want to apply.
                  example: Change the background to a sunset over the ocean
                output_format:
                  type: string
                  enum:
                    - png
                    - jpeg
                  default: png
                  description: 'Output image format. Default: `png`.'
                output_compression:
                  type: integer
                  minimum: 0
                  maximum: 100
                  description: Compression level for jpeg output (0–100).
                'n':
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
                  description: >-
                    Number of images to return. Supports `1–10`. Default: `1`.
                    **Requires selecting the Direct group** in the console.
                  example: 1
                size:
                  type: string
                  default: 1024x1024
                  description: >-
                    Output image size in `{width}x{height}` format. Same
                    flexible-resolution constraints as image generation.
                  example: 1024x1024
      responses:
        '200':
          description: Image edited successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: Array of edited images.
                    items:
                      type: object
                      properties:
                        b64_json:
                          type: string
                          description: Base64-encoded image data.
                        revised_prompt:
                          type: string
                          description: The revised prompt actually used by the model.
        '400':
          description: Bad request. Invalid parameters.
        '401':
          description: Unauthorized. Invalid or missing API key.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````