# How to generate several image to image at once using Gemini Api

**URL:** <https://discuss.ai.google.dev/t/how-to-generate-several-image-to-image-at-once-using-gemini-api/170930>\
**Category:** Gemini API\
**Tags:** api\
**Created:** [June 12, 2026, 2:08am UTC](https://discuss.ai.google.dev/t/how-to-generate-several-image-to-image-at-once-using-gemini-api/170930 "2026-06-12T02:08:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trylz](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/trylz/32/130864_2.png) [@Trylz](https://discuss.ai.google.dev/u/Trylz)\
**Post date:** [June 12, 2026, 2:08am UTC](https://discuss.ai.google.dev/t/how-to-generate-several-image-to-image-at-once-using-gemini-api/170930/1 "2026-06-12T02:08:06Z")

</div>

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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![Sai\_Deepika\_K](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/sai_deepika_k/32/34803_2.png) [@Sai\_Deepika\_K](https://discuss.ai.google.dev/u/Sai_Deepika_K)\
**Post date:** [June 17, 2026, 8:03am UTC](https://discuss.ai.google.dev/t/how-to-generate-several-image-to-image-at-once-using-gemini-api/170930/2 "2026-06-17T08:03:51Z")

</div>

Hello @Trylz ,

When you pass multiple images into contents like this: contents=[prompt, image\_src\_0, image\_src\_1], the API does not treat them as separate, batched jobs. Instead, it processes them as a single interleaved multimodal prompt context. To get a separate generated output image for each of your input images, you need to loop through your source images and execute an independent API call for each one.

---

<div class="post-metadata">

**Author:** ![system](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/system/32/1_2.png) [@system](https://discuss.ai.google.dev/u/system)\
**Post date:** [November 5, 2026, 6:42pm UTC](https://discuss.ai.google.dev/t/how-to-generate-several-image-to-image-at-once-using-gemini-api/170930/4 "2026-11-05T18:42:09Z")

</div>

Closed on November 5, 2026, 6:42pm UTC

This thread was automatically closed 60 days after the last reply. If you are running into an issue, please create a new post.
