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

# GPT Image 2 — Image edit

> Edit an existing image with a text prompt using the GPT Image 2 model. The request body is multipart/form-data.



## OpenAPI

````yaml en/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 — Image edit
  description: Edit an existing image with GPT Image 2
  version: 1.0.0
servers:
  - url: https://ai.cubeuaeai.com
security:
  - bearerAuth: []
paths:
  /v1/images/edits:
    post:
      summary: Edit an image
      description: >-
        Edit an existing image with a text prompt using the GPT Image 2 model.
        The request body is multipart/form-data.


        Each request supports up to 16 input images (`image[]`). Formats: PNG,
        JPEG. Images must be uploaded as multipart/form-data file uploads.


        **Note:** With `gpt-image-2-c`, a higher quality setting can make
        multi-image (`n`) output less stable. Use a lower quality setting if you
        need consistent multi-image generation.
      operationId: editGptImage2
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                image:
                  type: string
                  format: binary
                  description: >-
                    A single source image file (PNG or JPEG). Use `image[]` for
                    multiple images.
                image[]:
                  type: array
                  items:
                    type: string
                    format: binary
                  description: >-
                    Multiple source image files (PNG or JPEG), up to 16 per
                    request. Use this instead of `image` for multiple images.
                mask:
                  type: string
                  format: binary
                  description: >-
                    Mask image file (with an alpha channel) that marks the
                    region to edit. Must match the source image format and size
                    (< 50MB). **Select the Direct group in the console.**
                model:
                  type: string
                  enum:
                    - gpt-image-2
                    - gpt-image-2-c
                  description: >-
                    Model ID. `gpt-image-2` is the official model;
                    `gpt-image-2-c` is the cost-efficient variant (supports
                    `response_format`）。
                  example: gpt-image-2
                prompt:
                  type: string
                  description: Edit instruction text.
                  example: Replace the image background with a sunset over the sea
                output_format:
                  type: string
                  enum:
                    - png
                    - jpeg
                  default: png
                  description: Output image format. Defaults to `png`.
                output_compression:
                  type: integer
                  minimum: 0
                  maximum: 100
                  description: Compression level for jpeg (0–100).
                'n':
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
                  description: >-
                    Number of images to return, `1–10`, default `1`. **Select
                    the Direct group in the console.**
                  example: 1
                size:
                  type: string
                  default: 1024x1024
                  description: >-
                    Output image size in `{width}x{height}` format, with the
                    same constraints as the image generation API (flexible
                    resolution).
                  example: 1024x1024
                response_format:
                  type: string
                  enum:
                    - url
                  default: url
                  description: >-
                    Response format. **Supported only by `gpt-image-2-c`
                    (cost-efficient variant)**. Currently only `url`.
                  example: url
      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:
                        url:
                          type: string
                          description: >-
                            Presigned URL of the edited image (returned when
                            `response_format=url`).
                        b64_json:
                          type: string
                          description: >-
                            Base64-encoded image data
                            (`response_format=b64_json` returns this; official
                            model only).
                        revised_prompt:
                          type: string
                          description: The rewritten prompt actually used by the model.
        '400':
          description: Request error. Invalid parameters.
        '401':
          description: Unauthorized. The API key is invalid or missing.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````