> ## 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.

# Edit Image Async

> Interface description: Edit the image asynchronously, return the logId immediately, and poll the results through the task status query interface.

Before calling this interface, please request the ["Image Editing Models"](/en/api-reference/get-api-ai-models-image-edit) interface (`GET /api/ai/models/image/edit`) to obtain the currently available model list and the size, maximum number of input images, and price supported by each model, and then fill in the parameters of this interface accordingly.

Image editing is **image-to-image**: the reference image `image` must be passed in, and the prompt words can be used to modify and redraw it based on it. If you want to generate a new image (text-to-image) using only text, please use the ["Generate Image Async"](/en/api-reference/post-api-ai-image-generate-async) interface.



## OpenAPI

````yaml /openapi/en/aitoearn.openapi.json post /api/ai/image/edit/async
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
paths:
  /api/ai/image/edit/async:
    post:
      tags:
        - AI Services/Image Generation
      summary: Edit Image Async
      description: >-
        Interface description: Edit the image asynchronously, return the logId
        immediately, and poll the results through the task status query
        interface.


        Before calling this interface, please request the ["Image Editing
        Models"](/en/api-reference/get-api-ai-models-image-edit) interface (`GET
        /api/ai/models/image/edit`) to obtain the currently available model list
        and the size, maximum number of input images, and price supported by
        each model, and then fill in the parameters of this interface
        accordingly.


        Image editing is **image-to-image**: the reference image `image` must be
        passed in, and the prompt words can be used to modify and redraw it
        based on it. If you want to generate a new image (text-to-image) using
        only text, please use the ["Generate Image
        Async"](/en/api-reference/post-api-ai-image-generate-async) interface.
      operationId: ImageController_editImageAsync
      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.
                image:
                  anyOf:
                    - type: string
                    - type: array
                      items:
                        type: string
                  description: original picture
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 4000
                  description: Edit description
                mask:
                  type: string
                  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.
                'n':
                  description: Number of images generated
                  type: integer
                  minimum: 1
                  maximum: 1
                size:
                  type: string
                  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`.
                response_format:
                  type: string
                  enum:
                    - url
                    - b64_json
                  description: Return format
              required:
                - model
                - image
                - prompt
            examples: {}
        required: true
      responses:
        '200':
          description: >-
            The request has been processed by the service. Business success is
            determined by whether the response body has code === 0.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/AsyncTaskResponseVo'
                  code:
                    type: integer
                    description: >-
                      Business status code. 0 means success; non-zero means a
                      business error.
                  message:
                    type: string
                    description: Response message.
                  requestId:
                    type: string
                    description: Request ID.
                  timestamp:
                    type: integer
                    description: Error response timestamp in Unix milliseconds.
                required:
                  - code
                  - message
              examples:
                success:
                  summary: Success
                  value:
                    code: 0
                    message: Request succeeded
                    data:
                      logId: string
                      status: generating
                validationFailed10002:
                  summary: ValidationFailed (10002)
                  value:
                    code: 10002
                    message: Parameter validation failed
                    data: {}
                    timestamp: 1772099056662
                unauthorized401:
                  summary: Unauthenticated or invalid API Key
                  value:
                    code: 401
                    message: Unauthorized
                    data: {}
                    timestamp: 1772099056662
                invalidModel12300:
                  summary: InvalidModel (12300)
                  value:
                    code: 12300
                    message: Invalid AI model
                    data: {}
                    timestamp: 1772099056662
                userCreditsInsufficient12001:
                  summary: UserCreditsInsufficient (12001)
                  value:
                    code: 12001
                    message: Insufficient User Credits
                    data: {}
                    timestamp: 1772099056662
      deprecated: false
      security:
        - apikey-header-X-Api-Key: []
components:
  schemas:
    AsyncTaskResponseVo:
      type: object
      properties:
        logId:
          type: string
          description: Task log ID
        status:
          type: string
          enum:
            - generating
            - success
            - failed
          description: Task status
      required:
        - logId
        - status
      additionalProperties: false
  securitySchemes:
    apikey-header-X-Api-Key:
      type: apiKey
      in: header
      name: X-Api-Key
      description: >-
        Need to get API Key from AiToEarn. Click to go to ["API Key Obtaining
        Tutorial"](/en/use/api-key).

````