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

# Generate Image Async

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

Before calling this interface, please request the ["Image Generation Model"](/en/api-reference/get-api-ai-models-image-generation) interface (`GET /api/ai/models/image/generation`) to obtain the currently available model list and the size, quality, style and price supported by each model, and then fill in the parameters of this interface accordingly.

The image is generated as **Wen Sheng Picture**: Generate a new image only through text prompts, without passing in pictures. If you need to make modifications based on existing images (picture-generated images), please use the ["Asynchronous Image Editing"](/en/api-reference/post-api-ai-image-edit-async) interface.



## OpenAPI

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


        Before calling this interface, please request the ["Image Generation
        Model"](/en/api-reference/get-api-ai-models-image-generation) interface
        (`GET /api/ai/models/image/generation`) to obtain the currently
        available model list and the size, quality, style and price supported by
        each model, and then fill in the parameters of this interface
        accordingly.


        The image is generated as **Wen Sheng Picture**: Generate a new image
        only through text prompts, without passing in pictures. If you need to
        make modifications based on existing images (picture-generated images),
        please use the ["Asynchronous Image
        Editing"](/en/api-reference/post-api-ai-image-edit-async) interface.
      operationId: ImageController_generateImageAsync
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                prompt:
                  type: string
                  minLength: 1
                  maxLength: 4000
                  description: Image description tips
                model:
                  type: string
                  description: >-
                    Image generation model name. First call the ["Image
                    Generation
                    Model"](/en/api-reference/get-api-ai-models-image-generation)
                    interface (`GET /api/ai/models/image/generation`) and pass
                    in the `data[n].name` returned by it; the size, quality,
                    style and price supported by each model shall be subject to
                    the return of this interface.
                'n':
                  description: Number of images generated
                  type: integer
                  minimum: 1
                  maximum: 10
                quality:
                  type: string
                  description: >-
                    Image quality. The optional values ​​vary from model to
                    model, and are subject to the `data[n].qualities` returned
                    by the ["Image Generation
                    Model"](/en/api-reference/get-api-ai-models-image-generation)
                    interface.
                response_format:
                  type: string
                  enum:
                    - url
                    - b64_json
                  description: Return format
                size:
                  type: string
                  description: >-
                    Image size. The optional values ​​vary with the model, and
                    are subject to the `data[n].sizes` returned by the ["Image
                    Generation
                    Model"](/en/api-reference/get-api-ai-models-image-generation)
                    interface; the prices for different sizes are different, see
                    `data[n].pricing`.
                style:
                  type: string
                  description: >-
                    Image style. The optional values ​​vary with the model, and
                    are subject to the `data[n].styles` returned by the ["Image
                    Generation
                    Model"](/en/api-reference/get-api-ai-models-image-generation)
                    interface; returning empty means that the model does not
                    support style parameters.
              required:
                - prompt
                - model
            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).

````