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

# Edit images

> Edits or extends one or more uploaded images (multipart/form-data, fields `image` or `image[]`, optional `mask`). Billing, size tiers, `n`, `b64_json` output and the long-call behaviour are the same as Create images. The whole request may be up to 20 MiB.



## OpenAPI

````yaml /openapi.json post /v1/images/edits
openapi: 3.1.0
info:
  title: OmniRelay API
  version: 1.0.0
  description: >-
    OpenAI-compatible gateway for reviewed real text models. Access is
    workspace-specific; query your own model list for capabilities and customer
    prices.
servers:
  - url: https://api.omnirelay.ai
security:
  - bearerAuth: []
tags:
  - name: Service
  - name: Models
  - name: Chat
  - name: Management
  - name: Responses
  - name: Embeddings
  - name: Images
  - name: Videos
paths:
  /v1/images/edits:
    post:
      tags:
        - Images
      summary: Edit images
      description: >-
        Edits or extends one or more uploaded images (multipart/form-data,
        fields `image` or `image[]`, optional `mask`). Billing, size tiers, `n`,
        `b64_json` output and the long-call behaviour are the same as Create
        images. The whole request may be up to 20 MiB.
      operationId: editImage
      parameters:
        - name: X-Gateway-Tags
          in: header
          required: false
          description: >-
            Tags for this call as comma-separated `key=value` pairs, for example
            `client=acme,env=prod`. Merged with the API key's default tags; the
            `tags` body field wins on the same key. `X-OmniRelay-Tags` is the
            same header under its former name and stays accepted.
          schema:
            type: string
          example: client=acme,env=prod
        - name: X-Gateway-Metadata
          in: header
          required: false
          description: >-
            Send `enabled` to receive a `gateway_metadata` block describing what
            the gateway decided. Any other value, or no header, leaves the
            response unchanged. `X-OmniRelay-Metadata` is the same header under
            its former name and stays accepted.
          schema:
            type: string
            enum:
              - enabled
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ImagesEditRequest'
      responses:
        '200':
          description: Images with settled usage and cost.
          headers:
            X-Request-ID:
              description: >-
                OmniRelay request ID for diagnostics. It is separate from the
                provider trace, header and response IDs.
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
        '400':
          description: >-
            Invalid JSON, form or parameters (`response_format` other than
            `b64_json`, `stream`, an unknown `size`, `n` above the model limit),
            or a parameter the model refused. Nothing is charged.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: unsupported_parameter
                request_id: 2f6c1d0e9a
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          description: >-
            inference_budget_or_access_denied: wallet, key or platform budget
            cannot cover n images at the requested tier; member_budget_exceeded:
            member cap exceeded. Rejected before dispatch.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: inference_budget_or_access_denied
                request_id: 2f6c1d0e9a
        '403':
          description: >-
            `model_not_allowed`: the API key is limited to other models;
            `ip_not_allowed`. Nothing is charged.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_not_allowed
                request_id: 2f6c1d0e9a
        '404':
          description: >-
            `model_unavailable`: the model is not an image model available to
            this workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: model_unavailable
                request_id: 2f6c1d0e9a
        '413':
          description: 'payload_too_large: the request body exceeds 20 MiB.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: payload_too_large
                request_id: 2f6c1d0e9a
        '429':
          description: >-
            Rate or concurrency limit. Nothing is charged; retry after
            Retry-After seconds.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: rate_limited
                request_id: 2f6c1d0e9a
        '502':
          description: >-
            `upstream_rejected`: the provider refused the call; nothing is
            charged. `image_call_held`: a dropped connection, a provider server
            error or an answer that could not be verified; the call is held for
            review and charged only if the provider produced the images.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: image_call_held
                request_id: 2f6c1d0e9a
        '503':
          description: Live access is not ready or paused. Nothing is sent or charged.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: live_provider_unavailable
                request_id: 2f6c1d0e9a
        '504':
          description: >-
            `image_call_held`: the call did not finish in time. It is held for
            review and charged only if the provider produced the images.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: image_call_held
                request_id: 2f6c1d0e9a
components:
  schemas:
    ImagesEditRequest:
      type: object
      required:
        - model
        - prompt
        - image
      description: >-
        Other fields (`background`, `output_format`, `output_compression`,
        `moderation`, `user`) are passed to the model, which accepts or refuses
        them.
      properties:
        model:
          type: string
          description: Image model ID, for example `gpt-image-2`.
          example: gpt-image-2
        prompt:
          type: string
          maxLength: 32000
          description: Text description of the image, up to 32000 characters.
        'n':
          type: integer
          minimum: 1
          maximum: 4
          default: 1
          description: >-
            Number of images, 1 to the model limit (4). n images are reserved;
            only the images returned are charged.
        size:
          type: string
          default: auto
          example: 1024x1024
          description: >-
            `WIDTHxHEIGHT` or `auto`. Decides the price tier: longest side up to
            1024 px is 1K, up to 2048 px is 2K, up to 4096 px is 4K; `auto` or
            omitted is 2K.
        quality:
          type: string
          description: >-
            Passed to the model, for example `low`, `medium`, `high` or `auto`.
            Does not change the price.
        response_format:
          type: string
          enum:
            - b64_json
          description: Only `b64_json` is supported.
        image:
          type: string
          format: binary
          description: One or more source images (PNG, JPEG or WebP).
        mask:
          type: string
          format: binary
          description: Optional mask image; transparent areas mark where to edit.
      additionalProperties: true
    ImagesResponse:
      type: object
      required:
        - created
        - data
        - model
        - cost_microusd
      properties:
        created:
          type: integer
        model:
          type: string
        data:
          type: array
          description: Generated images.
          items:
            type: object
            required:
              - b64_json
            properties:
              b64_json:
                type: string
                description: Base64-encoded image.
              revised_prompt:
                type: string
        background:
          type: string
        output_format:
          type: string
        quality:
          type: string
        size:
          type: string
        usage:
          type: object
          description: >-
            Token counts reported by the model, for information; images are
            billed per image, not per token.
          additionalProperties: true
        cost_microusd:
          type: integer
          description: Charged amount in micro-USD after your discount.
        omnirelay_metadata:
          $ref: '#/components/schemas/RequestMetadata'
        gateway_metadata:
          $ref: '#/components/schemas/RequestMetadata'
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
            - type
          properties:
            code:
              type: string
              example: model_unavailable
            message:
              type: string
              example: The model does not exist or is disabled.
              description: >-
                Short English description for logs and SDK exceptions. Its
                wording can change; branch on code.
            type:
              type: string
              example: not_found_error
              description: >-
                Error family by HTTP status: invalid_request_error,
                authentication_error, insufficient_quota, permission_error,
                not_found_error, conflict_error, rate_limit_error,
                service_unavailable or api_error.
            param:
              type: string
              maxLength: 200
              description: >-
                Rejected request field path when identifiable; never a parameter
                value. Responses uses native field names.
        request_id:
          type: string
          description: Present on chat completion, Responses and embeddings errors.
    RequestMetadata:
      type: object
      description: >-
        Present only when the request sent `X-Gateway-Metadata: enabled`.
        Returned under both `gateway_metadata` and its former name
        `omnirelay_metadata`, with the same content. On a stream it rides the
        first chunk.
      properties:
        request_id:
          type: string
          description: The request ID, as in `X-Request-ID`.
        requested:
          type: string
          description: The model ID you sent.
        model:
          type: string
          description: The model that served the call.
        provider:
          type: string
          description: The provider of that model.
        mode:
          type: string
          enum:
            - live
          description: 'live: a real provider was called.'
        strategy:
          type: string
          enum:
            - direct
          description: >-
            How the model was resolved. Every model has one channel today, so
            this is always `direct`.
        attempt:
          type: integer
          description: >-
            1-based position of the attempt that served. Always 1 until fallback
            exists.
        attempts:
          type: array
          description: Every attempt made, in order.
          items:
            type: object
            properties:
              provider:
                type: string
              model:
                type: string
              mode:
                type: string
        tags:
          type: object
          additionalProperties:
            type: string
          description: The tags recorded for this call, or `{}`.
        deprecated_header:
          type: string
          description: >-
            Present when the request sent an old-style header
            (`X-OmniRelay-Tags` or `X-OmniRelay-Metadata`) together with its new
            name carrying a different value: names the old header that was
            ignored.
  responses:
    Unauthorized:
      description: '`unauthorized`: the API key is missing, revoked, or invalid.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        An API key created in the OmniRelay console. The owner can view it again
        in the console after confirming their identity.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.