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

# Edit images

> Edit one or more uploaded images with a prompt and optional mask.



## OpenAPI

````yaml /openapi/naga-api.json post /v1/images/edits
openapi: 3.1.0
info:
  title: NagaAI API
  summary: Unified AI API with OpenAI and Anthropic compatibility layers.
  version: '2026-03-31'
  contact:
    name: NagaAI
    url: https://naga.ac
  termsOfService: https://naga.ac/legal/terms
servers:
  - url: https://api.naga.ac
    description: Production
  - url: http://localhost:8500
    description: Local development
security: []
tags:
  - name: Chat Completions
    description: >-
      OpenAI-compatible chat completion requests, including streaming, tools,
      and multimodal input.
  - name: Messages
    description: >-
      Anthropic-compatible Messages API requests used by Claude-style clients
      and agents.
  - name: Responses
    description: >-
      OpenAI-compatible Responses API requests for structured input, tools, and
      streaming output items.
  - name: Embeddings
    description: >-
      Create vector embeddings for search, retrieval, clustering, and ranking
      use cases.
  - name: Images
    description: >-
      Generate or edit images with multimodal models and OpenAI-compatible
      payloads.
  - name: Audio
    description: >-
      Generate speech or convert uploaded audio into transcriptions and
      translations.
  - name: Moderations
    description: Classify text and image inputs for safety policy categories.
  - name: Models
    description: List available models, capabilities, and pricing metadata.
  - name: Startups
    description: >-
      Public metadata about AI startups and model providers surfaced by the
      gateway.
  - name: Account
    description: Provisioning-key protected account balance and usage endpoints.
  - name: API Keys
    description: Provisioning-key protected API key management endpoints.
paths:
  /v1/images/edits:
    post:
      tags:
        - Images
      summary: Edit images
      description: Edit one or more uploaded images with a prompt and optional mask.
      operationId: editImage
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_editImage'
            examples:
              basic:
                summary: Multipart image edit request
                value:
                  model: gpt-image-1
                  prompt: Replace the background with a rainy cyberpunk street.
                  response_format: url
                  'n': 1
                  image: <binary image>
                  mask: <binary mask>
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '402':
          description: Insufficient credits
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '410':
          description: Model deprecated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '422':
          description: Validation error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationErrorResponse'
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
        '503':
          description: Upstream service error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorEnvelope'
      security:
        - bearerAuth: []
        - xApiKeyAuth: []
components:
  schemas:
    Body_editImage:
      properties:
        model:
          type: string
          title: Model
        prompt:
          type: string
          maxLength: 32000
          minLength: 1
          title: Prompt
        background:
          type: string
          title: Background
        mask:
          anyOf:
            - type: string
              contentMediaType: application/octet-stream
            - type: 'null'
          title: Mask
        'n':
          type: integer
          minimum: 1
          title: 'N'
        quality:
          type: string
          title: Quality
        response_format:
          type: string
          enum:
            - url
            - b64_json
          title: Response Format
          default: url
        size:
          type: string
          title: Size
        image:
          type: string
          contentMediaType: application/octet-stream
          title: Image
        image[]:
          items:
            type: string
            contentMediaType: application/octet-stream
          type: array
          title: Image[]
      type: object
      required:
        - model
        - prompt
      title: Body_editImage
    ImagesResponse:
      properties:
        created:
          type: integer
          title: Created
        data:
          items:
            $ref: '#/components/schemas/ImageDataResponse'
          type: array
          title: Data
        usage:
          $ref: '#/components/schemas/ImageUsageResponse'
      additionalProperties: true
      type: object
      required:
        - created
        - data
        - usage
      title: ImagesResponse
      examples:
        - created: 1743393600
          data:
            - url: https://api.naga.ac/outputs/example-image.png
          usage:
            input_tokens: 42
            output_tokens: 1024
            total_tokens: 1066
    ErrorEnvelope:
      properties:
        error:
          $ref: '#/components/schemas/ErrorBody'
      additionalProperties: true
      type: object
      required:
        - error
      title: ErrorEnvelope
      examples:
        - error:
            message: The request body is invalid.
            type: invalid_request_error
    HTTPValidationErrorResponse:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationErrorItem'
          type: array
          title: Detail
      additionalProperties: true
      type: object
      required:
        - detail
      title: HTTPValidationErrorResponse
    ImageDataResponse:
      properties:
        url:
          anyOf:
            - type: string
            - type: 'null'
          title: Url
        b64_json:
          anyOf:
            - type: string
            - type: 'null'
          title: B64 Json
      additionalProperties: true
      type: object
      title: ImageDataResponse
    ImageUsageResponse:
      properties:
        input_tokens:
          anyOf:
            - type: integer
            - type: 'null'
          title: Input Tokens
        output_tokens:
          type: integer
          title: Output Tokens
        total_tokens:
          type: integer
          title: Total Tokens
      additionalProperties: true
      type: object
      required:
        - output_tokens
        - total_tokens
      title: ImageUsageResponse
    ErrorBody:
      properties:
        type:
          type: string
          title: Type
          description: Stable machine-readable error type.
        message:
          type: string
          title: Message
          description: Human-readable error message.
        code:
          anyOf:
            - type: string
            - type: integer
            - type: 'null'
          title: Code
        param:
          anyOf:
            - type: string
            - type: 'null'
          title: Param
      additionalProperties: true
      type: object
      required:
        - type
        - message
      title: ErrorBody
    ValidationErrorItem:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Loc
        msg:
          type: string
          title: Msg
        type:
          type: string
          title: Type
      additionalProperties: true
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationErrorItem
  securitySchemes:
    bearerAuth:
      type: http
      description: >-
        Primary authentication for inference endpoints. Send your Naga API key
        as `Authorization: Bearer <api-key>`.
      scheme: bearer
    xApiKeyAuth:
      type: apiKey
      description: >-
        Alternate authentication for inference endpoints. Useful for clients
        that send `x-api-key: <api-key>`.
      in: header
      name: x-api-key

````