Skip to content

编辑图片 ​

POST /v1/images/edits

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

调用指南与限制

在线调试 ​

填写自己的 API Key 和请求参数后发送。生成请求会正常计费;Key 仅用于本次调试,不保存到浏览器。

application/json ​

参数类型必填默认值 / 可选值说明
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 字符。
sizestring否auto, 1024x1024, 1536x1024, 1024x1536, 1792x1024, 1024x1792, 2048x2048, 2048x1152, 1152x2048, 4096x4096, 4096x2304, 2304x4096分辨率档位与比例预设,实际像素以返回文件为准;必须与 resolution/aspect_ratio 一致。
resolutionstring否"1k"分辨率档位大小写不敏感,默认 1K,Lite 仅支持 1K。
aspect_ratiostring否1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9画面比例;图片默认 1:1,普通视频默认 16:9,short 固定 9:16。
qualitystring否auto, standard, hd质量随模型固定,只接受 auto 或该模型的 standard/hd,不支持 low/medium/high。
ninteger否1每次仅生成一个产物。
response_formatstring否url, b64_json普通 JSON 默认只返回 URL;默认 SSE 即使填写 url 也仍包含 Base64。
enhanceboolean否true提示词增强开关,默认 true。
streamboolean否falsetrue 返回等待心跳和最终图片事件。
partial_imagesinteger否0仅接受 0,暂不提供中途预览图。
deliverystring否"url"本站 URL 交付扩展,仅与 stream:true 同用,不能同时请求 b64_json;完成事件为 image_url.completed。
imagestring / array是—参考图片,JSON 使用 URL / data URL 或其数组;multipart 使用文件。

请求示例 ​

json
{
  "model": "gemini-3-pro-image",
  "prompt": "保持构图,将红色改为蓝色",
  "image": "https://example.com/reference.png",
  "stream": true,
  "partial_images": 0
}

multipart/form-data ​

Boolean form fields use true/false; n and partial_images are integer strings.

参数类型必填默认值 / 可选值说明
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-creativePublic product route. Lite accepts 1K only.
promptstring是—Non-blank prompt, at most 4096 Unicode characters.
sizestring否auto, 1024x1024, 1536x1024, 1024x1536, 1792x1024, 1024x1792, 2048x2048, 2048x1152, 1152x2048, 4096x4096, 4096x2304, 2304x4096Target tier and aspect ratio; actual output pixels depend on the model. Must agree with resolution/aspect_ratio.
resolutionstring否"1k"Case-insensitive tier; Lite only accepts 1k/1080p.
aspect_ratiostring否1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9
qualitystring否auto, standard, hdFixed per model; standard for Lite/Flash/2.5-fast/basic/fast, hd for Pro/2.5-pro/2/pro/creative. auto accepts the fixed tier.
ninteger否1
response_formatstring否url, b64_jsonNon-streaming response defaults to URL. Default SSE still embeds Base64, even when url is requested.
enhanceboolean否true
streamboolean否falseUse true for SSE heartbeats followed by a completion event. No partial previews.
partial_imagesinteger否0
deliverystring否"url"Site extension: stream=true only, incompatible with response_format=b64_json. Emits image_url.completed.
imagestring否—One reference file. For multiple files use repeated image[]. At most 20 MiB per file.
image[]array否—

响应 ​

StatusDescription
200JSON result, or SSE comment heartbeats then a completion/error event. HTTP 200 alone is not proof of generation success.
400Unsupported or conflicting parameters.
401Missing or invalid customer API Key.
413Request exceeds upload limits.
429Capacity or rate limit exceeded.
502Generation or image delivery failed; do not automatically resubmit.
507Insufficient capacity before submission.

application/json ​

json
{
  "created": 1790980000,
  "data": [
    {
      "url": "https://s3.yanxinyu.ggff.net/media_outputs/0123456789abcdef0123456789abcdef.png"
    }
  ]
}

text/event-stream ​

text
event: image_url.completed
data: {"type":"image_url.completed","operation":"edit","url":"https://s3.yanxinyu.ggff.net/media_outputs/0123456789abcdef0123456789abcdef.png","request_id":"REQUEST_ID","created_at":1790980000}

data: [DONE]