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

# Image Generation

<Note>
  Note: For setting the image generation model name, refer to the [System Supported Image Generation Models List](https://geekai.dev/models), \`\`\`markdown
  currently supported image generation models are `dall-e-3`, `cogview-3-flash` (free), `cogview-3-plus`, and `cogview-4`. The request/response parameter structure is fully compatible with [OpenAI](https://platform.openai.com/docs/api-reference/images). When switching models, you only need to modify the corresponding model name. If the model request/response parameters are inconsistent with OpenAI, GeekAI will automatically convert and align them at the underlying level.
  The response data format is fully compatible with OpenAI.
</Note>

Different AI platforms support different image sizes for their image generation models. Please refer to the table below for the specific supported sizes:

<div style={{ width: '100%', overflowX: 'auto' }}>
  <table style={{ width: '100%', borderCollapse: 'collapse', tableLayout: 'fixed' }}>
    <thead>
      <tr>
        <th style={{ border: '1px solid #ccc', padding: '10px'}}>Platform</th>
        <th style={{ border: '1px solid #ccc', padding: '10px'}}>Model</th>
        <th style={{ border: '1px solid #ccc', padding: '10px', width: '60%'}}>Supported Sizes</th>
      </tr>
    </thead>

    <tbody>
      <tr>
        <td style={{ border: '1px solid #ccc', padding: '8px' }}>OpenAI</td>
        <td style={{ border: '1px solid #ccc', padding: '8px' }}>DALL·E 3</td>

        <td style={{ border: '1px solid #ccc', padding: '8px' }}>
          1024x1024, 1792x1024, 1024x1792 (default is 1024x1024)
        </td>
      </tr>

      <tr>
        <td style={{ border: '1px solid #ccc', padding: '8px' }}>Zhipu</td>
        <td style={{ border: '1px solid #ccc', padding: '8px' }}>CogView Series</td>

        <td style={{ border: '1px solid #ccc', padding: '8px' }}>
          1024x1024, 768x1344, 864x1152, 1344x768,
          1152x864, 1440x720, 720x1440 (default is 1024x1024)
        </td>
      </tr>
    </tbody>
  </table>
</div>

### cURL Request Example

```bash theme={null}
curl --location 'https://geekai.dev/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: {YOUR_GEEKAI_API_KEY}' \
--data '{
    "model":"dall-e-3",
    "prompt":"Draw a cute kitten playing in the grass",
    "size": "1024x1024",
    "n":1
}'
```


## OpenAPI

````yaml openapi.yaml POST /images/generations
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /images/generations:
    post:
      tags:
        - Image
      summary: 图片生成接口
      description: 基于文本提示生成AI图片的接口，支持多种图片生成模型和参数配置
      operationId: createImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  description: 图片生成模型
                  example: gpt-image-1
                prompt:
                  type: string
                  description: 文本提示
                  example: 画一只可爱的小猫
                negative_prompt:
                  type: string
                  description: 反向提示词，用来描述不希望在画面中看到的内容，可以对画面进行限制
                image:
                  oneOf:
                    - type: string
                      description: 单张图片URL/Base64编码数据，仅支持图生图模型支持该配置
                    - type: array
                      description: 多张图片URL/Base64编码数组列表，仅支持图生图模型支持该配置
                      items:
                        type: string
                strength:
                  type: number
                  description: 以图生图引用图片的影响强度，取值范围[0, 1]，默认0.5
                  default: 0.5
                size:
                  type: string
                  description: 图片尺寸，不同模型设置不同，详见模型尺寸表
                  default: 1024x1024
                aspect_ratio:
                  type: string
                  description: 图片宽高比，不同模型设置不同，详见模型尺寸表
                  default: '1:1'
                'n':
                  type: integer
                  description: 图片数量，默认为1
                  default: 1
                quality:
                  type: string
                  description: >-
                    图片质量，可灵AI支持 std、pro 两个配置，OpenAI/智谱清言支持 standard、hd 两个配置，GPT
                    Image支持 auto/low/medium/high 四个配置项
                  default: medium
                style_preset:
                  type: string
                  description: 风格预设，目前仅 stable image 支持该配置
                  example: 3d-model
                response_format:
                  type: string
                  description: 图片响应格式，支持 url/b64_json 两种格式，默认为url
                  enum:
                    - url
                    - b64_json
                  default: url
                output_format:
                  type: string
                  description: 图片输出格式，支持 png/jpg/webp 三种格式，默认为png
                  enum:
                    - png
                    - jpg
                    - webp
                  default: png
                mask:
                  type: string
                  description: 图片遮罩，支持图片URL/Base64编码数据
                watermark:
                  type: boolean
                  description: 是否添加AI生成水印，默认为false，仅部分模型支持
                  default: false
                background:
                  type: string
                  description: 背景透明度，目前仅 gpt-image-1 支持该配置
                  enum:
                    - transparent
                    - opaque
                    - auto
                  default: auto
                extra_body:
                  type: object
                  description: 额外参数配置项，以适配不同画图模型的多样化配置
                  properties:
                    sequential_image_generation:
                      type: string
                      description: 控制是否关闭组图功能，仅 doubao-seedream-4.0 支持该参数，默认disabled
                      enum:
                        - auto
                        - disabled
                      default: disabled
                    sequential_image_generation_options:
                      type: object
                      description: >-
                        组图功能的配置，仅当 sequential_image_generation 为 auto 时生效。仅
                        doubao-seedream-4.0 支持该参数。
                      properties:
                        max_images:
                          type: integer
                          description: 组图张数，取值范围1-15，默认15
                          default: 15
                async:
                  type: boolean
                  description: 是否异步生成，默认false，即同步等待图片生成成功后返回生成结果，如果异步需要通过调用图片获取接口获取生成结果
                  default: false
                retries:
                  type: integer
                  description: 自动重试次数，默认0，表示失败不重试
                  default: 0
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                required:
                  - created
                  - data
                properties:
                  task_id:
                    type: string
                    description: 图片生成任务ID
                    format: uuid
                  task_status:
                    type: string
                    description: 任务状态
                    enum:
                      - pending
                      - running
                      - succeed
                      - failed
                    example: running
                  created:
                    type: integer
                    description: 创建时间戳
                    format: unix-timestamp
                  data:
                    type: array
                    description: 生成的图片列表(仅在task_status=succeed时返回)
                    items:
                      type: object
                      required:
                        - url
                      properties:
                        url:
                          type: string
                          description: 图片URL
                          format: uri
                        b64_json:
                          type: string
                          description: 图片Base64编码数据
                          format: base64
                        revised_prompt:
                          type: string
                          description: 优化后的提示文本
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '413':
          description: 提示文本过长
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/StandardError'
components:
  responses:
    ValidationError:
      description: 参数验证错误
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: validation_error
              message:
                type: string
                example: 参数验证失败
              details:
                type: object
                additionalProperties:
                  type: string
                example:
                  field: 错误描述
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````