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

# OpenAI Image Editing

> Interface description: Compatible endpoint of OpenAI Images API `/v1/images/edits` (image-to-image). The request, response and error formats fully comply with the OpenAI specifications: `application/json` and `multipart/form-data` are supported (images and mask files can be uploaded directly), OpenAI original `ImagesResponse` is returned, and the AiToEarn universal response package is not used; the image link is the original return from the upstream and is not transferred. Authentication uses `Authorization: Bearer <API Key>` (OpenAI SDK carries it by default). Existing OpenAI SDK or ecological tools only need to replace the baseURL and API Key to access, and billing is based on AiToEarn points.

The model value comes from `data[n].name` returned by the ["Image Editing Model"](/en/api-reference/get-api-ai-models-image-edit) interface. If you need the AiToEarn universal response format (`code === 0`) and the stable image link after dumping, please use the ["Edit Image"](/en/api-reference/post-api-ai-image-edit) interface instead.



## OpenAPI

````yaml /openapi/en/aitoearn.openapi.json post /api/ai/images/edits
openapi: 3.0.1
info:
  title: AiToEarn Open Platform API
  description: >-
    AiToEarn Open Platform API. You can switch between the China and
    international sites for testing. Business success is determined by whether
    the response body has code === 0.
  version: 1.0.0
  contact: {}
servers:
  - url: https://aitoearn.cn
    description: China site
  - url: https://aitoearn.ai
    description: International site
security: []
tags:
  - name: AI Services
  - name: AI Services/Video Generation
  - name: AI Services/Image Generation
  - name: Channel Management
  - name: Channel Management/Accounts
  - name: Channel Management/Publishing
  - name: Channel Management/Platforms
  - name: Channel Management/Works
  - name: Channel Management/Account Groups
  - name: Channel Management/Authorization
  - name: Asset Management
  - name: AI Services/Large Language Models
  - name: AI Services/Real-person Verification
  - name: AI Services/Virtual Portrait Assets
  - name: AI Services/Agent
  - name: Account & Keys/API Key
paths:
  /api/ai/images/edits:
    post:
      tags:
        - AI Services/Image Generation
      summary: OpenAI Image Editing
      description: >-
        Interface description: Compatible endpoint of OpenAI Images API
        `/v1/images/edits` (image-to-image). The request, response and error
        formats fully comply with the OpenAI specifications: `application/json`
        and `multipart/form-data` are supported (images and mask files can be
        uploaded directly), OpenAI original `ImagesResponse` is returned, and
        the AiToEarn universal response package is not used; the image link is
        the original return from the upstream and is not transferred.
        Authentication uses `Authorization: Bearer <API Key>` (OpenAI SDK
        carries it by default). Existing OpenAI SDK or ecological tools only
        need to replace the baseURL and API Key to access, and billing is based
        on AiToEarn points.


        The model value comes from `data[n].name` returned by the ["Image
        Editing Model"](/en/api-reference/get-api-ai-models-image-edit)
        interface. If you need the AiToEarn universal response format (`code ===
        0`) and the stable image link after dumping, please use the ["Edit
        Image"](/en/api-reference/post-api-ai-image-edit) interface instead.
      operationId: RelayController_imagesEdits
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                model:
                  type: string
                  description: >-
                    Image editing model name. First call the ["Image Editing
                    Models"](/en/api-reference/get-api-ai-models-image-edit)
                    interface (`GET /api/ai/models/image/edit`) and pass in the
                    `data[n].name` returned by it; the size, maximum number of
                    input images and price supported by each model shall be
                    subject to the return of this interface.
                  example: gpt-image-2
                image:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: Picture list
                  example: >-
                    https://images.unsplash.com/photo-1592194996308-7b43878e84a6?auto=format&fit=crop&w=1024&q=80
                prompt:
                  type: string
                  description: prompt word
                  example: >-
                    Edit the provided image into a cozy realistic scene by
                    placing the cute orange cat beside a sunlit window.
                mask:
                  description: >-
                    Mask image URL for **partial redraw** (optional). It needs
                    to be a PNG image with the same size as `image`: the
                    completely transparent area (alpha is 0) represents the part
                    that needs to be redrawn according to the prompt word, and
                    the opaque area remains unchanged. Edit the entire image
                    when not uploading.
                  type: string
                'n':
                  type: integer
                  minimum: 1
                  maximum: 9007199254740991
                  description: Generate quantity
                  example: 1
                size:
                  description: >-
                    Image size. The optional values ​​vary from model to model,
                    and are subject to the `data[n].sizes` returned by the
                    ["Image Editing
                    Models"](/en/api-reference/get-api-ai-models-image-edit)
                    interface; the prices for different sizes are different, see
                    `data[n].pricing`.
                  type: string
                  example: 1024x1024
                response_format:
                  description: Return format
                  type: string
                  enum:
                    - url
                    - b64_json
                  example: url
              required:
                - model
                - image
                - prompt
              additionalProperties: true
              example:
                model: gpt-image-2
                image: >-
                  https://images.unsplash.com/photo-1592194996308-7b43878e84a6?auto=format&fit=crop&w=1024&q=80
                prompt: >-
                  Edit the provided image into a cozy realistic scene by placing
                  the cute orange cat beside a sunlit window.
                'n': 1
                size: 1024x1024
                response_format: url
            examples:
              lowest-cost:
                summary: Lowest-cost example
                value:
                  model: gpt-image-2
                  image: >-
                    https://images.unsplash.com/photo-1592194996308-7b43878e84a6?auto=format&fit=crop&w=1024&q=80
                  prompt: >-
                    Edit the provided image into a cozy realistic scene by
                    placing the cute orange cat beside a sunlit window.
                  'n': 1
                  size: 1024x1024
                  response_format: url
        required: true
      responses:
        '200':
          description: >-
            Native third-party protocol response or SSE data, not wrapped in the
            AiToEarn common response envelope.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        url:
                          type: string
                  created:
                    type: number
                  size:
                    type: string
                  usage:
                    type: object
                    properties:
                      input_tokens:
                        type: number
                      output_tokens:
                        type: number
                      total_tokens:
                        type: number
                      input_tokens_details:
                        type: object
                        properties:
                          text_tokens:
                            type: number
                          image_tokens:
                            type: number
                      output_tokens_details:
                        type: object
                        properties:
                          text_tokens:
                            type: number
                          image_tokens:
                            type: number
                additionalProperties: true
                example:
                  data:
                    - url: string
                  created: number
                  size: string
                  usage:
                    input_tokens: number
                    output_tokens: number
                    total_tokens: number
                    input_tokens_details:
                      text_tokens: number
                      image_tokens: number
                    output_tokens_details:
                      text_tokens: number
                      image_tokens: number
              examples:
                success:
                  summary: Native third-party success response
                  value:
                    data:
                      - url: string
                    created: number
                    size: string
                    usage:
                      input_tokens: number
                      output_tokens: number
                      total_tokens: number
                      input_tokens_details:
                        text_tokens: number
                        image_tokens: number
                      output_tokens_details:
                        text_tokens: number
                        image_tokens: number
            text/event-stream:
              schema:
                type: string
      deprecated: false
      security:
        - apikey-header-Authorization: []
components:
  securitySchemes:
    apikey-header-Authorization:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Pass the API Key obtained from AiToEarn. Go to the ["API Key
        Tutorial"](/en/use/api-key). Example: Bearer xxx.

````

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