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

# xai generate image

> create a task to generate image



## OpenAPI

````yaml post /ai/xai/image/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/xai/image/generate:
    post:
      tags:
        - 开放-Grok开放接口
      summary: xai generate image
      description: create a task to generate image
      operationId: xaiImageGenerate
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GrokXaiImageGenerateDTO'
        required: true
      responses:
        '200':
          description: OK
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/RTaskResultVO'
components:
  schemas:
    GrokXaiImageGenerateDTO:
      type: object
      properties:
        prompt:
          type: string
          description: >-
            Video generated prompt words, currently only supporting English
            explanations
          minLength: 1
        model:
          type: string
          description: image model
          enum:
            - grok-imagine-image
          title: grok-imagine-image
        aspectRatio:
          type: string
          description: image aspectRatio
          enum:
            - '1:1'
            - '3:2'
            - '2:3'
            - '16:9'
            - '9:16'
          title: '1:1 : 1:1; 3:2 : 3:2; 2:3 : 2:3; 16:9 : 16:9; 9:16 : 9:16'
        images:
          type: array
          description: >-
            Reference image URL (Image generated/edited, up to 1 image, provided
            with image size following the reference image)
          items:
            type: string
      required:
        - model
        - prompt
    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

````