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

# Edit an image

> POST /v1/images/edits — modify an existing image with a prompt.

Models like Nano Banana (Gemini Image) support edits — provide a source image + prompt:

```bash theme={null}
curl https://api.infery.ai/v1/images/edits \
  -H "Authorization: Bearer $INFERY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-2-5-flash-image",
    "prompt": "Replace the background with a tropical beach",
    "image_base64": "<base64 of source image>"
  }'
```

### Sample output

<Frame caption="Source image — autumn Japanese garden">
  <img src="https://mintcdn.com/inferyai/5YDpMTITcUUspdCA/samples/image.png?fit=max&auto=format&n=5YDpMTITcUUspdCA&q=85&s=2f7c6a22252e41004c0e7d721f028888" alt="Source image before edit" width="1024" height="1024" data-path="samples/image.png" />
</Frame>

<Frame caption="Edited: 'Transform this into a snowy winter wonderland — keep the layout intact.' (gemini-2.5-flash-image)">
  <img src="https://mintcdn.com/inferyai/5YDpMTITcUUspdCA/samples/image-edit.png?fit=max&auto=format&n=5YDpMTITcUUspdCA&q=85&s=835e681979410038634eb22d3ad3f7d2" alt="Image after edit" width="1024" height="1024" data-path="samples/image-edit.png" />
</Frame>

*Image-edit output format matches [image generation](/api-reference/images/generations).*

## Supported models

Image-edit capability is model-dependent. Check `capabilities.imageEdit: true` via `GET /v1/models/{slug}` or see [Models catalog](/models/catalog).


## OpenAPI

````yaml openapi.json POST /v1/images/edits
openapi: 3.0.0
info:
  title: Infery Gateway
  description: >-
    Infery Inference Gateway — OpenAI-compatible API for LLMs, embeddings,
    images, audio, and video
  version: '1.0'
  contact: {}
servers:
  - url: https://api.infery.ai
    description: Production
  - url: http://localhost:3001
    description: Local
security: []
tags: []
paths:
  /v1/images/edits:
    post:
      tags:
        - Images
      summary: Edit an existing image
      operationId: createImageEdit
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
                - image_base64
              properties:
                model:
                  type: string
                prompt:
                  type: string
                  description: Edit instruction
                image_base64:
                  type: string
                  description: Base64-encoded source image
                image_mime_type:
                  type: string
                  default: image/png
                mask_base64:
                  type: string
                  description: Base64-encoded mask (transparent area = edit region)
                mask_mime_type:
                  type: string
                  default: image/png
                'n':
                  type: integer
                  default: 1
                size:
                  type: string
                  enum:
                    - 256x256
                    - 512x512
                    - 1024x1024
                    - 1792x1024
                    - 1024x1792
                  default: 1024x1024
                response_format:
                  type: string
                  enum:
                    - url
                    - b64_json
                  default: url
      responses:
        '200':
          description: Image edit result
          content:
            application/json:
              schema:
                type: object
                properties:
                  created:
                    type: integer
                    example: 1713204900
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                          example: /samples/image.png
                          description: Ephemeral provider-hosted URL.
                        b64_json:
                          type: string
                          description: Inline base64-encoded PNG.
                        revised_prompt:
                          type: string
                    example:
                      - url: /samples/image.png
                  credits_used:
                    type: integer
                    example: 40
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '401':
          description: Unauthorized — invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
        '404':
          description: Model not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponseDto'
      security:
        - ApiKey: []
components:
  schemas:
    ErrorResponseDto:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/ErrorDetailDto'
      required:
        - error
    ErrorDetailDto:
      type: object
      properties:
        message:
          type: string
          example: Model not found
          description: Human-readable error message
        type:
          type: string
          example: invalid_request_error
          description: Error category
          enum:
            - invalid_request_error
            - authentication_error
            - permission_error
            - quota_exceeded
            - rate_limit_error
            - server_error
        code:
          type: object
          example: model_not_found
          nullable: true
          description: Stable machine-readable error code
        param:
          type: object
          example: model
          nullable: true
          description: >-
            Name of the request parameter that triggered the error, if
            applicable
      required:
        - message
        - type
        - code
        - param
  securitySchemes:
    ApiKey:
      type: apiKey
      in: header
      name: Authorization
      description: 'API key in format: Bearer inf_***'

````