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

# GPT Image 2 Image Edit

> Edit images using a text prompt and optional mask with GPT Image 2.

## Overview

Edit existing images using a text prompt with GPT Image 2. Pass one or more input images (URL or Base64) and an optional mask to constrain the edit region. Supports up to 4K output and batch generation of 1–4 edited images per request.


## OpenAPI

````yaml api-reference/endpoint/openai/gpt-image-2/openapi.yaml POST /vendors/openai/v1/gpt-image-2/edit
openapi: 3.1.0
info:
  title: GPT Image 2 Generation & Edit API
  description: Generate and edit images using the GPT Image 2 model via MuleRouter.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.mulerouter.ai/
security:
  - bearerAuth: []
paths:
  /vendors/openai/v1/gpt-image-2/edit:
    post:
      summary: Image Edit
      description: Edit images using a text prompt and optional mask with GPT Image 2.
      operationId: gpt_image_2_edit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/EditRequest'
      responses:
        '202':
          description: Accepted - Task created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskCreatedResponse'
components:
  schemas:
    EditRequest:
      type: object
      additionalProperties: false
      properties:
        prompt:
          type: string
          minLength: 1
          description: Text prompt describing the desired edit.
        images:
          type: array
          description: Input images to edit. Each item is a URL or Base64-encoded string.
          items:
            type: string
          minItems: 1
        size:
          $ref: '#/components/schemas/SizeEnum'
        'n':
          type: integer
          description: Number of edited images to generate.
          minimum: 1
          maximum: 4
          default: 1
        mask:
          type: string
          description: >-
            Optional mask image (URL or Base64-encoded) to specify the edit
            region.
        format:
          $ref: '#/components/schemas/FormatEnum'
      required:
        - prompt
        - images
    TaskCreatedResponse:
      type: object
      additionalProperties: true
      properties:
        task_info:
          $ref: '#/components/schemas/TaskInfoCreated'
    SizeEnum:
      type: string
      description: Output image resolution.
      enum:
        - 1024x1024
        - 1536x1024
        - 1024x1536
        - 2048x2048
        - 2048x1152
        - 3840x2160
        - 2160x3840
        - auto
      default: auto
    FormatEnum:
      type: string
      description: Output image format.
      enum:
        - png
        - jpeg
        - webp
      default: png
    TaskInfoCreated:
      type: object
      additionalProperties: true
      properties:
        id:
          type: string
          format: uuid
          description: UUID of the task
        status:
          type: string
          enum:
            - pending
          description: Task status (pending when created)
        created_at:
          type: string
          format: date-time
          description: Task creation timestamp (ISO 8601)
        updated_at:
          type: string
          format: date-time
          description: Task last update timestamp (ISO 8601)
      required:
        - id
        - status
        - created_at
        - updated_at
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````