We are integrating Gemini Api in our software. We want to obtain deterministic results. To do so we are testing several scenarios. One of them is to generate several images at once(batching).
But when we do so Api return only one image. I am doing something wong but i dont know what.
Here the code:
from google import genai
from google.genai import types
from PIL import Image
client = genai.Client(api_key="MyApiKey")
prompt = (
"Create a beautiful daytime bathroom."
)
image_src_0 = Image.open("D:\\AI images\\bathroom_0.png")
image_src_1 = Image.open("D:\\AI images\\bathroom_1.png")
deterministic_config = types.GenerateContentConfig(
temperature=0.7,
candidate_count=1,
top_p=0,
top_k=1,
seed=123456,
# stop_sequences=["STOP!"],
response_modalities=["IMAGE"],
# Configure internal layout specifications
image_config=types.ImageConfig(
aspect_ratio="4:3", # Options: "1:1", "3:4", "4:3", "9:16", "16:9"
imageSize="2k"
)
)
response = client.models.generate_content(
model="gemini-3.1-flash-image",
# model="gemini-3-pro-image",
contents=[
prompt,
image_src_0,
image_src_1
],
config=deterministic_config
)
curr = 0
for part in response.parts:
if part.text is not None:
print(part.text)
elif part.inline_data is not None:
image = part.as_image()
image.save("D:\\AI images\\generated_image_" + str(curr) + ".png")
curr += 1
The following will only generate generated_image_0.png.
HELP!