Skip to content

编辑图片 · image-fast ​

POST/v1/images/edits

基于参考图编辑,不支持遮罩。JSON 使用 image;multipart 使用 image 或重复 image[] 文件字段,单文件最多 20 MiB。

同步 · 直接返回结果 · 本次请求等待处理并直接返回 JSON 或文件。

鉴权

使用客户 API Key。 获取与配置 →

Authorization: Bearer YOUR_API_KEY

选择模型

查看该模型的能力与限制 →

请求参数

组合与模型限制
  • 当 提供 delivery: 必须提供 stream;stream 必须为 true;response_format 必须为 "url".
  • 当 model = "gemini-3.1-flash-lite-image": resolution 须匹配 ^(1[kK]|1080[pP])$;size 仅接受 "auto", "1024x1024", "1536x1024", "1024x1536", "1792x1024", "1024x1792".
  • 当 model 为 "gemini-3-pro-image", "gpt-image-2.5-pro", "gpt-image-2", "image-pro", "image-creative": quality 仅接受 "auto", "hd";否则 quality 仅接受 "auto", "standard".
  • 当 提供 progress,且 progress = true: 必须提供 stream;stream 必须为 true.
modelstring必填

本站公开调用名称,具体能力与限制见指南。

"gemini-3.1-flash-lite-image""gemini-3.1-flash-image""gemini-3-pro-image""gpt-image-2.5-fast""gpt-image-2.5-pro""gpt-image-2""image-basic""image-fast""image-pro""image-creative"
promptstring必填

必填,不能为空白,最多 4096 个 Unicode 字符。

最少字符: 1 · 最多字符: 4096 · 匹配规则: "\\S"

sizestring

分辨率档位与比例预设,实际像素以返回文件为准;必须与 resolution/aspect_ratio 一致。

"auto""1024x1024""1536x1024""1024x1536""1792x1024""1024x1792""2048x2048""2048x1152""1152x2048""4096x4096""4096x2304""2304x4096"
resolutionstring

分辨率档位大小写不敏感,默认 1K,Lite 仅支持 1K。

匹配规则: "^(1[kK]|1080[pP]|2[kK]|4[kK])$" · 默认: "1k"

aspect_ratiostring

画面比例;图片默认 1:1,普通视频默认 16:9,short 固定 9:16。

"1:1""16:9""9:16""4:3""3:4""3:2""2:3""21:9"

默认: "1:1"

qualitystring

质量随模型固定,只接受 auto 或该模型的 standard/hd,不支持 low/medium/high。

"auto""standard""hd"
ninteger

每次仅生成一个产物。

固定值: 1 · 默认: 1

response_formatstring

普通 JSON 默认只返回 URL;默认 SSE 即使填写 url 也仍包含 Base64。

"url""b64_json"

默认: "url"

enhanceboolean

提示词增强开关,默认 true。

默认: true

streamboolean

true 返回等待心跳和最终图片事件。

默认: false

partial_imagesinteger

仅接受 0,暂不提供中途预览图。

固定值: 0

deliverystring

本站 URL 交付扩展,仅与 stream:true 同用,不能同时请求 b64_json;完成事件为 image_url.completed。

固定值: "url"

imageoneOf必填

参考图片,JSON 使用 URL / data URL 或其数组;multipart 使用文件。

展开结构
任选一种结构 · 1

string — HTTP(S) 图片地址或 Base64 图片 Data URL。

匹配规则: "^(https?://|data:image/)"

任选一种结构 · 2

array

最少条数: 1

progressboolean

本站扩展,进度事件来自同一个原始任务,必须开启 stream=true;源进度百分比缺失时为 null。

默认: false

同时满足的规则 · 1
组合与模型限制
  • 当 提供 delivery: 必须提供 stream;stream 必须为 true;response_format 必须为 "url".

object

条件约束(JSON Schema)
{
  "if": {
    "required": [
      "delivery"
    ]
  },
  "then": {
    "required": [
      "stream"
    ],
    "properties": {
      "stream": {
        "const": true,
        "type": "boolean"
      },
      "response_format": {
        "const": "url",
        "type": "string"
      }
    }
  }
}
同时满足的规则 · 2
组合与模型限制
  • 当 model = "gemini-3.1-flash-lite-image": resolution 须匹配 ^(1[kK]|1080[pP])$;size 仅接受 "auto", "1024x1024", "1536x1024", "1024x1536", "1792x1024", "1024x1792".

object

条件约束(JSON Schema)
{
  "if": {
    "properties": {
      "model": {
        "const": "gemini-3.1-flash-lite-image",
        "type": "string"
      }
    }
  },
  "then": {
    "properties": {
      "resolution": {
        "pattern": "^(1[kK]|1080[pP])$"
      },
      "size": {
        "enum": [
          "auto",
          "1024x1024",
          "1536x1024",
          "1024x1536",
          "1792x1024",
          "1024x1792"
        ],
        "type": "string"
      }
    }
  }
}
同时满足的规则 · 3
组合与模型限制
  • 当 model 为 "gemini-3-pro-image", "gpt-image-2.5-pro", "gpt-image-2", "image-pro", "image-creative": quality 仅接受 "auto", "hd";否则 quality 仅接受 "auto", "standard".

object

条件约束(JSON Schema)
{
  "if": {
    "properties": {
      "model": {
        "enum": [
          "gemini-3-pro-image",
          "gpt-image-2.5-pro",
          "gpt-image-2",
          "image-pro",
          "image-creative"
        ],
        "type": "string"
      }
    }
  },
  "then": {
    "properties": {
      "quality": {
        "enum": [
          "auto",
          "hd"
        ],
        "type": "string"
      }
    }
  },
  "else": {
    "properties": {
      "quality": {
        "enum": [
          "auto",
          "standard"
        ],
        "type": "string"
      }
    }
  }
}
同时满足的规则 · 4
组合与模型限制
  • 当 提供 progress,且 progress = true: 必须提供 stream;stream 必须为 true.

object

条件约束(JSON Schema)
{
  "if": {
    "required": [
      "progress"
    ],
    "properties": {
      "progress": {
        "const": true
      }
    }
  },
  "then": {
    "required": [
      "stream"
    ],
    "properties": {
      "stream": {
        "const": true,
        "type": "boolean"
      }
    }
  }
}

不接受未列出的字段。

响应

返回 JSON 结果,或 SSE 心跳、可选进度事件(progress=true),随后返回完成或错误事件。只有完成事件才能确认交付。

响应头

X-Image-Request-Idstring

用于查单的请求 ID,可能与最终 New API request_id 不同。

Content-Type application/json

createdinteger必填
dataarray必填

最少条数: 1 · 最多条数: 1

展开结构
urlstring必填

格式: "uri"

b64_jsonstring

在成功的普通响应中,仅在显式请求时返回。