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

# Edit an image

> OpenAI-compatible image editing endpoint.

Accepts EITHER ``multipart/form-data`` (binary uploads: ``image``, optional
``mask``, ``reference_images``) OR ``application/json`` whose image fields are
data-URL / base64 strings (or ``{"url": ...}`` objects) — the same convention
as the chat ``image_url``. Remote http(s) URLs are rejected (mesh does not
server-side-fetch images); send a ``data:image/<fmt>;base64,<data>`` URL.

Supports ``operation`` in {edit, remove_background, upscale, outpaint, mix,
reframe, inpaint}. Each op is gated by the resolved model's supports_image_<op>
flag (422 when unset / unsupported); the legacy provider matrix is a
transitional backstop for the original four ops.

- ``edit`` (default): openai, byteplus, vertex — prompt + image (+ optional mask + refs).
- ``remove_background``: openai, vertex — image only; prompt optional.
- ``upscale``: vertex (Imagen) or byteplus (Seedream Smart Upscale) — image +
  upscale_factor (x2|x4; Seedream maps x2→2k, x4→4k).
- ``outpaint``: vertex — image + prompt + mask (defines expansion region).
- ``mix``: Gemini image models + gpt-image (openai) — prompt + image + 1-3
  reference_images (2-4 sources composed into one, sent as image[]); single
  output.
- ``reframe``: Gemini image models — image + aspect_ratio
  (1:1|3:4|4:3|9:16|16:9|2:3|3:2); recomposes by outpainting to the target
  ratio; single output.
- ``inpaint``: openai, vertex — image + mask (canonical WHITE=edit; mesh
  normalizes per provider). Optional mask_feather blends the result back
  through the mask (Pillow; 501 if unavailable).

> **Note:** The image response may not render in GitBook's "Test it" panel.
> To view the edited image, try this endpoint with Postman, curl, or another
> HTTP client.



## OpenAPI

````yaml /api/openapi.json post /v1/images/edits
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/images/edits:
    post:
      tags:
        - Images
      summary: Edit an image
      description: >-
        OpenAI-compatible image editing endpoint.


        Accepts EITHER ``multipart/form-data`` (binary uploads: ``image``,
        optional

        ``mask``, ``reference_images``) OR ``application/json`` whose image
        fields are

        data-URL / base64 strings (or ``{"url": ...}`` objects) — the same
        convention

        as the chat ``image_url``. Remote http(s) URLs are rejected (mesh does
        not

        server-side-fetch images); send a ``data:image/<fmt>;base64,<data>``
        URL.


        Supports ``operation`` in {edit, remove_background, upscale, outpaint,
        mix,

        reframe, inpaint}. Each op is gated by the resolved model's
        supports_image_<op>

        flag (422 when unset / unsupported); the legacy provider matrix is a

        transitional backstop for the original four ops.


        - ``edit`` (default): openai, byteplus, vertex — prompt + image (+
        optional mask + refs).

        - ``remove_background``: openai, vertex — image only; prompt optional.

        - ``upscale``: vertex (Imagen) or byteplus (Seedream Smart Upscale) —
        image +
          upscale_factor (x2|x4; Seedream maps x2→2k, x4→4k).
        - ``outpaint``: vertex — image + prompt + mask (defines expansion
        region).

        - ``mix``: Gemini image models + gpt-image (openai) — prompt + image +
        1-3
          reference_images (2-4 sources composed into one, sent as image[]); single
          output.
        - ``reframe``: Gemini image models — image + aspect_ratio
          (1:1|3:4|4:3|9:16|16:9|2:3|3:2); recomposes by outpainting to the target
          ratio; single output.
        - ``inpaint``: openai, vertex — image + mask (canonical WHITE=edit; mesh
          normalizes per provider). Optional mask_feather blends the result back
          through the mask (Pillow; 501 if unavailable).

        > **Note:** The image response may not render in GitBook's "Test it"
        panel.

        > To view the edited image, try this endpoint with Postman, curl, or
        another

        > HTTP client.
      operationId: edit_image
      parameters:
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
            default: 2026-08
          example: 2026-08
          description: >-
            Dated version of the API contract to pin this request to. Omit it
            and the request is served under `2026-08` — the oldest supported
            version, so an existing integration is never moved by a release. A
            malformed or unsupported value is rejected with `400
            invalid_api_version` rather than falling back silently. The version
            actually served is echoed as `X-Mesh-Version` on every response,
            including errors.
      requestBody:
        content:
          application/json:
            examples:
              default:
                summary: Example request (JSON with base64 image)
                value:
                  model: openai/gpt-image-1
                  prompt: Add a red scarf to the portrait
                  image:
                    url: >-
                      data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
      responses:
        '200':
          description: The edited image(s).
          content:
            application/json:
              schema: {}
              examples:
                default:
                  summary: Successful image edit response
                  value:
                    created: 1717200000
                    data:
                      - url: >-
                          https://images.example.com/edits/portrait-with-scarf.png
        '401':
          description: Missing or invalid API key
        '402':
          description: Insufficient balance or spend cap reached
        '415':
          description: Unsupported image content type
        '422':
          description: Validation error (missing required field or oversized file)
        '429':
          description: Rate limit exceeded
        '500':
          description: Upstream provider error
        '501':
          description: Provider does not support image editing
      security:
        - BearerAuth: []
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) — sent as `Authorization: Bearer
        <key>`.

````