Gemini 2.5 Flash Image Preview supports response generation in multiple
modalities, including text and images. Gemini Flash Preview Image's public preview for image generation
( With this public experimental release, Gemini 2.5 Flash Image Preview can
generate images in 1024px, supports generating images of people,
and contains updated safety filters that provide a more flexible and less
restrictive user experience. It supports the following modalities and capabilities: Text to image Text to image (text rendering) Text to image(s) and text (interleaved) Image(s) and text to image(s) and text (interleaved) Locale-aware image generation Limitations: The following sections cover how to generate images using either
Vertex AI Studio or using the API. For guidance and best practices for prompting, see
Design multimodal prompts. To use image generation:
Gemini will generate an image based on your description. This
process should take a few seconds, but may be comparatively slower depending on
capacity.
To learn more, see the
SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
To learn more, see the
SDK reference documentation.
Set environment variables to use the Gen AI SDK with Vertex AI:
Run the following command in the terminal to create or overwrite this file in
the current directory:
Gemini will generate an image based on your description. This
process should take a few seconds, but may be comparatively slower depending on
capacity.
Image generation
gemini-2.5-flash-image-preview
) supports the ability to generate
images in addition to text. This expands Gemini's capabilities to include the
following:
Generate images
Console
gemini-2.5-flash-image-preview
from the menu.
Python
Install
pip install --upgrade google-genai
# 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
# 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
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": { "text": "Create a tutorial explaining how to make a peanut butter and jelly sandwich in three easy steps."},
},
"generation_config": {
"response_modalities": ["TEXT", "IMAGE"],
},
"safetySettings": {
"method": "PROBABILITY",
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
}' 2>/dev/null >response.json
Generate interleaved images and text
Gemini 2.5 Flash Image Preview can generate interleaved images with its text responses. For example, you can generate images of what each step of a generated recipe might look like to go along with the text of that step, without having to make separate requests to the model to do so.
Console
To generate interleaved images with text responses:
- Open Vertex AI Studio > Create prompt.
-
Click Switch model and select
gemini-2.5-flash-image-preview
from the menu. - In the Outputs panel, select Image and text from the drop-down menu.
- Write a description of the image you want to generate in the text area of the Write a prompt text area. For example, "Create a tutorial explaining how to make a peanut butter and jelly sandwich in three easy steps. For each step, provide a title with the number of the step, an explanation, and also generate an image, generate each image in a 1:1 aspect ratio."
- Click the Prompt ( ) button.
Gemini will generate a response based on your description. This process should take a few seconds, but may 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
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": { "text": "Create a tutorial explaining how to make a peanut butter and jelly sandwich in three easy steps. For each step, provide a title with the number of the step, an explanation, and also generate an image, generate each image in a 1:1 aspect ratio."},
},
"generation_config": {
"response_modalities": ["TEXT", "IMAGE"],
},
"safetySettings": {
"method": "PROBABILITY",
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
}' 2>/dev/null >response.json
Gemini will generate an image based on your description. This process should take a few seconds, but may be comparatively slower depending on capacity.
Locale-aware image generation
Gemini 2.5 Flash Image Preview can also include information about your location when providing text or image responses. For example, you can generate images of types of locations or experiences that take your current location into account without having to specify your location to the model to do so.
Console
To use locale-aware image generation:
- Open Vertex AI Studio > Create prompt.
-
Click Switch model and select
gemini-2.5-flash-image-preview
from the menu. - In the Outputs panel, select Image and text from the drop-down menu.
- Write a description of the image you want to generate in the text area of the Write a prompt text area. For example, "Generate a photo of a typical breakfast."
- Click the Prompt ( ) button.
Gemini will generate a response based on your description. This process should take a few seconds, but may 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
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": { "text": "Generate a photo of a typical breakfast."},
},
"generation_config": {
"response_modalities": ["TEXT", "IMAGE"],
},
"safetySettings": {
"method": "PROBABILITY",
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
}' 2>/dev/null >response.json
Gemini will generate an image based on your description. This process should take a few seconds, but may be comparatively slower depending on capacity.