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

# Generations

> OpenAI 兼容图像生成。

**路径：** `POST https://api.omniall.ai/v1/images/generations`

推荐通用生图入口。`image` 可为单个 URL/Base64 或 **字符串数组**（多图参考）；带参考图时部分渠道会自动改走 `/v1/images/edits` 或 Chat 桥接。

Gemini 原生亦可使用 `generateContent`。



## OpenAPI

````yaml zh-CN/openapi/xgapi-public.yaml POST /v1/images/generations
openapi: 3.0.3
info:
  title: Omniall AI 公开 API
  description: >-
    Omniall AI 公开 API。网站：https://omniall.ai — API 主机：https://api.omniall.ai —
    模型广场：https://omniall.ai/pricing
  version: 1.1.0
servers:
  - url: https://api.omniall.ai
    description: 生产环境
security:
  - bearerAuth: []
tags:
  - name: Models
    description: 列出当前 API Key 可用的模型。
  - name: ChatGPT Chat Completions
    x-group: ChatGPT
    description: OpenAI Chat Completions 对话接口（`POST /v1/chat/completions`）。
  - name: Responses
    description: OpenAI Responses 接口（`POST /v1/responses`）。
  - name: Claude
    description: Anthropic Messages 消息接口（`POST /v1/messages`）。
  - name: Gemini
    description: Google Gemini 原生 generateContent / streamGenerateContent。
  - name: Images
    description: 图像生成（OpenAI Images）、各厂商说明与 Midjourney 代理接口。
  - name: Video
    description: 异步视频任务。
  - name: Audio
    description: 语音合成及相关音频接口。
  - name: Rerank
    description: 文档重排序。
paths:
  /v1/images/generations:
    post:
      tags:
        - Images
      summary: 生成图像（generations）
      description: >-
        OpenAI 兼容图像生成。


        **路径：** `POST https://api.omniall.ai/v1/images/generations`


        推荐通用生图入口。`image` 可为单个 URL/Base64 或 **字符串数组**（多图参考）；带参考图时部分渠道会自动改走
        `/v1/images/edits` 或 Chat 桥接。


        Gemini 原生亦可使用 `generateContent`。
      operationId: createImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageRequest'
            examples:
              文生图:
                summary: 文生图
                value:
                  model: gpt-image-2
                  prompt: 一间采光柔和的安静工作室
                  'n': 1
                  size: 1024x1024
              多图参考:
                summary: 文生图 · 多图参考
                value:
                  model: gemini-3.1-flash-image-preview
                  prompt: 参考这几张图的风格与配色，生成一张统一品牌调性的产品海报
                  image:
                    - https://example.com/ref-style.jpg
                    - https://example.com/ref-layout.jpg
                  aspect_ratio: '16:9'
                  'n': 1
              图生图:
                summary: 图生图
                value:
                  model: gpt-image-2
                  prompt: 保持主体不变，把背景换成日落海边
                  image: https://example.com/reference.jpg
                  'n': 1
                  size: 1024x1024
      responses:
        '200':
          description: 生图结果
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
              example:
                created: 1710000000
                data:
                  - url: https://example.com/image.png
        '400':
          description: 请求无效
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '429':
          description: 速率限制
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '500':
          description: 上游或网关错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
components:
  schemas:
    ImageRequest:
      type: object
      required:
        - model
        - prompt
      description: >-
        OpenAI 兼容生图请求体（`POST /v1/images/generations`），对应网关
        `dto.ImageRequest`。适用于 GPT-Image、DALL·E、Flux、Grok
        Imagine、Seedream/即梦生图渠道，以及许多路由到该路径的 Gemini 图像模型。
      properties:
        model:
          type: string
          description: >-
            模型 ID，来自模型广场 / `GET
            /v1/models`。示例：`gpt-image-1`、`gpt-image-2`、`dall-e-3`、`flux-pro`、`grok-imagine-image`、`doubao-seedream-5-0-pro-260628`、`gemini-2.5-flash-image`。
          example: gpt-image-2
        prompt:
          type: string
          description: 图像描述文本。尽量写清主体、风格、光影与构图。
          example: 一间采光柔和的安静工作室
        'n':
          type: integer
          minimum: 1
          maximum: 128
          description: 生成张数。费用通常随 `n` 增加；部分模型只允许 `n=1`。
          default: 1
        size:
          type: string
          description: >-
            输出尺寸。可用像素字符串（如 `1024x1024`、`2048x1152`、`3840x2160`、`auto`），或配合
            `aspect_ratio` + `quality`/`image_size`（1K/2K/4K）。GPT-Image 系列常用比例见
            GPT-Image 文档中的比例表（3:1～1:3）。自定义尺寸建议：单边 ≤ 3840、宽高为 16 的倍数、长宽比 ≤ 3:1。
          example: 1024x1024
        quality:
          type: string
          description: >-
            质量档位。GPT-Image 常用：`low` / `medium` / `high` / `auto`；部分模型亦用 `1K` /
            `2K` / `4K`（与比例表对应）。
          example: high
        aspect_ratio:
          type: string
          description: >-
            画幅比例，如 `1:1`、`16:9`、`9:16`、`3:2`、`4:3`、`21:9`、`3:1`、`1:3` 等。与
            1K/2K/4K 档位组合时的像素尺寸见 GPT-Image 文档比例表。
          example: '1:1'
          enum:
            - '3:1'
            - '21:9'
            - '16:9'
            - '3:2'
            - '4:3'
            - '1:1'
            - '3:4'
            - '2:3'
            - '9:16'
            - '1:3'
            - '4:5'
            - '5:4'
        image_size:
          type: string
          description: 提供方特定的 image_size 字段（透传，不会改写成 resolution）。
        resolution:
          type: string
          description: 提供方特定的 resolution 字段（与 image_size 独立透传）。
        response_format:
          type: string
          enum:
            - url
            - b64_json
          description: 返回 URL 还是 Base64 JSON。支持时默认常为 `url`。
        style:
          description: 风格提示（如 DALL·E 的 `vivid` / `natural`）。
        background:
          description: 背景控制（如 GPT-Image 透明/不透明背景）。
        moderation:
          description: 审核级别（模型支持时）。
        output_format:
          description: 输出文件格式（如 `png`、`jpeg`、`webp`）。
        output_compression:
          description: 支持压缩格式时的压缩强度。
        partial_images:
          description: 渐进/分片出图选项（模型支持时）。
        stream:
          type: boolean
          description: 若上游支持流式出图（如部分 GPT-Image），可请求流式事件。
        watermark:
          type: boolean
          description: 是否请求水印（提供方支持该开关时）。
        image:
          oneOf:
            - type: string
              description: 单张参考图 URL、Base64 或 data URI。
            - type: array
              items:
                type: string
              description: 多张参考图 URL / Base64 数组（文生图多图参考或图生图）。
          description: |-
            可选参考图（图生图 / 多图参考）。可为：
            - 单个 URL、Base64 或 `data:image/...;base64,...`
            - **字符串数组**（多张参考图，网关会解析并转发）
            带参考图时更完整的编辑能力请用 `/v1/images/edits`。
        user:
          description: 终端用户标识（不透明），用于滥用监测。
        extra_fields:
          description: 预留扩展字段。有文档字段时请优先用顶层标准字段。
    ImageResponse:
      type: object
      description: OpenAI 兼容生图响应。
      properties:
        created:
          type: integer
          description: 完成时的 Unix 时间戳。
        data:
          type: array
          description: 生成的图像列表。
          items:
            type: object
            properties:
              url:
                type: string
                description: 图像临时 HTTPS 链接（请及时转存，可能过期）。
              b64_json:
                type: string
                description: 当 `response_format=b64_json` 时的 Base64 图像数据。
              revised_prompt:
                type: string
                description: 模型改写后的提示词（如 DALL·E），若有。
    OpenAIErrorResponse:
      type: object
      description: 鉴权或请求失败时返回的 OpenAI 风格错误包络。
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              description: 人类可读错误信息。网关可能附加 request id 便于排查。
            type:
              type: string
              description: 错误类型，常见为 `new_api_error`。
              example: new_api_error
            code:
              type: string
              description: 可选机器可读错误码（如 `access_denied`），可能为空字符串。
          description: 错误对象。
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: '使用来自 https://omniall.ai/dashboard 的 Authorization: Bearer sk-...'

````

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