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

# /v1/images/generations

> 根据给定的文本提示创建图像。支持多种模型包括gpt-image-1和DALL·E 3，提供不同的质量、尺寸和风格选项。



## 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://model-api.skyengine.com.cn
    description: TokenOps AI API 生产环境
security: []
paths:
  /v1/images/generations:
    post:
      tags:
        - Images
      summary: 创建图像
      description: 根据给定的文本提示创建图像。支持多种模型包括gpt-image-1和DALL·E 3，提供不同的质量、尺寸和风格选项。
      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
                    background: auto
                    output_format: png
                    quality: high
                    size: 1024x1024
                    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: 1
                      total_tokens: 16
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - OpenAIAuth: []
components:
  schemas:
    CreateImageRequest:
      type: object
      required:
        - prompt
      properties:
        prompt:
          type: string
          description: >-
            描述所需图像的文本提示。gpt-image-1 最大长度为 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-1。必须是 transparent、opaque 或
            auto（默认值）之一。当使用 auto 时，模型将自动确定图像的最佳背景。如果是
            transparent，输出格式需要支持透明度，因此应设置为 png（默认值）或 webp
          default: auto
        model:
          anyOf:
            - type: string
              enum:
                - dall-e-2
                - dall-e-3
                - gpt-image-1
            - type: 'null'
          description: 用于图像生成的模型。dall-e-2、dall-e-3 或 gpt-image-1 之一。
          example: gpt-image-1
        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
        output_compression:
          anyOf:
            - type: integer
              minimum: 0
              maximum: 100
            - type: 'null'
          description: 生成图像的压缩级别（0-100%）。此参数仅支持使用 webp 或 jpeg 输出格式的 gpt-image-1，默认为 100
          default: 100
        output_format:
          anyOf:
            - type: string
              enum:
                - png
                - jpeg
                - webp
            - type: 'null'
          description: 生成图像返回的格式。此参数仅支持 gpt-image-1。必须是 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
                - high
                - medium
                - low
                - hd
                - standard
            - type: 'null'
          description: >-
            将要生成的图像质量。auto（默认值）将自动为给定模型选择最佳质量。gpt-image-1 支持 high、medium 和
            low。dall-e-3 支持 hd 和 standard。dall-e-2 仅支持 standard
          default: auto
        response_format:
          anyOf:
            - type: string
              enum:
                - url
                - b64_json
            - type: 'null'
          description: >-
            dall-e-2 和 dall-e-3 生成图像的返回格式。必须是 url 或 b64_json 之一。URL 仅在生成图像后的 60
            分钟内有效。此参数不支持 gpt-image-1，后者始终返回 base64 编码的图像
          default: url
        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
          description: 用于图像生成的背景参数。transparent 或 opaque
        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: 图像生成的输出格式。png、webp 或 jpeg
        quality:
          type: string
          enum:
            - low
            - medium
            - high
          description: 生成图像的质量。low、medium 或 high
        size:
          type: string
          enum:
            - 1024x1024
            - 1024x1536
            - 1536x1024
          description: 生成图像的尺寸。1024x1024、1024x1536 或 1536x1024
        usage:
          $ref: '#/components/schemas/ImageUsage'
          description: 仅适用于 gpt-image-1，图像生成的 token 使用信息
    ErrorResponse:
      type: object
      properties:
        error:
          $ref: '#/components/schemas/Status'
          description: 错误信息
    Image:
      type: object
      properties:
        b64_json:
          type: string
          description: >-
            生成图像的 base64 编码 JSON。gpt-image-1 的默认值，仅当 dall-e-2 和 dall-e-3 的
            response_format 设置为 b64_json 时才存在
        revised_prompt:
          type: string
          description: 仅适用于 dall-e-3，用于生成图像的修订提示
          example: 一只可爱的小海獭仰躺在平静的蓝色水面上
        url:
          type: string
          description: >-
            使用 dall-e-2 或 dall-e-3 时，如果 response_format 设置为 url（默认值），则为生成图像的
            URL。gpt-image-1 不支持
          example: >-
            https://oaidalleapiprodscus.blob.core.windows.net/private/org-abc123/user-abc123/img-abc123.png
    ImageUsage:
      type: object
      description: 仅适用于 gpt-image-1，图像生成的 token 使用信息
      properties:
        input_tokens:
          type: integer
          description: 输入提示中的 token 数量（图像和文本）
        input_tokens_details:
          $ref: '#/components/schemas/ImageInputTokensDetails'
          description: 图像生成的输入 token 详细信息
        output_tokens:
          type: integer
          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 数量
  securitySchemes:
    OpenAIAuth:
      type: http
      scheme: bearer
      description: >-
        OpenAI API密钥认证。在 `Authorization` HTTP Header 中包含您的 API-Key，格式为 `Bearer
        {API_KEY}`

````