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

# 生成图片

> 同步生成或编辑图片，请求在图片生成完成后返回。




## OpenAPI

````yaml POST /v1/images/generations
openapi: 3.1.0
info:
  title: MindSee OpenAPI
  version: 1.0.0
  description: 面向持有访问令牌的外部程序客户端的 MindSee 接口。
servers:
  - url: https://openapi.mindsee.app
    description: 生产环境
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      tags:
        - 图片
      summary: 生成图片
      description: |
        同步生成或编辑图片，请求在图片生成完成后返回。
      operationId: createImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              textToImage:
                summary: 文生图
                value:
                  model: gpt-image-2
                  prompt: 一只橘猫坐在窗台上看雨，水彩风格
                  resolution: 1K
                  ratio: '3:4'
              imageEditing:
                summary: 图片编辑
                value:
                  model: gpt-image-2
                  prompt: 把背景换成海边日落
                  image:
                    - data:image/png;base64,iVBORw0KGgo...
                  resolution: auto
                  ratio: auto
      responses:
        '200':
          description: 生成成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
              example:
                created: 1767225600
                data:
                  - b64_json: iVBORw0KGgoAAAANSUhEUgAA...
        '400':
          description: 生成任务执行失败，积分已退还
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: 缺少访问令牌、格式不是 Bearer，或令牌无效
          headers:
            WWW-Authenticate:
              description: 固定为 `Bearer realm="MindSee"`
              schema:
                type: string
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: 您尚未登录，请先登录后重试
                code: ''
                detail: null
        '402':
          description: 积分不足
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: 该功能需订阅或支付费用
                code: INSUFFICIENT_CREDITS
                detail: null
        '422':
          description: 请求参数不合法，例如模型不存在、尺寸或质量不受该模型支持、图片无法解析或超过 20MB
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                message: 当前模型不支持所选尺寸
                code: ''
                detail: null
        '500':
          description: 服务内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ImageGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: 模型 ID，各模型支持的参数取值见指南中对应的模型页面。
          enum:
            - gpt-image-2
            - gpt-image-2.5-flare
            - gpt-image-2.5-sunburst
            - mindsee-image-2.5-flash
        prompt:
          type: string
          description: 生图提示词。
          minLength: 1
          maxLength: 32000
        image:
          type: array
          description: >-
            待编辑图片的 base64，必须带 data URL 前缀，如 `data:image/png;base64,`。最多 8
            张，单张解码后不超过 20MB。传入的图片会保存到你的素材库。
          maxItems: 8
          items:
            type: string
        resolution:
          type: string
          description: >-
            输出分辨率档位。GPT 系列必填，可选 `auto`、`1K`；`mindsee-image-2.5-flash` 必填，可选
            `1K`~`4K`。
          enum:
            - auto
            - 1K
            - 2K
            - 3K
            - 4K
        ratio:
          type: string
          description: >-
            输出宽高比。GPT 系列必填，`resolution=auto` 时只能为
            `auto`，其他档位必须是具体比例；`mindsee-image-2.5-flash` 选填，默认 `1:1`。
          enum:
            - auto
            - '1:1'
            - '3:4'
            - '4:3'
            - '16:9'
            - '9:16'
            - '2:3'
            - '3:2'
            - '21:9'
        quality:
          type: string
          description: >-
            输出质量，仅 GPT 系列支持，默认 `auto`。`xhigh`、`max` 仅
            `gpt-image-2.5-flare`、`gpt-image-2.5-sunburst` 支持。
          enum:
            - auto
            - low
            - medium
            - high
            - xhigh
            - max
        output_format:
          type: string
          description: 输出格式，仅 GPT 系列支持，默认 `png`。
          enum:
            - png
            - jpeg
            - webp
        background:
          type: string
          description: >-
            背景模式，仅 GPT 系列支持，默认 `auto`。`transparent` 需要 `output_format` 为 `png` 或
            `webp`。
          enum:
            - auto
            - opaque
            - transparent
    ImageGenerationResponse:
      type: object
      required:
        - created
        - data
      properties:
        created:
          type: integer
          format: int64
          description: 生成完成时间，Unix 秒。
        data:
          type: array
          description: 生成结果，固定只有一项。
          items:
            type: object
            required:
              - b64_json
            properties:
              b64_json:
                type: string
                description: 结果图片的 base64。
    ErrorResponse:
      type: object
      required:
        - message
        - code
        - detail
      properties:
        message:
          type: string
          description: 可读的错误信息，语言跟随 `Accept-Language` 请求头。
        code:
          type: string
          description: 机器可识别的错误码，多数错误为空字符串。
        detail:
          description: 附加信息，多数错误为 null。
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 在 MindSee 控制台的用户菜单「令牌」中创建访问令牌。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.