Skip to main content
POST
Image-to-Image Editing

编辑图像

使用带有文本说明的 Google Gemini 2.5 Flash Image 编辑现有图像。

端点

说明

使用带有文本说明的 Google Gemini 2.5 Flash Image 编辑现有图像。该端点专为图像到图像编辑而设计,其中:
  • 图像文件是必需的(与 /images/generations 不同,它是可选的)
  • 文本提示描述如何编辑或转换图像
  • 编辑后的图像以相同的质量和格式选项返回
所有提示和响应均通过 SMLTP 自动处理,以进行审核记录和合规性。

身份验证

必需:API 密钥

请求正文

该端点接受 multipart/form-data 格式。

参数

请求示例

卷曲

JavaScript/Node.js

###Python

回应

成功响应 (200)

响应字段

图像对象

元数据对象

错误响应

400 错误请求

401 未经授权

403 禁止

413 有效负载太大

500 内部服务器错误

503 服务不可用

注释

  • 支持的图像格式:JPEG、PNG、WEBP、GIF
  • 最大文件大小:每张图像 10MB
  • 此端点需要图像文件(与/images/generations不同)
  • 提示描述如何编辑或转换上传的图片
  • 所有请求均通过 SMLTP 处理,以确保安全性和合规性
  • 使用response_format: "b64_json"接收base64编码的图像数据而不是URL

授权

Authorization
string
header
必填

API key authentication using Bearer token format. Example: Authorization: Bearer sk-your-api-key-here

请求体

multipart/form-data
prompt
string
必填

Text instructions describing how to edit or transform the uploaded image

Required string length: 1 - 4000
示例:

"Add dramatic sunset colors to the sky and enhance the overall atmosphere"

image
file
必填

Image file to edit (required, JPEG, PNG, WEBP, or GIF, max 10MB)

smltp_policy
string
默认值:internal

SMLTP security policy to apply (e.g., 'internal', 'public', 'confidential', 'hipaa', 'gdpr')

示例:

"internal"

response_format
enum<string>
默认值:url

The format of the response images

可用选项:
url,
b64_json
示例:

"url"

响应

Image edited successfully

success
boolean
示例:

true

id
string

Unique request identifier

示例:

"f55bb4aa-ad9a-4b5a-9c94-511bf6fce806"

object
string
示例:

"image.edit"

created
integer

Unix timestamp of when the image was edited

示例:

1705312200

data
object[]

Array of edited images

metadata
object