> ## 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.

# 编辑图像

> OpenAI 兼容图像编辑 / 局部重绘。

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

支持 **`application/json`**（`image`/`mask` 为 URL 或 Base64）与 **`multipart/form-data`**（上传文件）。多图时 JSON 用 `image` 字符串数组；表单用多个 `image[]` 文件字段。

提供 `prompt` 描述修改方式；可选 `mask` 指定可编辑区域。



## OpenAPI

````yaml zh-CN/openapi/xgapi-public.yaml POST /v1/images/edits
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/edits:
    post:
      tags:
        - Images
      summary: 编辑图像
      description: >-
        OpenAI 兼容图像编辑 / 局部重绘。


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


        支持 **`application/json`**（`image`/`mask` 为 URL 或 Base64）与
        **`multipart/form-data`**（上传文件）。多图时 JSON 用 `image` 字符串数组；表单用多个 `image[]`
        文件字段。


        提供 `prompt` 描述修改方式；可选 `mask` 指定可编辑区域。
      operationId: createImageEdit
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageEditRequest'
            examples:
              图生图:
                summary: 图生图（JSON）
                value:
                  model: gpt-image-1
                  prompt: 把背景替换成干净的白色影棚背景
                  image: https://example.com/product.png
                  'n': 1
              多图参考:
                summary: 图生图 · 多图参考（JSON）
                value:
                  model: gpt-image-1
                  prompt: 融合两张参考图的构图与主体，输出一张商业广告图
                  image:
                    - https://example.com/ref-a.png
                    - https://example.com/ref-b.png
                  'n': 1
          multipart/form-data:
            schema:
              type: object
              required:
                - model
                - prompt
                - image
              description: >-
                OpenAI 兼容 `multipart/form-data`
                编辑请求。文本字段与文件字段同表提交；网关会将上传的图片转发上游。
              properties:
                model:
                  type: string
                  description: 支持编辑的模型 ID。
                  example: gpt-image-1
                prompt:
                  type: string
                  description: 描述如何修改图像的文本指令。
                  example: 把背景替换成干净的白色影棚背景
                image:
                  type: string
                  format: binary
                  description: >-
                    源图文件。单张时字段名为 `image`；多张参考图时使用多个 `image[]` 或
                    `image[0]`、`image[1]` 文件字段（与 OpenAI 适配器一致）。
                mask:
                  type: string
                  format: binary
                  description: 可选蒙版 PNG。透明区域表示允许编辑的区域。
                'n':
                  type: string
                  description: 生成张数（表单中为字符串，如 `1`）。
                  example: '1'
                size:
                  type: string
                  description: 输出尺寸（若模型支持）。
                quality:
                  type: string
                  description: 质量档位（若模型支持）。
                response_format:
                  type: string
                  enum:
                    - url
                    - b64_json
                  description: 返回格式。
            examples:
              表单图生图:
                summary: 图生图（multipart 表单）
                value:
                  model: gpt-image-1
                  prompt: 把背景替换成干净的白色影棚背景
                  'n': '1'
      responses:
        '200':
          description: 编辑结果
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
        '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:
    ImageEditRequest:
      type: object
      required:
        - model
        - prompt
      description: OpenAI 兼容图像编辑（`POST /v1/images/edits`）。支持 JSON 与 multipart/form-data。
      properties:
        model:
          type: string
          description: 支持编辑的模型 ID（如 `gpt-image-1`、`dall-e-2`、部分 Gemini/Qwen 编辑模型）。
          example: gpt-image-1
        prompt:
          type: string
          description: 描述如何编辑图像的指令。
          example: 把天空替换成晚霞
        image:
          oneOf:
            - type: string
            - type: array
              items:
                type: string
          description: >-
            源图。JSON：URL / Base64 / **字符串数组**（多图）。multipart：文件字段 `image`（单张）或重复
            `image[]` / `image[n]`（多张）。
        mask:
          oneOf:
            - type: string
              description: 蒙版 URL 或 Base64。
            - type: string
              format: binary
              description: multipart 表单中的 `mask` 文件。
          description: 可选蒙版。JSON 为 URL/Base64；multipart 为 `mask` 文件字段（PNG，透明区域可编辑）。
        'n':
          type: integer
          description: 返回的编辑结果张数。
          default: 1
        size:
          type: string
          description: 输出尺寸（若支持）。
        quality:
          type: string
          description: 质量档位（若支持）。
        response_format:
          type: string
          enum:
            - url
            - b64_json
        user:
          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.