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

# GPT Image 2 - Edit



## OpenAPI

````yaml mountsea-api.mint.json POST /ms/v1/run/openai/gpt-image-2/edit
openapi: 3.0.0
info:
  title: mountsea-api
  description: >-
    mountsea unified AI API — video, image, and audio generation.


    ### Async task flow

    1. `POST /ms/v1/run/{endpoint_slug}` — submit a job (returns Task with
    `status: queued`).

    2. `GET /ms/v1/tasks/{task_id}` — poll until `succeeded` (`output.images` /
    `output.videos` / `output.audio`) or `failed`/`timeout` (`error`).
       Or pass `webhook_url` in the submit body for a signed terminal callback (`x-ms-signature`).
    3. `GET /ms/v1/endpoints[/{slug}]` — marketplace listing with
    `input_schema`, `output_schema`, and `examples`.


    ### Request body

    - `{ "input": { ... } }` — all parameters and media URLs per endpoint
    `input_schema`.

    - Optional `webhook_url` for callbacks.


    ### SDK compatibility (optional)

    Prefer the native async API above? Skip this section.


    - **OpenAI SDK** — `baseURL = https://{gateway}/ms/v1`
      - Image (sync): `POST /ms/v1/images/generations|edits` — gpt-image-2 family
      - Video (async): `POST /ms/v1/videos` + `GET /ms/v1/videos/{id}` — sora-2 → Veo lite/pro slugs
    - **Gemini SDK** — `httpOptions.baseUrl = https://{gateway}/ms`
      - Image (sync): `POST /ms/v1beta/models/{model}:generateContent` — nano-banana family
      - Video (async): `POST /ms/v1beta/models/{model}:predictLongRunning` + poll `GET /ms/v1beta/operations/{task_id}`

    Unsupported `model` → **HTTP 400** before any task is created (no charge).

    Successful calls bill the **same endpoint slug** as the equivalent
    `/ms/v1/run/...` API.
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.mountsea.ai
    description: API Gateway
security: []
tags:
  - name: Run
    description: Submit async tasks by endpoint slug
  - name: Tasks
    description: Poll or cancel tasks
  - name: Endpoints (marketplace)
    description: Endpoint catalog and schemas
  - name: SDK Compatibility
    description: >-
      OpenAI / Gemini official SDK — sync image APIs (same billing as native
      run)
  - name: Admin - Catalog (internal)
    description: Internal admin (swagger only, not public gateway)
paths:
  /ms/v1/run/openai/gpt-image-2/edit:
    post:
      tags:
        - Models / image
      summary: GPT Image 2 - Edit
      description: >-
        OpenAI GPT Image 2 instruction editing.


        **Endpoint**: `openai/gpt-image-2/edit` · **mode**: `image-to-image`


        Returns a Task with `status: queued` and `output: null`. Poll `GET
        /ms/v1/tasks/{task_id}` until `succeeded`, then read `output` (see
        response schema).


        Request examples are taken from the endpoint `examples` field.
      operationId: run_openai_gpt_image_2_edit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RunEndpointInput_openai_gpt_image_2_edit'
            example:
              input:
                prompt: Add a rainbow.
                image_size: auto
                image_urls:
                  - https://example.com/a.jpg
      responses:
        '200':
          $ref: '#/components/responses/MsTaskImageResponse'
        '201':
          $ref: '#/components/responses/MsTaskImageResponse'
        '400':
          $ref: '#/components/responses/BadRequestResponse'
        '404':
          $ref: '#/components/responses/NotFoundResponse'
      security:
        - bearerAuth: []
components:
  schemas:
    RunEndpointInput_openai_gpt_image_2_edit:
      type: object
      properties:
        input:
          type: object
          description: >-
            Parameters for this endpoint (input_schema.params). Input media URLs
            use schema field names, e.g. image_url, image_urls, mask_url.
          properties:
            prompt:
              description: Text prompt describing the image. Maximum 32000 characters.
              type: string
              maxLength: 32000
            quality:
              type: string
              enum:
                - auto
                - low
                - medium
                - high
              default: high
            mask_url:
              description: >-
                Optional mask image URL (PNG with transparency). Edited region
                is transparent or white.
              type: string
              format: uri
            sync_mode:
              type: boolean
            image_size:
              description: >-
                Preset name or custom {width,height}. Custom: both dims multiple
                of 16, max edge 3840px, aspect ratio 1:3 to 3:1, total pixels
                655360-8294400.
              type: string
              default: auto
            image_urls:
              description: Input image URLs for editing (1-16 images).
              type: array
              items:
                type: string
                format: uri
              minItems: 1
              maxItems: 16
            num_images:
              description: Number of images to generate (1-4).
              type: integer
              minimum: 1
              maximum: 4
              default: 1
            output_format:
              type: string
              enum:
                - jpeg
                - png
                - webp
              default: png
          required:
            - prompt
            - image_urls
        webhook_url:
          type: string
          format: uri
          description: >-
            Optional webhook URL for terminal status (HMAC header
            x-ms-signature)
    MsTaskImage:
      type: object
      description: Async image task
      properties:
        task_id:
          type: string
          example: ms-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
        endpoint:
          type: string
          example: google/veo-3.1/text-to-video
        model:
          type: string
          example: veo-3.1
        capability:
          type: string
          enum:
            - image
            - video
            - audio
        mode:
          type: string
          example: text-to-video
        status:
          type: string
          enum:
            - queued
            - processing
            - succeeded
            - failed
            - timeout
            - canceled
        error:
          type: object
          nullable: true
          properties:
            code:
              type: integer
              example: 500
            message:
              type: string
              example: task failed
        created_at:
          type: string
          format: date-time
        started_at:
          type: string
          format: date-time
          nullable: true
        completed_at:
          type: string
          format: date-time
          nullable: true
        elapsed_ms:
          type: integer
          nullable: true
        output:
          nullable: true
          description: >-
            Normalized task output. Null while queued/processing; populated when
            status=succeeded.
          allOf:
            - $ref: '#/components/schemas/MsTaskOutputImage'
      required:
        - task_id
        - endpoint
        - model
        - capability
        - mode
        - status
        - created_at
    ErrorBody:
      type: object
      properties:
        statusCode:
          type: integer
          example: 400
        message:
          type: string
        error:
          type: string
    MsTaskOutputImage:
      type: object
      description: >-
        Succeeded task output: normalized images. Count matches actual produced
        items.
      properties:
        images:
          type: array
          description: Generated images (1..N)
          items:
            type: object
            properties:
              url:
                type: string
                format: uri
                description: Stable mountsea CDN URL (preferred)
              b64:
                type: string
                description: Base64 payload when URL unavailable
              mime:
                type: string
                description: MIME type, e.g. image/png
      required:
        - images
  responses:
    MsTaskImageResponse:
      description: Image task (usually queued right after submit)
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/MsTaskImage'
    BadRequestResponse:
      description: Validation failed or unsupported model
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
    NotFoundResponse:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorBody'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````