Tool setup

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.

·

Choose a GPT Image model for your catalog

GPT Image 2, GPT Image 2.5 Flare and GPT Image 2.5 Sunburst use the same OpenAI Images endpoints, key and prepaid balance. Flare is the faster everyday option; Sunburst targets more precise edits. Compare the models on your own accepted outputs. All three use the same published token rates.

POST /v1/images/edits accepts one to five PNG, JPEG or WebP reference files, each up to 50 MB, as image or image[]. Use the same model IDs as generation. The multipart mask field is ignored; use the Responses image_generation tool for region inpainting. Check geometry, labels and product identity before accepting an edit.

See also: Edit images with GPT Image 2, Flare or Sunburst

Generate and edit with one key

Send a Bearer key to POST /v1/images/generations on router.apitoken.sale. Choose gpt-image-2, gpt-image-2.5-flare or gpt-image-2.5-sunburst. The default response contains PNG bytes as data[0].b64_json; decode, validate and store them yourself.

curl https://router.apitoken.sale/v1/images/generations \
  -H "Authorization: Bearer $APITOKEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-image-2.5-flare","prompt":"A studio photo of a ceramic mug","n":1,"quality":"low","size":"auto"}'

POST /v1/images/edits accepts one to five PNG, JPEG or WebP reference files, each up to 50 MB, as image or image[]. Use the same model IDs as generation. The multipart mask field is ignored; use the Responses image_generation tool for region inpainting. Check geometry, labels and product identity before accepting an edit.

Size controls steer proportions, not exact pixel dimensions. Higher quality values do not guarantee a higher native quality tier. The dedicated Images endpoints return base64 data; jpeg/webp output is a local conversion from the native PNG. Read the model guide before relying on a control.

A production workflow that protects the product

  1. 01Normalize source photography and assign an immutable SKU/asset version to every input file.
  2. 02Write the brief as allowed changes plus protected traits: silhouette, color, logo, labels and included accessories.
  3. 03Generate one bounded candidate, then validate product identity, rendered text, artifacts, composition and policy compliance.
  4. 04Store the original, output, prompt version, model, request ID, terminal usage and reviewer verdict as one durable record.
  5. 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.

Budget from measured token usage

Usage per 1M tokensOfficialRegular B2C · 50% off
Text input$5$2.50
Cached text input$1.25$0.625
Image input$8$4
Cached image input$2$1
Image output$30$15

For example, an edit with 900 fresh text-input tokens, 1,200 fresh image-input tokens and 4,000 image-output tokens costs $0.1341 officially, or $0.06705 at the regular B2C rate. These token counts are an example, not a promise for each picture. Use the final usage and matching request charge for your own measurements.

For a catalog or batch, divide all settled charges by the number of accepted assets. Include paid outputs that failed review. GPT Image has no free countTokens estimator: measure a small funded sample and set a spending limit before starting the queue.

Ship images that help storefront SEO

  • Track settled cost per accepted SKU image, not request count; retries and rejects are part of acquisition cost.
  • Check the actual output dimensions before creating responsive storefront sizes.
  • 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

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.

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.

Do GPT Image 2, Flare and Sunburst have different token rates?

All three share the published rates: $5 text input, $8 image input and $30 image output per 1M tokens, before the regular B2C 50% discount. Compare actual usage and accepted outputs.

Create an account, top up your balance, and generate an API key to use supported Claude, GPT and Gemini models.