Tool setup

Build a batch image generation pipeline that cannot overrun its budget

Run GPT Image 2, Flare or Sunburst behind your own durable queue. Set n=1 per job, bound workers and attempts, and reconcile usage before retrying an uncertain request.

·

Queue one image per job

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.

Use n=1 for each queue job so you can track each asset and its cost. Images requests accept n=1..10, executing sequential native turns; this is not an asynchronous batch service. Keep queue ordering, concurrency, retries and budgets in your application.

See also: How image generation API pricing actually works

One durable job per asset, not per prompt

  1. 01Create a stable asset ID and an immutable brief — prompt, references, protected traits — before anything is enqueued.
  2. 02Resolve the model, protocol, output size and maximum attempts into the job payload, so a retry replays the same decision rather than making a new one.
  3. 03Give each worker a bounded slice of the queue and reserve one provider request per candidate; never ask the model for an internal batch.
  4. 04Persist the request ID, terminal usage, output checksum and validation verdict atomically with the asset version.
  5. 05Mark the job complete only after storage and downstream publication both confirm the same asset version.

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.

Bound every multiplier, not just the price

MultiplierGuardrail
AssetsExplicit queue length and campaign budget
VariantsMaximum candidates per asset
RetriesOnly proven not-started attempts; total deadline
ResolutionCheck returned dimensions; size steers proportions
ReferencesOnly files required by the brief
ConcurrencySmall worker ceiling with 429 cooling

A key's lifetime spending limit is the last monetary boundary when every application-level guardrail fails. Set it to the campaign budget plus a measured safety margin — not to the account balance.

Retry, cooling and observability rules

  • Never retry after image bytes or a complete provider response were delivered — that retry is a second paid candidate, not a recovery.
  • Treat an ambiguous timeout as reconciliation work: match the request ID against the dashboard charge before concluding that no billable generation happened.
  • Honor 429 responses with Retry-After, provider cooling and jitter inside a total deadline; immediate fan-out amplifies a capacity event.
  • Track attempts, accepted assets, settled nanoUSD and validation failure reasons; keep prompts and keys out of metrics.
  • Alert on cost per accepted asset and failure share, not only on HTTP success rate — a fully green batch can still be an expensive one.

Settled cost per accepted asset is the batch's real unit economics: it folds token price, resolution, retries and quality rejects into the single number the business actually buys.

Isolate the batch lane with its own key and budget

Run the batch worker on a dedicated key with a lifetime spending limit and an expiration date, so a queue bug can exhaust only the campaign budget, never the account. The prepaid balance never expires, and there is no subscription to size.

  • One key per workload: batch generation never shares a key with interactive or editing traffic.
  • Reconcile every settled charge against its request ID before the campaign is closed.
  • Re-check the lifetime spending limit before each new campaign, not once at setup.

Prepaid plans that never expire: fund exactly the campaign budget →

Frequently asked questions

Can one API request generate a whole batch?

Images requests accept n=1..10 with sequential native turns. For large jobs, use n=1 per queue item and control concurrency and budgets in your application. There is no asynchronous Images batch endpoint.

How do I stop a runaway image batch?

Combine a dedicated key carrying a lifetime spending limit, an explicit queue length, bounded workers, a per-asset maximum attempt count and a total campaign budget. Each layer fails independently, and the key-level limit is the boundary that holds even if all the others misbehave.

Should 429 responses be retried immediately?

No. Respect Retry-After and provider cooling, add jitter and keep a total deadline per job. Immediate fan-out during a capacity event converts a slowdown into an outage you paid to create.

Should the pipeline store the base64 payload or a URL?

Treat the API response as transport, not storage. Decode base64 once, checksum and persist the bytes in your own object storage, then publish optimized WebP/AVIF derivatives; never serve the raw API payload as a storefront asset.

Does the 50% discount apply to every call in a batch?

For regular B2C accounts it applies to the official usage of every admitted call, generation or edit. B2B accounts follow their negotiated policy, and OpenKeys bill 1:1 at official prices. A discount never proves that a model is currently available to a particular key.

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