Skip to main content
POST
Image-to-Image Editing

Edit Images

Edit existing images using Google Gemini 2.5 Flash Image with text instructions.

Endpoint

Description

Edit existing images using Google Gemini 2.5 Flash Image with text instructions. This endpoint is specifically designed for image-to-image editing where:
  • An image file is required (unlike /images/generations where it’s optional)
  • A text prompt describes how to edit or transform the image
  • The edited image is returned with the same quality and format options
All prompts and responses are automatically processed through SMLTP for audit logging and compliance.

Authentication

Required: API Key

Request Body

This endpoint accepts multipart/form-data format.

Parameters

Request Examples

cURL

JavaScript/Node.js

Python

Response

Success Response (200)

Response Fields

Image Object

Metadata Object

Error Responses

400 Bad Request

401 Unauthorized

403 Forbidden

413 Payload Too Large

500 Internal Server Error

503 Service Unavailable

Notes

  • Supported image formats: JPEG, PNG, WEBP, GIF
  • Maximum file size: 10MB per image
  • The image file is required for this endpoint (unlike /images/generations)
  • The prompt describes how to edit or transform the uploaded image
  • All requests are processed through SMLTP for security and compliance
  • Use response_format: "b64_json" to receive base64-encoded image data instead of URLs

授权

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