The following Gemini models support the ability to generate images in addition to text:
-
Gemini 2.5 Flash Image, otherwise known as Gemini 2.5 Flash (with Nano Banana)
-
Gemini 3 Pro Image (preview), otherwise known as Gemini 3 Pro (with Nano Banana)
For more information about Gemini model capabilities, see Gemini modesl .
Generate images
The following shows how to generate images using either Vertex AI Studio or using the API.
For more information about best practices for prompting, see Design multimodal prompts .
Console
To generate images with Gemini, do the following:
- Open Vertex AI Studio > Create prompt .
- Click Switch model
and select one of the following models from the
menu:
-
gemini-2.5-flash-image -
gemini-3-pro-image-preview
-
- 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.
- Click the Prompt ( ) button.
Gemini generates an 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
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
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
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."
}
]
},
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
},
},
"safetySettings": {
"method": "PROBABILITY",
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
}'
2
>/dev/null
>response.json
Gemini generates an image based on your description. This process takes a few seconds, but can be comparatively slower depending on capacity.
Generate interleaved images and text
Gemini 2.5 Flash Image supports generating interleaved images with text responses. For example, Gemini 2.5 Flash Image lets you generate images for each each step of a generated recipe without having to make separate requests to the model.
Console
To generate interleaved images with text responses, do the following:
- Open Vertex AI Studio > Create prompt .
- Click Switch model
and select one of the following models from the menu:
-
gemini-2.5-flash-image -
gemini-3-pro-image-preview
-
- 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 generates a response 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": [
{
"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."
}
]
},
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"imageConfig": {
"aspectRatio": "16:9",
},
},
"safetySettings": {
"method": "PROBABILITY",
"category": "HARM_CATEGORY_DANGEROUS_CONTENT",
"threshold": "BLOCK_MEDIUM_AND_ABOVE"
},
}'
2
>/dev/null
>response.json
Gemini generates an image based on your description. This process takes a few seconds, but can be comparatively slower depending on capacity.
What's next?
See the following links for more information about Gemini image generation:

