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

# Modifier une image

> Edit an uploaded image with an optional mask using the OpenAI-compatible image editing endpoint. Also accepts Qwen-compatible JSON payloads with an `input.messages` wrapper.



## OpenAPI

````yaml api-reference/openapi.json POST /v1/images/edits
openapi: 3.1.0
info:
  title: DGrid AI Gateway API
  description: >-
    A single, unified API to access 200+ leading AI models. OpenAI-, Claude-,
    and Gemini-compatible endpoints for chat, completions, embeddings, images,
    audio, and moderations.
  version: 1.0.0
  contact:
    name: DGrid AI
    url: https://dgrid.ai
servers:
  - url: https://api.dgrid.ai
    description: DGrid AI Gateway
security:
  - bearerAuth: []
paths:
  /v1/images/edits:
    post:
      tags:
        - Images
      summary: Edit image
      description: >-
        Edit an uploaded image with an optional mask using the OpenAI-compatible
        image editing endpoint. Also accepts Qwen-compatible JSON payloads with
        an `input.messages` wrapper.
      operationId: editImage
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - image
                - prompt
              properties:
                image:
                  type: string
                  format: binary
                  description: Source image in PNG format, under 4 MB.
                mask:
                  type: string
                  format: binary
                  description: Optional mask image.
                prompt:
                  type: string
                  description: Editing instruction.
                model:
                  type: string
                  description: Target image model.
                'n':
                  type: integer
                  description: Number of outputs.
                size:
                  type: string
                  description: Output size.
                response_format:
                  type: string
                  description: Response format.
                user:
                  type: string
                  description: End-user identifier.
          application/json:
            schema:
              type: object
              title: Qwen format
              required:
                - model
                - input
              properties:
                model:
                  type: string
                  description: Model identifier.
                input:
                  type: object
                  description: Input wrapper object.
                  properties:
                    messages:
                      type: array
                      description: Messages array nested under `input`.
                      items:
                        type: object
      responses:
        '200':
          description: Edited images in the image generation response format.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
components:
  schemas:
    ImageResponse:
      type: object
      properties:
        created:
          type: integer
          description: Creation timestamp.
        data:
          type: array
          description: Generated image entries.
          items:
            type: object
            properties:
              url:
                type: string
                description: Image URL when using URL output.
              b64_json:
                type: string
                description: Base64 image payload when requested.
              revised_prompt:
                type: string
                description: Refined prompt returned by the model.
        usage:
          type: object
          properties:
            total_tokens:
              type: integer
            input_tokens:
              type: integer
            output_tokens:
              type: integer
            input_tokens_details:
              type: object
              properties:
                text_tokens:
                  type: integer
                image_tokens:
                  type: integer
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            param:
              type: string
            code:
              type: string
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your DGrid API key. All endpoints use `Authorization: Bearer
        <DGRID_API_KEY>`.

````