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

# images.generate (OpenAI Compat)

> 与 `POST https://api.openai.com/v1/images/generations` 完全对齐；同步返回图片结果。

**扩展行为（官方 SDK 不会触发）**：当 JSON body 携带非空 `image`（URL / data URL / 纯 base64，单张或数组）时，自动改走图编辑（image_edit）流程，依然同步返回。



## OpenAPI

````yaml POST /openai/v1/images/generations
openapi: 3.0.0
info:
  title: Openai AI
  description: API documentation for Openai AI
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.mountsea.ai
    description: API Gateway
security: []
tags:
  - name: openai
    description: ''
  - name: openai-compat
    description: ''
paths:
  /openai/v1/images/generations:
    post:
      tags:
        - openai-compat
      summary: OpenAI images.generate 兼容（含 JSON 形态图编辑分流）
      description: >-
        与 `POST https://api.openai.com/v1/images/generations` 完全对齐；同步返回图片结果。


        **扩展行为（官方 SDK 不会触发）**：当 JSON body 携带非空 `image`（URL / data URL / 纯
        base64，单张或数组）时，自动改走图编辑（image_edit）流程，依然同步返回。
      operationId: OpenaiCompatController_generate
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenaiCompatImageGenerationDto'
      responses:
        '200':
          description: ''
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenaiImageResponseDto'
      security:
        - bearerAuth: []
components:
  schemas:
    OpenaiCompatImageGenerationDto:
      type: object
      properties:
        prompt:
          type: string
          description: 提示词（prompt）
        model:
          type: string
          enum:
            - gpt-image-2
          description: 模型
          default: gpt-image-2
        size:
          description: >-
            尺寸 / 分辨率。可传 ImageResolution 枚举值，或自定义 `WxH`（如
            `1280x960`）。自定义尺寸须满足以下约束：① 单边 ≤ 3840 px；② 宽、高均为 16 的倍数；③ 长边 : 短边 ≤
            3:1；④ 总像素 ∈ [655 360, 8 294 400]。不满足约束或渠道不支持自定义尺寸时请求将被拒绝。
          oneOf:
            - type: string
              enum:
                - auto
                - 1024x1024
                - 1536x1024
                - 1024x1536
                - 2048x2048
                - 2048x1152
                - 3840x2160
                - 2160x3840
            - type: string
              pattern: ^\d+x\d+$
              example: 1280x960
          default: 1024x1024
        'n':
          type: number
          minimum: 1
          maximum: 1
          description: 生成数量（当前仅支持 1）
          default: 1
        quality:
          enum:
            - auto
            - low
            - medium
            - high
            - standard
          type: string
          description: 质量等级
        background:
          enum:
            - transparent
            - opaque
            - auto
          type: string
          description: 背景透明度
        output_format:
          enum:
            - png
            - jpeg
            - webp
          type: string
          description: 输出文件格式
        output_compression:
          type: number
          minimum: 0
          maximum: 100
          description: JPEG / WebP 的压缩等级 0-100
        moderation:
          enum:
            - auto
            - low
          type: string
          description: 审核强度
        response_format:
          default: url
          enum:
            - url
            - b64_json
          type: string
          description: >-
            响应格式：`url` 返回图片自家 S3 URL；`b64_json` 返回 base64。本服务对所有渠道（含 OpenAI
            gpt-image-* 这种上游强制返 b64 的模型）都会按本字段严格输出，不会两个字段都返回。不传时按 `url` 处理。
        input_fidelity:
          enum:
            - high
            - low
          type: string
          description: 输入图保真度（gpt-image-2 新增，仅 edit 场景生效；generate 可忽略）
        user:
          type: string
          description: 终端用户标识（透传给上游供滥用监控）
        image:
          description: >-
            【本服务私有扩展，官方 SDK 不会传】输入图片（URL / data URL / 纯
            base64）。提供则同步触发图编辑（image_edit），不提供则保持原文生图行为。支持单张字符串或字符串数组。
          oneOf:
            - type: string
            - type: array
              items:
                type: string
        mask:
          type: string
          description: >-
            【本服务私有扩展，官方 SDK 不会传】mask 图片（URL / data URL / 纯 base64）；仅在同时提供
            `image` 时生效，透明区域将被重绘。
      required:
        - prompt
    OpenaiImageResponseDto:
      type: object
      properties:
        created:
          type: number
          description: 创建时间（unix 秒）
        data:
          description: 图片列表
          type: array
          items:
            $ref: '#/components/schemas/OpenaiImageItemDto'
        background:
          type: string
          enum:
            - transparent
            - opaque
        output_format:
          type: string
          enum:
            - png
            - webp
            - jpeg
        quality:
          type: string
          enum:
            - low
            - medium
            - high
        size:
          type: string
        usage:
          $ref: '#/components/schemas/OpenaiImageUsageDto'
      required:
        - created
        - data
    OpenaiImageItemDto:
      type: object
      properties:
        url:
          type: string
          description: 图片 URL（如果 response_format=url）
        b64_json:
          type: string
          description: base64 编码（如果 response_format=b64_json）
        revised_prompt:
          type: string
          description: 模型改写后的 prompt
    OpenaiImageUsageDto:
      type: object
      properties:
        input_tokens:
          type: number
          description: prompt 中所有 token 数（含图 + 文本）
        input_tokens_details:
          $ref: '#/components/schemas/OpenaiImageUsageDetailsDto'
        output_tokens:
          type: number
          description: 模型生成的 token 数
        total_tokens:
          type: number
          description: 总 token 数
    OpenaiImageUsageDetailsDto:
      type: object
      properties:
        image_tokens:
          type: number
        text_tokens:
          type: number
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````