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

# openai generate async

> create a task to generate image

A unified entry point for image creation. The backend service automatically determines the action based on the request body:

* **Text-to-Image:** If the `image` field is absent or null, it performs text-to-image generation.
* **Image Editing:** If the `image` field is present, it performs image editing based on the provided image.


## OpenAPI

````yaml post /ai/openai/images/generate
openapi: 3.1.0
info:
  title: OpenAPI definition
  version: v0
servers:
  - url: https://ai.pmock.com/api
    description: Generated server url
security: []
tags:
  - name: 开放-百度视频生成
    description: 开放-百度视频生成
  - name: 开放-Grok开放接口
    description: 开放-Grok开放接口
  - name: 开放-Gemini开放接口
    description: 开放-Gemini开放接口
  - name: 开放-AI对话开放接口
    description: 开放-AI对话开放接口
  - name: 开放-Sora2开放接口
    description: 开放-Sora2开放接口
  - name: 开放-模型列表接口
    description: 开放-模型列表接口
  - name: 开放-OpenAi开放接口
    description: 开放-OpenAi开放接口
  - name: 开放-业务相关接口
    description: 开放-业务相关接口
  - name: 开放-任务开放接口
    description: 开放-任务开放接口
paths:
  /ai/openai/images/generate:
    post:
      tags:
        - 开放-OpenAi开放接口
      summary: openai generate async
      description: create a task to generate image
      operationId: openAiImagesGenerate
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenAiImageGenerateDTO'
        required: true
      responses:
        '200':
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/RTaskResultVO'
components:
  schemas:
    OpenAiImageGenerateDTO:
      type: object
      properties:
        prompt:
          type: string
          description: prompt
          minLength: 1
        model:
          type: string
          description: model
          enum:
            - gpt-image-2
        size:
          type: string
          default: 1024x1024
          description: >-
            image size, ① Single side ≤ 3840 px; ② Both width and height are
            multiples of 16; ③ Long side : short side ≤ 3:1; ④ Total pixels ∈
            [655,360, 8,294,400]. Requests that do not meet the constraints or
            are not supported by the channel for custom sizes will be rejected
          enum:
            - auto
            - 1024x1024
            - 1024x1536
            - 1536x1024
            - 2048x2048
            - 2048x1152
            - 3840x2160
            - 2160x3840
        'n':
          type: integer
          format: int32
          description: Generation quantity (currently only supports 1)
        quality:
          type: string
          default: auto
          description: quality grade
          enum:
            - auto
            - low
            - medium
            - high
            - standard
          title: >-
            auto : auto; low : low; medium : medium; high : high; standard :
            standard
        background:
          type: string
          description: background transparency
          enum:
            - transparent
            - opaque
            - auto
          title: 'transparent : transparent; opaque : opaque; auto : auto'
        outputFormat:
          type: string
          description: Output file format
          enum:
            - png
            - jpeg
            - webp
          title: 'png : png; jpeg : jpeg; webp : webp'
        outputCompression:
          type: integer
          format: int32
          description: JPEG/WebP compression level 0-100
        moderation:
          type: string
          description: Audit intensity
          enum:
            - auto
            - low
          title: 'auto : auto; low : low'
        responseFormat:
          type: string
          description: >-
            Response format (compatible with DALL · E; The gpt image series
            always returns b64_json)
          enum:
            - url
            - b64_json
          title: 'url : url; b64_json : b64_json'
        inputFidelity:
          type: string
          description: >-
            Input image fidelity (newly added in gpt-image-2, only effective for
            editing scenes); Generate can be ignored)
          enum:
            - high
            - low
          title: 'high : high; low : low'
        image:
          type: array
          description: >-
            Enter an image (URL or base64 data URL). If provided, go through
            image editing; If not provided, use text and images. Support single
            or multiple sheets
          items:
            type: string
        mask:
          type: string
          description: >-
            mask image (only for editing scenes, URL or base64 data URL);
            transparent areas will be redrawn
      required:
        - model
        - prompt
        - quality
    RTaskResultVO:
      type: object
      description: Unified return structure for response results
      properties:
        code:
          type: integer
          format: int32
          description: Response status code
          example: 200
        message:
          type: string
          description: Response message
        data:
          $ref: '#/components/schemas/TaskResultVO'
          description: Response result
        traceId:
          type: string
          description: Response traceId
    TaskResultVO:
      type: object
      properties:
        taskId:
          type: string
          description: taskId

````