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

# OpenAI 图像编辑

> 接口说明：OpenAI Images API `/v1/images/edits` 的兼容端点（图生图）。请求、响应与错误格式完全遵循 OpenAI 规范：支持 `application/json` 与 `multipart/form-data`（可直接上传图片与遮罩文件），返回 OpenAI 原始 `ImagesResponse`，不使用 AiToEarn 通用响应包裹；图片链接为上游原始返回，不做转存。鉴权使用 `Authorization: Bearer <API Key>`（OpenAI SDK 默认携带），已有 OpenAI SDK 或生态工具只需替换 baseURL 与 API Key 即可接入，按 AiToEarn 积分计费。

模型取值来自[「图像编辑模型」](/api-reference/ai-服务图像生成/图像编辑模型)接口返回的 `data[n].name`。如需 AiToEarn 通用响应格式（`code === 0`）与转存后的稳定图片链接，请改用[「编辑图像」](/api-reference/ai-服务图像生成/编辑图像)接口。



## OpenAPI

````yaml /openapi/zh/aitoearn.openapi.json post /api/ai/images/edits
openapi: 3.0.1
info:
  title: AiToEarn 开放平台 API
  description: AiToEarn 开放平台 API，支持在中国站与国际站之间切换调试。业务是否成功以响应体 code === 0 为准。
  version: 1.0.0
  contact: {}
servers:
  - url: https://aitoearn.cn
    description: 中国站
  - url: https://aitoearn.ai
    description: 国际站
security: []
tags:
  - name: AI 服务
  - name: AI 服务/视频生成
  - name: AI 服务/图像生成
  - name: 渠道管理
  - name: 渠道管理/账号
  - name: 渠道管理/内容发布
  - name: 渠道管理/平台
  - name: 渠道管理/作品
  - name: 渠道管理/账号分组
  - name: 渠道管理/授权
  - name: 资源管理
  - name: AI 服务/大语言模型
paths:
  /api/ai/images/edits:
    post:
      tags:
        - AI 服务/图像生成
      summary: OpenAI 图像编辑
      description: >-
        接口说明：OpenAI Images API `/v1/images/edits` 的兼容端点（图生图）。请求、响应与错误格式完全遵循
        OpenAI 规范：支持 `application/json` 与 `multipart/form-data`（可直接上传图片与遮罩文件），返回
        OpenAI 原始 `ImagesResponse`，不使用 AiToEarn 通用响应包裹；图片链接为上游原始返回，不做转存。鉴权使用
        `Authorization: Bearer <API Key>`（OpenAI SDK 默认携带），已有 OpenAI SDK
        或生态工具只需替换 baseURL 与 API Key 即可接入，按 AiToEarn 积分计费。


        模型取值来自[「图像编辑模型」](/api-reference/ai-服务图像生成/图像编辑模型)接口返回的 `data[n].name`。如需
        AiToEarn 通用响应格式（`code ===
        0`）与转存后的稳定图片链接，请改用[「编辑图像」](/api-reference/ai-服务图像生成/编辑图像)接口。
      operationId: RelayController_imagesEdits
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RelayImageEditDto'
            examples: {}
        required: true
      responses:
        '200':
          description: 第三方协议原生响应或 SSE 数据。不使用 AiToEarn 通用响应包裹。
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
                description: 第三方协议原生响应，不使用 AiToEarn 通用响应包裹。
              examples:
                success:
                  summary: 第三方协议原生成功响应
                  value:
                    id: RelayController_imagesEdits_example
                    object: response
            text/event-stream:
              schema:
                type: string
                description: SSE 流式响应。
      deprecated: false
      security:
        - apikey-header-Authorization: []
components:
  schemas:
    RelayImageEditDto:
      type: object
      properties:
        model:
          type: string
          description: >-
            图像编辑模型名称。先调用[「图像编辑模型」](/api-reference/ai-服务图像生成/图像编辑模型)接口（`GET
            /api/ai/models/image/edit`），传入其返回的
            `data[n].name`；各模型支持的尺寸、最大输入图片数与价格以该接口返回为准。
        image:
          anyOf:
            - type: string
            - type: array
              items:
                type: string
          description: 图片列表
        prompt:
          type: string
          description: 提示词
        mask:
          type: string
          description: >-
            遮罩图片 URL，用于**局部重绘**（可选）。需为与 `image` 尺寸一致的 PNG 图片：完全透明（alpha 为
            0）的区域表示需要按提示词重绘的部分，不透明区域保持原图不变。不传时对整张图片进行编辑。
        'n':
          type: integer
          minimum: 1
          maximum: 9007199254740991
          description: 生成数量
        size:
          type: string
          description: >-
            图像尺寸。可选值随模型而不同，以[「图像编辑模型」](/api-reference/ai-服务图像生成/图像编辑模型)接口返回的
            `data[n].sizes` 为准；不同尺寸的价格不同，见 `data[n].pricing`。
        response_format:
          type: string
          enum:
            - url
            - b64_json
          description: 返回格式
      required:
        - model
        - image
        - prompt
      additionalProperties: true
  securitySchemes:
    apikey-header-Authorization:
      type: apiKey
      in: header
      name: Authorization
      description: OpenAI 兼容接口使用，示例：Bearer <token>。

````