# Changing background of product picture to create an ad

**URL:** <https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870>\
**Category:** Questions\
**Created:** [May 11, 2025, 10:15pm UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870 "2025-05-11T22:15:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anthony\_Roger](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/anthony_roger/32/79032_2.png) [@Anthony\_Roger](https://community.n8n.io/u/Anthony_Roger)\
**Post date:** [May 11, 2025, 10:15pm UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/1 "2025-05-11T22:15:54Z")

</div>

## Describe the problem/error/question

Use case: I have product pictures (png) in google drive. I set a nod to convert these into base64 before passing them to an AI model to change the background (eg I have picture of sofa and I want to add it to a living room)  
Pb: I tried to call with HTTP node the brand new Gemini API, I am based in the US (no geo restrictution) but can’t make it work (end point: [https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent?key=APIKEY](https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash-exp-image-generation:generateContent?key=APIKEY)).

I keep on getting this message: "“models/gemini-2.0-flash-exp-image-generation is not found for API version v1beta, or is not supported for generateContent” while Google API doc says this model exists: [https://ai.google.dev/gemini-api/docs/models#gemini-2.0-flash](https://ai.google.dev/gemini-api/docs/models#gemini-2.0-flash)

I tried Open AI but only manage to make image from scratch, not leveraging my product picture

I am surely missing something but can’t find how to make it work via API calls (on both Open AI UI and Gemini UI I managed to get what I want but not via n8n)

Thanks a lot for any pointer, I spent 3 days on this and exhausted all I could think of

## What is the error message (if any)?

## Please share your workflow

```auto
(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

```

## Share the output returned by the last node

## Information on your n8n setup

- **n8n version:**
- **Database (default: SQLite):**
- **n8n EXECUTIONS\_PROCESS setting (default: own, main):**
- **Running n8n via (Docker, npm, n8n cloud, desktop app):**
- **Operating system:**

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [May 12, 2025, 5:54am UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/2 "2025-05-12T05:54:55Z")

</div>

Hello @Anthony_Roger

Assuming there is no geo-restriction as explained here:

> [@Gemini new image generation model API: Any luck using it with HTTP node](http://community.n8n.io/t/gemini-new-image-generation-model-api-any-luck-using-it-with-http-node/113072/2):
>
> Hi @Anthony_Roger First, are you allowed to use it? Simply go to [https://ai.dev](https://ai.dev) and check if the model is listed in your account or not. If it’s not listed, it may not be available in your country. If it is listed, then availability isn’t the issue, and you can try accessing it via the API (HTTP node)..

The endpoint you’re mentioning looks good to me and is working on my side.

So, I suggest you double-check the JSON body that you included in the request..

---

<div class="post-metadata">

**Author:** ![Anthony\_Roger](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/anthony_roger/32/79032_2.png) [@Anthony\_Roger](https://community.n8n.io/u/Anthony_Roger)\
**Post date:** [May 12, 2025, 2:50pm UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/3 "2025-05-12T14:50:50Z")

</div>

> [@mohamed3nan](#):
>
> o, I suggest you double-check the JSON body that you included in the request…

Thanks this really helps knowing that this endpoint actually works. I will triple check my JSON script today and revert. Thanks again for the reco

---

<div class="post-metadata">

**Author:** ![Anthony\_Roger](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/anthony_roger/32/79032_2.png) [@Anthony\_Roger](https://community.n8n.io/u/Anthony_Roger)\
**Post date:** [May 12, 2025, 11:27pm UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/4 "2025-05-12T23:27:35Z")

</div>

So I tried several JSON script (including some generated by Gemini) but no luck at calling this API and generating an image. My set up\> Google Drive, download a file then a convert to base64 node, then a HTTP node. The first 2 nodes work, the HTTP one doesn’t. If the endpoint works, it seems my JSON doesn’t. Is there any resource of a JSON call for this API I can refer to? I checked the template but this model isn’t there yet

---

<div class="post-metadata">

**Author:** ![mohamed3nan](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mohamed3nan/32/188347_2.png) [@mohamed3nan](https://community.n8n.io/u/mohamed3nan)\
**Post date:** [May 13, 2025, 11:02am UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/5 "2025-05-13T11:02:32Z")

</div>

Hi @Anthony_Roger

This is a very basic example of how to call Gemini to generate an image via the HTTPS node:

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/d/4/d4e82e5863eaa030bb9610b8b973fe0f3c93c2c6.jpeg)  
You can find more details here:

> **[Image generation (text-to-image) - Gemini API  |  Google AI for Developers](https://ai.google.dev/gemini-api/docs/image-generation#image_generation_text-to-image)**
>
> Reminder: Make sure you have the necessary rights to any images you upload. Don't generate content that infringe on others' rights, including videos or images that deceive, harass, or harm. Your use of this generative AI service is subject to our...

Feel free to edit it as needed, and let me know if you need any assistance.

---

<div class="post-metadata">

**Author:** ![Wouter\_Nigrini](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/wouter_nigrini/32/150261_2.png) [@Wouter\_Nigrini](https://community.n8n.io/u/Wouter_Nigrini)\
**Post date:** [May 13, 2025, 11:11am UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/6 "2025-05-13T11:11:18Z")

</div>

Are you hard set on using Gemini? Ive done something similar for a side project where I replaced the background of a car using Stability AI. My process was:

1. Take input image and strip background (Maybe your products already have no background)
2. Use the structure API to generate a new image using the same structure of the car with a different background
3. Use n8n Edit Image node to stick the Masked car onto the new image generated.
4. Push the new image to a cdn for use in my app

Heres the results:

 ![WhatsApp Image 2025-05-13 at 13.13.16](https://europe1.discourse-cdn.com/n8n/original/3X/a/5/a5f8c5b88efef008fea931dca40ddb337d46542c.jpeg)  
 ![WhatsApp Image 2025-05-13 at 13.13.16 (2)](https://europe1.discourse-cdn.com/n8n/original/3X/1/7/17d86b1b8130c92cd7d3cec920c5c8aa119af337.jpeg)  
 ![WhatsApp Image 2025-05-13 at 13.13.16 (3)](https://europe1.discourse-cdn.com/n8n/original/3X/1/7/17603db7fff0b19360e105e7cdd62162bc26d618.jpeg)

NB: Slightly different images, as I cant find my old execution, but to give an idea of the process

---

<div class="post-metadata">

**Author:** ![Anthony\_Roger](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/anthony_roger/32/79032_2.png) [@Anthony\_Roger](https://community.n8n.io/u/Anthony_Roger)\
**Post date:** [May 14, 2025, 12:39am UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/7 "2025-05-14T00:39:07Z")

</div>

Nice car!! Thanks a million for the examples, will test this out now. I wanted to use Gemini as I had some API credit but will switch allegiances if I can’t make it work

---

<div class="post-metadata">

**Author:** ![Anthony\_Roger](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/anthony_roger/32/79032_2.png) [@Anthony\_Roger](https://community.n8n.io/u/Anthony_Roger)\
**Post date:** [May 14, 2025, 12:49am UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/8 "2025-05-14T00:49:15Z")

</div>

I will go the Stability AI or even Chatgpt road. I tried the exact worlfow with Gemini (copy pasted it) and still got the same error message so not sure what is wrong with my Gemini API account. Anyway thanks a mill for the solutions.

---

<div class="post-metadata">

**Author:** ![Wouter\_Nigrini](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/wouter_nigrini/32/150261_2.png) [@Wouter\_Nigrini](https://community.n8n.io/u/Wouter_Nigrini)\
**Post date:** [May 14, 2025, 9:03am UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/9 "2025-05-14T09:03:27Z")

</div>

Sometimes it’s worth using the right tool for the job. There are off course many options out there. I have yet to properly play with the new GPT image gen.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [May 21, 2025, 9:03am UTC](https://community.n8n.io/t/changing-background-of-product-picture-to-create-an-ad/113870/10 "2025-05-21T09:03:41Z")

</div>

Closed on May 21, 2025, 9:03am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
