Gemini supports improved editing of images and multi-turn editing, and supports updated safety filters that provide a more flexible and less restrictive experience.
The following Gemini models support image editing:
For more information about model capabilities, see Gemini models.
Edit an image
Console
To edit images, do the following:
- Open Vertex AI Studio > Create prompt.
- Click Switch model and select one of the displayed models.
- In the Outputs panel, select Image and text from the drop-down menu.
- Click Insert media () and select a source from the menu, then follow the dialog's instructions.
- Write what edits you want to make to the image in the Write a prompt text area.
- Click the Prompt () button.
Gemini generates an edited version of the provided image based on your description. This process takes a few seconds, but can be comparatively slower depending on capacity.
Python
Install
pip install --upgrade google-genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
Java
Learn how to install or update the Java.
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
Go
Learn how to install or update the Go.
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
Node.js
Install
npm install @google/genai
To learn more, see the SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
# Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values # with appropriate values for your project. export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT export GOOGLE_CLOUD_LOCATION=global export GOOGLE_GENAI_USE_VERTEXAI=True
REST
Run the following command in the terminal to create or overwrite this file in the current directory:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
https://${API_ENDPOINT}:generateContent \
-d '{
"contents": {
"role": "USER",
"parts": [
{"fileData": {
"mimeType": "image/jpg",
"fileUri": "FILE_NAME"
}
},
{"text": "Convert this photo to black and white, in a cartoonish style."},
]
},
"generationConfig": {
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "4K",
"responseModalities": ["TEXT", "IMAGE"],
"imageOutputOptions": {
"mimeType": "image/png"
},
"personGeneration": "allow_all"
},
},
"safetySettings": {
"method": "PROBABILITY",
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
}' 2>/dev/null >response.json
For more information about model capabilities, including supported aspect ratios and output resolutions, see Gemini models.
Gemini generates an image based on your description. This process takes a few seconds, but can be comparatively slower depending on capacity.
Multi-turn image editing
Multi-turn editing lets you respond to the model with changes after it displays an edited image response.
The following Gemini models support multi-turn editing:
We recommended limiting the entire request file size to 50MB maximum.
To test out multi-turn image editing, see the following notebooks:
To see code samples related to multi-turn image creation and editing using Gemini 3 Pro Image, see Example of multi-turn image editing using thought signatures.
What's next?
See the following links for more information about Gemini image generation: