> ## Documentation Index
> Fetch the complete documentation index at: https://quwan-b8010aef.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# /v1/images/generations

> 根据文本提示创建图像。GPT Image 2.5 还支持在 JSON body 中传入 image（URL 或 Base64）进行图片编辑；需要 mask 时请使用 /v1/images/edits。



## OpenAPI

````yaml POST /v1/images/generations
openapi: 3.1.0
info:
  title: TokenOps AI API
  description: TokenOps AI API 提供了强大的AI服务能力，包括聊天对话、Gemini模型集成等功能。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.tokenops.ai
    description: TokenOps AI API 生产环境
security: []
paths:
  /v1/images/generations:
    post:
      tags:
        - Images
      summary: 创建图像
      description: >-
        根据文本提示创建图像。GPT Image 2.5 还支持在 JSON body 中传入 image（URL 或 Base64）进行图片编辑；需要
        mask 时请使用 /v1/images/edits。
      operationId: createImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateImageRequest'
            examples:
              basic_generation:
                summary: 基础图像生成
                description: 使用默认设置生成图像
                value:
                  model: dall-e-3
                  prompt: 一只可爱的小猫在花园里玩耍，阳光明媚，油画风格
                  'n': 1
                  size: 1024x1024
              high_quality_generation:
                summary: 高质量图像生成
                description: 生成高质量的详细图像
                value:
                  model: dall-e-3
                  prompt: 未来主义城市天际线，充满霓虹灯和飞行汽车，赛博朋克风格
                  'n': 1
                  size: 1792x1024
                  quality: hd
                  style: vivid
              multiple_images:
                summary: 批量图像生成
                description: 一次生成多张图像（仅DALL·E 2支持）
                value:
                  model: dall-e-2
                  prompt: 抽象艺术，充满活力的颜色和几何形状
                  'n': 4
                  size: 1024x1024
      responses:
        '200':
          description: 图像创建成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImagesResponse'
              examples:
                success_response:
                  summary: 图像生成成功
                  value:
                    created: 1589478378
                    data:
                      - url: >-
                          https://oaidalleapiprodscus.blob.core.windows.net/private/org-abc123/user-abc123/img-abc123.png
                    usage:
                      input_tokens: 15
                      input_tokens_details:
                        image_tokens: 0
                        text_tokens: 15
                      output_tokens: 196
                      output_tokens_details:
                        image_tokens: 196
                        text_tokens: 0
                      total_tokens: 211
                    generate_image: 1
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OpenAIAuth: []
components:
  schemas:
    CreateImageRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        prompt:
          type: string
          description: >-
            描述所需图像的文本提示。GPT Image 系列最大长度为 32000 个字符，dall-e-2 最大长度为 1000
            个字符，dall-e-3 最大长度为 4000 个字符
          maxLength: 32000
          example: 一只可爱的小猫在花园里玩耍，阳光明媚，油画风格
        background:
          anyOf:
            - type: string
              enum:
                - transparent
                - opaque
                - auto
            - type: 'null'
          description: >-
            设置生成图像背景。GPT Image 2.5 支持 transparent、opaque 或 auto；transparent 请配合
            png 输出格式
          default: auto
        model:
          anyOf:
            - type: string
              enum:
                - gpt-image-2.5-flare
                - gpt-image-2.5-sunburst
                - gpt-image-2-2026-04-21
                - gpt-image-2
                - gpt-image-1.5
                - gpt-image-1-mini
                - gpt-image-1
                - dall-e-2
                - dall-e-3
            - type: 'null'
          description: >-
            用于图像生成的模型。新接入推荐 gpt-image-2.5-flare（速度优先）或
            gpt-image-2.5-sunburst（编辑精度优先）
          example: gpt-image-2.5-flare
        moderation:
          anyOf:
            - type: string
              enum:
                - low
                - auto
            - type: 'null'
          description: 控制 gpt-image-1 生成图像的内容审核级别。必须是 low（较少限制的过滤）或 auto（默认值）
          default: auto
        'n':
          anyOf:
            - type: integer
              minimum: 1
              maximum: 10
            - type: 'null'
          description: 要生成的图像数量。必须在 1 到 10 之间。对于 dall-e-3，仅支持 n=1
          default: 1
          example: 1
        image:
          anyOf:
            - type: string
            - type: array
              items:
                type: string
              minItems: 1
              maxItems: 16
          description: >-
            平台扩展的图片编辑输入。可传单个字符串或最多 16 个字符串；每项支持 HTTP(S) URL、纯 Base64 或
            data:image/...;base64,... Data URI。传入后平台按图片编辑处理；需要 mask 时请改用
            /v1/images/edits
        output_compression:
          anyOf:
            - type: integer
              minimum: 0
              maximum: 100
            - type: 'null'
          description: 生成图像的压缩级别（0-100）。GPT Image 2.5 当前平台接入仅在 output_format=jpeg 时使用
          default: 100
        output_format:
          anyOf:
            - type: string
              enum:
                - png
                - jpeg
                - webp
            - type: 'null'
          description: 输出图片格式。GPT Image 2.5 当前平台接入支持 png 或 jpeg，暂不支持 webp
          default: png
        partial_images:
          type: integer
          minimum: 0
          maximum: 3
          description: >-
            要生成的部分图像数量。此参数用于返回部分图像的流式响应。值必须在 0 到 3 之间。当设置为 0
            时，响应将是在一个流式事件中发送的单个图像。注意，如果完整图像生成得更快，最终图像可能会在生成完整数量的部分图像之前发送
          default: 0
        quality:
          anyOf:
            - type: string
              enum:
                - auto
                - max
                - xhigh
                - high
                - medium
                - low
                - hd
                - standard
            - type: 'null'
          description: >-
            图像质量。GPT Image 2.5 支持 auto、low、medium、high、xhigh 和 max；dall-e-3 支持
            hd 和 standard；dall-e-2 仅支持 standard
          default: auto
        response_format:
          anyOf:
            - type: string
              enum:
                - url
                - b64_json
            - type: 'null'
          description: 平台响应格式。b64_json 直接返回图片 Base64；url 会由平台转存图片并返回签名 URL
          default: b64_json
        size:
          anyOf:
            - type: string
              enum:
                - 1024x1024
                - 1536x1024
                - 1024x1536
                - auto
                - 256x256
                - 512x512
                - 1792x1024
                - 1024x1792
            - type: 'null'
          description: >-
            生成图像的尺寸。gpt-image-1 必须是 1024x1024、1536x1024（横向）、1024x1536（纵向）或
            auto（默认值）之一。dall-e-2 必须是 256x256、512x512 或 1024x1024 之一。dall-e-3 必须是
            1024x1024、1792x1024 或 1024x1792 之一
          default: auto
        stream:
          anyOf:
            - type: boolean
            - type: 'null'
          description: 以流式模式生成图像。默认为 false。有关更多信息，请参阅图像生成指南。此参数仅支持 gpt-image-1
          default: false
        style:
          anyOf:
            - type: string
              enum:
                - vivid
                - natural
            - type: 'null'
          description: >-
            生成图像的风格。此参数仅支持 dall-e-3。必须是 vivid 或 natural 之一。vivid
            使模型倾向于生成超现实和戏剧性的图像。natural 使模型产生更自然、不太超现实的图像
          default: vivid
        user:
          type: string
          description: 代表您的最终用户的唯一标识符，可以帮助 OpenAI 监控和检测滥用
    ImagesResponse:
      type: object
      required:
        - created
        - data
      properties:
        background:
          type: string
          enum:
            - transparent
            - opaque
            - auto
          description: OpenAI 兼容保留字段，上游可能回传实际背景设置。当前 Azure / QNAIGC GPT Image 2.5 适配器不返回
        created:
          type: integer
          format: int64
          description: 图像创建时的 Unix 时间戳（以秒为单位）
          example: 1677649963
        data:
          type: array
          description: 生成的图像列表
          items:
            $ref: '#/components/schemas/Image'
        output_format:
          type: string
          enum:
            - png
            - webp
            - jpeg
          description: OpenAI 兼容保留字段，上游可能回传实际图片格式。当前 Azure / QNAIGC GPT Image 2.5 适配器不返回
        quality:
          type: string
          enum:
            - low
            - medium
            - high
            - xhigh
            - max
            - auto
          description: OpenAI 兼容保留字段，上游可能回传实际质量档位。当前 Azure / QNAIGC GPT Image 2.5 适配器不返回
        size:
          type: string
          description: >-
            OpenAI 兼容保留字段，上游可能回传实际图片尺寸，例如 1024x1024。当前 Azure / QNAIGC GPT Image
            2.5 适配器不返回
        usage:
          $ref: '#/components/schemas/ImageUsage'
          description: GPT Image 模型的 token 使用信息。仅在上游提供 usage 时出现
        generate_image:
          type: integer
          minimum: 0
          description: 平台扩展字段，本次成功生成的图片张数。它不是 token，不应加到 total_tokens
        generate_image_r1:
          type: integer
          minimum: 0
          description: 平台扩展字段，R1 分辨率计费档位的图片张数；仅部分按张或档位计费的模型返回
        generate_image_r2:
          type: integer
          minimum: 0
          description: 平台扩展字段，R2 分辨率计费档位的图片张数；仅部分按张或档位计费的模型返回
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Status'
          description: 错误信息
    Image:
      type: object
      properties:
        b64_json:
          type: string
          description: response_format=b64_json 或未传时返回的图片 Base64。与 url 按返回格式二选一
        revised_prompt:
          type: string
          description: 仅适用于 dall-e-3，用于生成图像的修订提示
          example: 一只可爱的小海獭仰躺在平静的蓝色水面上
        url:
          type: string
          format: uri
          description: response_format=url 时由平台转存并返回的签名 URL。与 b64_json 按返回格式二选一，URL 会过期
          example: https://model-static.skyengine.com.cn/<uid>/images/generated_xxx.png
    ImageUsage:
      type: object
      description: GPT Image 模型的 token 使用信息。字段缺失不等于数值为 0，以渠道实际上报为准
      properties:
        input_tokens:
          type: integer
          description: 输入提示中的 token 数量（图像和文本）
        input_tokens_details:
          $ref: '#/components/schemas/ImageInputTokensDetails'
          description: 图像生成的输入 token 详细信息
        output_tokens:
          type: integer
          description: 模型生成的输出 token 数量
        output_tokens_details:
          $ref: '#/components/schemas/ImageOutputTokensDetails'
          description: 图像生成的输出 token 详细信息
        total_tokens:
          type: integer
          description: 图像生成使用的 token 总数（图像和文本）
    Status:
      type: object
      properties:
        code:
          type: integer
          description: 错误代码
        message:
          type: string
          description: 错误消息
        details:
          type: array
          description: 错误详情
          items:
            type: object
            additionalProperties: true
    ImageInputTokensDetails:
      type: object
      description: 图像生成的输入 token 详细信息
      properties:
        image_tokens:
          type: integer
          description: 输入提示中的图像 token 数量
        text_tokens:
          type: integer
          description: 输入提示中的文本 token 数量
    ImageOutputTokensDetails:
      type: object
      description: 图像生成的输出 token 详细信息
      properties:
        image_tokens:
          type: integer
          description: 图片输出 token，按图片输出单价计费
        text_tokens:
          type: integer
          description: 输出文本 token；GPT Image 2.5 纯图片响应通常为 0 或省略，且不产生计费文本输出
  securitySchemes:
    OpenAIAuth:
      type: http
      scheme: bearer
      description: >-
        OpenAI API密钥认证。在 `Authorization` HTTP Header 中包含您的 API-Key，格式为 `Bearer
        {API_KEY}`

````

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