E-commerce Product Image Generation API: Scale Visuals With AI
You're launching 500 new SKUs this quarter. Your photo studio can handle 50. The gap between those two numbers is where an AI image generation API stops being a novelty and becomes a practical engineering decision.
This guide covers how to integrate an AI image generation API into an e-commerce product pipeline—which model to use for which job, how to structure prompts for consistent output, and what it actually costs at scale.
What image models are available for e-commerce via API?
As of August 2026, GenRelay exposes three production-ready image generation models through a single unified endpoint:
| Model | Resolutions | Pricing | Best for |
|---|---|---|---|
| Nano Banana Pro | 1K / 2K / 4K | $0.030 / $0.030 / $0.042 per image | High-resolution lifestyle and studio shots |
| Nano Banana 2 | 1K / 4K | $0.020 / $0.036 per image | Budget-conscious SKU generation at volume |
| GPT-image-2 | Standard | $0.014 per image | Editing existing product photos, background replacement |
The practical recommendation for most e-commerce workflows: use Nano Banana 2 at 1K for draft review and internal approval ($0.020 each), then switch to Nano Banana Pro at 2K or 4K for the final images that go live on product detail pages.
GPT-image-2 fills a different role—it accepts an existing image plus a mask for in-painting edits rather than generating from scratch. Useful for standardizing backgrounds across an existing photo library.
How do I make my first API call to generate a product image?
All three models are accessible through a single POST endpoint. Authentication uses a Bearer token from the GenRelay console.
import requests
import os
GENRELAY_API_KEY = os.environ["GENRELAY_API_KEY"] # set in environment, not hardcoded
def generate_product_image(
prompt: str,
model: str = "nano-banana-2",
size: str = "1024x1024"
) -> str:
"""Returns the generated image URL."""
response = requests.post(
"https://api.genrelay.ai/v1/images/generations",
headers={"Authorization": f"Bearer {GENRELAY_API_KEY}"},
json={
"model": model,
"prompt": prompt,
"n": 1,
"size": size,
}
)
response.raise_for_status()
return response.json()["data"][0]["url"]
url = generate_product_image(
prompt="Ceramic coffee mug on a clean white studio background, soft even lighting, product photography",
model="nano-banana-2",
size="1024x1024"
)
print(url)
Typical response time for Nano Banana 2 at 1K is 4–8 seconds. Nano Banana Pro at 4K runs 10–20 seconds depending on load.
How should I structure prompts for consistent product photography?
Prompt consistency is the hardest part of using generative AI in e-commerce at scale. Without a template, you get different lighting, angles, and backgrounds per run.
A prompt formula that produces reliable catalog images:
[product description], [surface/background], [lighting style], [camera angle], [photography keywords]
Concrete examples:
"Blue denim jacket laid flat on a pure white background, even studio lighting, top-down angle, product photography, high detail""Stainless steel water bottle on a gray gradient background, soft diffused light, three-quarter view, commercial product shot""Running shoes on a wooden floor, natural window light from the left, side view, lifestyle product photo, sharp focus on sole"
Three rules that matter in practice:
- White background beats "clean background" — "pure white background" and "white studio background" produce more consistent results than vague descriptors. Amazon-style backgrounds consistently require this exact phrasing.
- Name the angle explicitly — "three-quarter view", "top-down", "side view", "front-facing" prevent random perspective changes between generations.
- Skip transparency — current models return JPEG or PNG without alpha channels. If you need transparent backgrounds, generate on white and remove it in post-processing.
How do I generate images in batch for a full product catalog?
For catalog-scale generation, use async requests with a concurrency limit. The following example generates images for multiple products simultaneously while respecting rate limits:
import asyncio
import aiohttp
import os
GENRELAY_API_KEY = os.environ["GENRELAY_API_KEY"]
CONCURRENCY = 5 # concurrent requests; adjust to your plan tier
async def generate_image(
session: aiohttp.ClientSession,
prompt: str,
model: str = "nano-banana-2",
size: str = "1024x1024"
) -> dict:
async with session.post(
"https://api.genrelay.ai/v1/images/generations",
headers={"Authorization": f"Bearer {GENRELAY_API_KEY}"},
json={"model": model, "prompt": prompt, "n": 1, "size": size}
) as resp:
resp.raise_for_status()
data = await resp.json()
return {"prompt": prompt, "url": data["data"][0]["url"]}
async def batch_generate(prompts: list[str], model: str = "nano-banana-2") -> list[dict]:
sem = asyncio.Semaphore(CONCURRENCY)
async with aiohttp.ClientSession() as session:
async def bounded(prompt: str) -> dict:
async with sem:
return await generate_image(session, prompt, model)
return await asyncio.gather(*[bounded(p) for p in prompts])
# 500-SKU example — run in chunks if needed
prompts = [
"Blue ceramic vase on white background, product photography, front view",
"Brown leather bifold wallet on gray linen surface, top-down, studio lighting",
# ... remaining prompts
]
results = asyncio.run(batch_generate(prompts))
for r in results:
print(r["url"])
This keeps 5 requests in flight at a time. Install aiohttp with pip install aiohttp.
How do I use GPT-image-2 to edit existing product photos?
GPT-image-2 accepts an existing image and a mask file to replace a region—background swaps, removing distracting elements, or adding props.
import requests
import os
GENRELAY_API_KEY = os.environ["GENRELAY_API_KEY"]
def edit_product_image(image_path: str, mask_path: str, prompt: str) -> str:
"""
Replace the masked region of an existing product photo.
Mask must be PNG: white = area to replace, black = area to keep.
"""
with open(image_path, "rb") as img_f, open(mask_path, "rb") as mask_f:
response = requests.post(
"https://api.genrelay.ai/v1/images/edits",
headers={"Authorization": f"Bearer {GENRELAY_API_KEY}"},
files={"image": img_f, "mask": mask_f},
data={
"model": "gpt-image-2",
"prompt": prompt,
"n": "1",
"size": "1024x1024",
}
)
response.raise_for_status()
return response.json()["data"][0]["url"]
url = edit_product_image(
image_path="product_original.png",
mask_path="background_mask.png",
prompt="Replace background with a clean white studio background, soft shadows under product"
)
print(url)
At $0.014 per edit, standardizing backgrounds across 1,000 existing product photos costs $14.00—a viable alternative to reshooting.
What does it cost to generate product images at scale?
Worked cost math for a 500-SKU catalog with multiple variants per product:
| Workflow | Model | Resolution | Per image | 500 images | 500 × 3 variants |
|---|---|---|---|---|---|
| Draft review | Nano Banana 2 | 1K | $0.020 | $10.00 | $30.00 |
| Final catalog | Nano Banana 2 | 4K | $0.036 | $18.00 | $54.00 |
| Hero / PDP | Nano Banana Pro | 2K | $0.030 | $15.00 | $45.00 |
| Hero / PDP | Nano Banana Pro | 4K | $0.042 | $21.00 | $63.00 |
A typical two-pass workflow—1K draft for internal review, then 4K final for publishing—costs $0.056 per SKU using Nano Banana 2, or $0.072 per SKU using Nano Banana Pro at the final step.
For context: stock photography licensing runs $0.25–$5.00 per image, and professional product photography typically costs $15–$50 per SKU for a studio shoot. Even the highest-quality API option (Nano Banana Pro 4K) comes in at $0.042 per image.
FAQ
Can the API guarantee a white background output?
No generation is deterministic. For Amazon listing requirements or other strict white-background specs, generate 2–3 variants and use a programmatic background validator or a background-removal service as a post-processing step. Build retry logic that re-prompts on failure.
What image format does the API return?
Generated images come back as URLs pointing to JPEG or PNG. Download and transcode to whatever format your pipeline requires—don't rely on the hosted URL being permanent.
Is there a file size limit for GPT-image-2 edits?
The edits endpoint accepts images up to 4 MB. Compress large product photos before uploading; standard product shots compress well with Pillow or sharp.
Can I request a specific color accurately?
Color fidelity in generated images is approximate. Use specific Pantone-adjacent descriptors ("cobalt blue", "sage green", "burnt sienna") rather than generic color names. For strict color matching, generate on a neutral background and apply color grading in post-processing.
How many images can I generate per minute?
Rate limits depend on your plan. Check the GenRelay console for your current quota. Higher-tier plans support significantly more concurrent requests.
For a side-by-side quality and cost comparison across all three image models, see the multi-model image API comparison 2026. To explore each model's capabilities directly, visit the Nano Banana and GPT-image-2 model pages on GenRelay.