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

# 生成图像

> OpenAI 兼容的图片生成接口。实际可用模型以 `/v1/models` 和控制台模型定价页为准。



## OpenAPI

````yaml /openapi/relay.json post /v1/images/generations
openapi: 3.0.1
info:
  title: AIOHub API
  description: AIOHub 公开 API
  version: 1.0.0
servers:
  - url: https://api.aiohub.org
security:
  - BearerAuth: []
tags:
  - name: 获取模型列表
  - name: OpenAI Chat
  - name: OpenAI Responses
  - name: 图片生成
  - name: OpenAI 图像
  - name: 视频生成
  - name: Claude Messages
  - name: Gemini API
  - name: OpenAI Embeddings
  - name: 文本补全
  - name: OpenAI 音频
  - name: Realtime API
paths:
  /v1/images/generations:
    post:
      tags:
        - OpenAI 图像
      summary: 生成图像
      description: OpenAI 兼容的图片生成接口。实际可用模型以 `/v1/models` 和控制台模型定价页为准。
      operationId: createImage
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            example:
              model: gpt-image-2
              prompt: A clean product photo of a ceramic coffee mug on a wooden desk
              size: 1024x1024
              'n': 1
      responses:
        '200':
          description: 成功生成图像
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
          headers: {}
      deprecated: false
      security:
        - BearerAuth: []
components:
  schemas:
    ImageGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          example: gpt-image-2
        prompt:
          type: string
          description: 图像描述
        'n':
          type: integer
          minimum: 1
          maximum: 10
          default: 1
        size:
          type: string
          description: 图片尺寸。不同模型支持的尺寸不同，例如 `1024x1024`、`1024x1792`、`1792x1024`。
          example: 1024x1024
        quality:
          type: string
          description: 图片质量。不同模型支持的取值不同，例如 `auto`、`standard`、`hd`、`high`。
          example: auto
        style:
          type: string
          enum:
            - vivid
            - natural
          default: vivid
        response_format:
          type: string
          enum:
            - url
            - b64_json
          default: url
        stream:
          type: boolean
          description: 是否流式返回，取决于所选模型是否支持。
        background:
          description: 背景设置，取决于所选模型是否支持。
        output_format:
          description: 输出格式，取决于所选模型是否支持。
        partial_images:
          description: 部分图片返回设置，取决于所选模型是否支持。
        user:
          type: string
    ImageResponse:
      type: object
      properties:
        created:
          type: integer
        data:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
              b64_json:
                type: string
              revised_prompt:
                type: string
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key (sk-xxx)

````