I am currently have a tool that uses Gemini-2.5-flash-image to generate images. However, I am only getting 1 image to be generated. I want the model to create multiple images for example 3 images at once. What is the ideal way to set it up ?
Is it only possible by looping and calling the model multiple times to get more images ? but that seems inefficient to make multiple calls. Seems like this should be possible within a single call.
It also says in the docs (https://docs.cloud.google.com/vertex-ai/generative-ai/docs/models/gemini/2-5-flash-image): “Maximum number of output images per prompt: 10”
Below is the code Ive setup.
Things ive tried:
Changing candidate_count value doesn’t create more images.
I also changed the prompt and asked it to directly created 3 images but still only creates 1 image.
generation_config = GenerateContentConfig(
response_modalities=[Modality.IMAGE],
candidate_count=1, # Only one candidate is supported.
safety_settings=[
SafetySetting(
category=HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
threshold=HarmBlockThreshold.BLOCK_ONLY_HIGH,
),
],
)
response = client.models.generate_content(
model="gemini-2.5-flash-image",
contents=f"Generate an image of: {prompt}",
config=generation_config,
)