Dev.to WebDev 🛠 Dev 👁 0 📖 3 min read

How I Added a Free AI Product Photo Generator to a Zero-Budget Toolbox

I run a small AI toolbox for Chinese e-commerce sellers. The whole thing is built with vanilla HTML, one cheap Node server, and free APIs. Last week I added a ninth tool: a product-photo generator that costs $0 per image

I run a small AI toolbox for Chinese e-commerce sellers. The whole thing is built with vanilla HTML, one cheap Node server, and free APIs. Last week I added a ninth tool: a product-photo generator that costs $0 per image and needs no API key.

Here is the weird part: the hard problem was not image generation. It was getting the model to understand Chinese product descriptions.

The stack

  • Static frontend hosted on Netlify
  • A small Node HTTP server for text generation
  • Pollinations for free image generation: https://image.pollinations.ai/prompt/{prompt}
  • No signup, no API key, no credit card

The image endpoint returns a JPEG directly. You can open it in a browser or fetch it server-side. I call it from the browser and show the returned URL.

Problem 1: the free tier is rate-limited

Pollinations gives anonymous users roughly one image every 45 seconds per IP. If you go over the limit, it does not return an HTTP error. It returns a yellow image that literally says:

Free limit reached
1 free image every 45 seconds

That is a trap for any automated test: the request looks successful, the image has a valid JPEG content type, and your UI happily displays the rate-limit card. I now check the generated image visually and tell users to wait 45 seconds before retrying.

For a production product I would queue requests per IP and return a clear retry-after value. For a free tool, a plain hint is enough.

Problem 2: Chinese prompts were ignored

My first test used a Chinese prompt:

äļ“äļšį”ĩå•†å•†å“æ‘„å―ąïžšį™―č‰ēé™ķį“·éĐŽå…‹æŊ原æœĻæĄŒéĒ、æ™Ļ光、įŪ€įšĶ北控éĢŽïžŒæ— æ–‡å­—ïžŒæ— æ°ī印

The result was a young woman standing under cherry blossoms. The model had ignored the subject completely.

The lesson: do not send a long Chinese instruction to an English-first image model and expect it to pick out the product. Translate the product and scene into English keywords first, then build a short image prompt.

I added a translation step using Pollinations' text endpoint:

const ask = 'čŊ·æŠŠäļ‹éĒįš„äļ­æ–‡å•†å“å’Œåœšæ™ŊįŋŧčŊ‘æˆč‹ąæ–‡å›ūį‰‡į”Ÿæˆå…ģé”ŪčŊïžŒåŠčū“å‡šč‹ąæ–‡å…ģé”ŪčŊïžŒį”Ļ逗号分隔äļč́č§Ģ释' + text;
const url = 'https://text.pollinations.ai/' + encodeURIComponent(ask) + '?model=openai';
const res = await fetch(url);
const keywords = (await res.text()).trim();

The translation returned:

white ceramic mug, natural wood desk, morning light, minimalist Nordic style

Then the final image prompt becomes:

'professional e-commerce product photography, ' + keywords +
', clean composition, subject centered, no text, no watermark, high detail'

That produced a clean mug on a wooden desk on the first try. Same tool, same model, completely different result.

Problem 3: Node fetch can hang

In Node 22, fetch sometimes times out connecting to the image CDN. Adding this at startup fixed it:

import dns from 'node:dns';
dns.setDefaultResultOrder('ipv4first');

I also retry the image request up to four times. Each attempt is cheap. The client only sees a loading state.

The workflow users see

  1. Type a product name and an optional scene, in Chinese.
  2. The page translates the scene into English keywords.
  3. It requests a 768×768 image from Pollinations.
  4. The image appears with a "long-press or right-click to save" hint.

No login. No server-side image storage. The image URL points at the public CDN.

What I would improve next

  • Add optional reference-image upload so the output keeps the exact product shape
  • Queue requests and show a real countdown instead of a static hint
  • Add background removal after generation

For now, the limitation is clear and I state it in the UI: the output is a scene illustration, not a real product photo. Do not use it as a fake "real shot" on a product page.

Try it

The tool is free and open in the browser:

https://xiaoshengyi-toolbox.netlify.app/tools/tupian.html?utm_source=devto&utm_medium=social&utm_campaign=tupian

The rest of the toolbox is here:

https://xiaoshengyi-toolbox.netlify.app/

If you are building something similar, the two things worth stealing are the translate-first step and the rate-limit check. Both are small changes that turn a demo into something a real seller can use.

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.