An image generation API workflow for ecommerce catalogs
Product imagery is an identity-preservation problem before it is a prompt-writing problem. Lock the product traits, permit only named scene changes, validate every output, and optimize cost only after the acceptance gate is reliable.
·
Match each catalog job to the right model
You can produce catalog-ready product images programmatically with two live models behind one prepaid apiToken.sale key: Nano Banana 2 (gemini-3.1-flash-image) on the native Gemini route and GPT Image 2 (gpt-image-2) on the OpenAI Images route. The right choice is per job, not per store: Nano Banana 2 gives explicit 1K/2K/4K sizes, broad aspect-ratio control and up to 14 reference inputs, while GPT Image 2 gives an OpenAI Images edit flow with one to five PNG, JPEG or WebP references for teams already on that client.
| Job | Recommended starting route | Mandatory check |
|---|---|---|
| New lifestyle scene for a hero shot | Nano Banana 2 1K with explicit aspect ratio | Product identity and packaging text survive |
| Strict background swap on packshot PNG | GPT Image 2 /v1/images/edits | No product geometry change |
| One SKU, many reference angles | Nano Banana 2 with the full reference set | Consistency of the product across views |
| Existing OpenAI media pipeline | GPT Image 2 | Opaque or transparent PNG and proportion size acceptable |
| Whole-catalog seasonal refresh | Batch queue over either model | Settled cost per accepted SKU asset |
GPT Image 2 publishes transparent cutouts when you send background=transparent: the PNG has a real alpha channel. size is a proportion preset (auto/1:1 ~1254×1254, 3:2, 2:3, 4:3, 16:9, 9:16), not a 1024-pixel or 4K lock. If a fixed pixel size is a hard storefront requirement, reject that route at design time instead of repairing every output later.
Editing route contracts: references, formats, output shapes →
Two wire protocols behind one prepaid key
The same key works for both routes, but the request shapes are not interchangeable. Nano Banana 2 is called with the Gemini generateContent shape and the x-goog-api-key header; the response carries the picture as a base64 inlineData image part. GPT Image 2 uses the OpenAI Images endpoints with Authorization: Bearer and returns one non-streaming base64 PNG. Size and quality controls differ too: imageConfig.imageSize (1K/2K/4K) plus aspectRatio on the Gemini side, the published background/quality/size values opaque-or-transparent/low/proportion-preset on the OpenAI side.
# Nano Banana 2 — native Gemini route, explicit size and ratio
curl https://router.apitoken.sale/v1beta/models/gemini-3.1-flash-image:generateContent \
-H "x-goog-api-key: $APITOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"contents":[{"parts":[{"text":"Place SKU-1042 on a warm kitchen counter, soft daylight"}]}],"generationConfig":{"responseModalities":["TEXT","IMAGE"],"imageConfig":{"imageSize":"1K","aspectRatio":"4:5"}}}'
# GPT Image 2 — OpenAI Images route, published controls only
curl https://router.apitoken.sale/v1/images/generations \
-H "Authorization: Bearer $APITOKEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"Studio packshot of a matte black bottle, seamless grey background","background":"opaque","quality":"low","size":"auto"}'Getting started is cheap by design: new B2C accounts created with Google or GitHub receive $5 of platform bonus credit (valid on Claude, GPT and Gemini models; email-and-password accounts are not eligible), and balance top-ups accept bank card or cryptocurrency. For a catalog worker, issue a dedicated key with a lifetime spending limit and an expiration date so a runaway batch cannot drain the whole account.
A production workflow that protects the product
- 01Normalize source photography and assign an immutable SKU/asset version to every input file.
- 02Write the brief as allowed changes plus protected traits: silhouette, color, logo, labels and included accessories.
- 03Generate one bounded candidate, then validate product identity, rendered text, artifacts, composition and policy compliance.
- 04Store the original, output, prompt version, model, request ID, terminal usage and reviewer verdict as one durable record.
- 05Publish only an optimized web derivative; never serve the API's base64 payload directly as a storefront asset.
PRODUCT: SKU-1042, matte black bottle, silver cap, logo unchanged ALLOWED: replace the background with a warm kitchen scene PROTECTED: silhouette, cap shape, logo spelling, label colors OUTPUT: one centered catalog hero image; no added text or accessories
A prompt is an instruction, not a guarantee. Validation against the protected traits is what keeps a regenerated background from quietly becoming a different product.
Cost math for a real catalog run
Nano Banana 2 has a fixed image-output leg per size: 1K bills 1,120 image tokens, which is $0.0672 official and $0.0336 for a regular B2C account after the 50% discount; 2K is $0.0504 and 4K is $0.0756 on the same terms. A seasonal refresh of 500 SKUs with two 1K candidates each produces 1,000 images, so the image-output legs settle at $33.60 for regular B2C, plus bounded prompt and reference input. If validation accepts 700 of those candidates, the image-leg cost per accepted asset is $33.60 ÷ 700 ≈ $0.048 — that is the number to compare against a reshoot budget, not the raw request count.
GPT Image 2 has no honest per-picture list price: billing combines terminal text-input, image-input, cached-input and image-output usage. A worked example with round numbers — if terminal usage reports 500 fresh text tokens and 4,000 image-output tokens, the official total is 500 × $5/M + 4,000 × $30/M = $0.1225, and a regular B2C account pays exactly half, $0.06125. References add image-input at $8/M official ($4/M after the discount), so an edit brief should send only the files the scene actually needs.
For regular B2C, the 50% discount applies to the exact official generation or edit usage. Conversion, CDN storage, human review and rejected assets remain your application costs and belong in the ecommerce business case.
Ship images that help storefront SEO
- Track settled cost per accepted SKU image, not request count; retries and rejects are part of acquisition cost.
- Start at the smallest delivery resolution (1K) and promote only hero assets that fail a delivery-detail check.
- Use descriptive filenames and truthful alt text describing the actual product and scene; never stuff model names or keyword lists into alt text.
- Encode responsive WebP/AVIF derivatives, keep a lossless master, and publish explicit width/height to avoid layout shift.
- Keep generated-image provenance and review evidence out of public metadata when it contains internal IDs or prompts.
Frequently asked questions
Which model should an ecommerce team start with for product images?
Run a small eval on your own SKUs. Nano Banana 2 is the stronger starting point when you need explicit aspect ratios, 1K/2K/4K sizes or many reference angles; GPT Image 2 fits OpenAI Images background edits and teams with an existing OpenAI Images client. Pin the winner per asset class rather than choosing one model for the whole catalog.
Can I generate transparent product cutouts with GPT Image 2 here?
Yes. Send background=transparent on POST /v1/images/generations or /v1/images/edits. That requests a PNG with a real alpha channel; inspect the file — a missing alpha is still HTTP 200. size remains a proportion preset, not a fixed pixel lock.
How do I stop the model from changing the product itself?
Declare protected traits in the brief — silhouette, colors, logo spelling, label text — provide clean references, change one named element at a time, and reject any candidate that fails product-identity validation. The prompt narrows the search space; only the acceptance gate protects the catalog.
What does it cost to re-shoot a 1,000-image catalog?
With Nano Banana 2 at 1K, one thousand image-output legs settle at $33.60 for a regular B2C account after the 50% discount, plus bounded input. Divide the settled total by the number of accepted assets to get the real figure; a 70% acceptance rate puts the image-leg cost near $0.048 per accepted SKU image.
Does the 50% discount cover CDN and review costs?
No. It applies to the exact official model usage for regular B2C accounts — generation and edit requests. Storage, WebP/AVIF transformation, CDN delivery, human review and rejected assets are separate application costs that stay in your business case.
Is there a free way to test before funding a catalog run?
Yes. New B2C accounts created with Google or GitHub get $5 of platform bonus credit, valid on Claude, GPT and Gemini models. For Nano Banana 2 you can also call countTokens to estimate input for free before any image is billed. When you top up, bank card and cryptocurrency are both accepted.
Create an account with Google or GitHub and test the gateway with $5 of platform bonus credit.