Mental model
An image progress interface should mirror evidence from the generation stream: a request is accepted, generation is active, optional previews arrive, and a final asset completes the job. Partial images are useful but provisional. Because the API may return fewer previews than requested, the interface must never infer a percentage from a preview count or denoising step it cannot observe.
Theory
Treat progress as a state machine driven by server events, not as an animation that estimates hidden work. In the Responses API, the image-generation call can emit response.image_generation_call.in_progress, response.image_generation_call.generating, and response.image_generation_call.partial_image events before the enclosing response completes. A partial-image event carries an item ID, an output index, a sequence number, a zero-based preview index, and base64 image data. The final response contains the completed image result; that asset becomes the display authority.
The request configuration controls whether the server may send previews. partial_images: 0 requests only the final image; a positive value requests up to three previews. A fast generation may finish before every requested preview is emitted, so the requested count is an upper bound. It is not a denominator for user-visible progress. Likewise, the model's internal denoising schedule is not a public event contract. Reporting “42% complete” because two of five preview slots appeared turns an arrival pattern into a false time estimate.
Use a per-request identity and the event sequence number to reject delayed updates from a prior attempt. Keep the lifecycle explicit: queued, generating, preview available, completed, failed, or cancelled. Preview state can contain several indexed images, while completed state contains the final output. Completion replaces the preview as the primary image; keeping a preview in a separate history can be useful for comparison, but the UI must mark it as an intermediate result.
Trade-offs
Previews reduce the wait before a user sees visual feedback, but they cost bandwidth, decoding work, and memory. For an image around 1024 by 1024 pixels, a decoded RGBA bitmap occupies roughly 4 MiB before browser-side copies or GPU textures. Holding three previews while also decoding the final output can therefore add tens of megabytes in a busy gallery. Limit retained previews, release object URLs when a card unmounts, and decode off the critical interaction path where the platform permits it.
Show meaningful status text such as “Generating image” and “Preview 1 available.” If the service exposes no calibrated completion estimate, use an indeterminate progress indicator instead of a fake numeric percentage. A first preview is a user-visible milestone, not a guarantee that generation will finish within a fixed interval. Include a cancel action that aborts the request and moves the UI to a terminal cancelled state; do not leave a spinner running after the transport closes.
Failure modes and misconceptions
An intermediate image can be mistaken for the final asset when the interface replaces its label but not its thumbnail. Keep a persistent “Preview” label until the final result arrives. A reconnect can replay an older event after a newer one; compare request identity and sequence number before updating state. A stream may close without a completion event, so treat transport closure as an incomplete outcome and offer retry or recovery rather than silently declaring success.
Another common failure is displaying the requested preview count as progress. If three previews were requested but only one arrived before completion, “33%” falsely suggests that two thirds of the work remains. If an application wants to describe actual latency, measure timestamps from the request and event stream. Do not derive them from preview indices. Record first-preview latency, final latency, cancellation rate, and preview decode failures separately: each reveals a different experience problem.
Decision scenario
Suppose an editor requests three partial images. The first preview arrives at 1.8 seconds, the second at 4.4 seconds, and the final image arrives at 5.1 seconds. The service does not promise that every requested preview will arrive. Show the first two as provisional previews, then replace the active preview with the completed image. The user received a useful image 3.3 seconds before completion, but no honest completion percentage can be calculated from the two preview events.
The decision is to preserve a stable image area, label previews as provisional, and report “Final image ready” only after the completion event. If the user cancels after the second preview, keep the preview only if the product permits saving partial output; otherwise clear it or retain it with an explicit cancelled status. That policy should be consistent across retries so an old preview cannot appear to belong to a new request.
Learning outcomes
- Map image-generation stream events to queued, generating, preview, and completed UI states.
- Explain why a requested preview count does not support a numeric completion percentage.
- Keep retries, cancellation, stale events, and final-image replacement coherent for each request.
Quantitative model
Let be first-preview latency and be final-image latency, both measured from request submission in seconds. Preview lead time is:
For the example above, . This measures how much earlier feedback became available; it does not estimate remaining generation work.
Implementation pattern
Normalize provider events into a small UI event union at the transport boundary. The reducer below ignores stale attempts and out-of-order events, accepts previews only for the active request, and lets only an explicit completion event install the final image.
typescripttype Phase = 'queued' | 'generating' | 'preview' | 'completed' | 'failed' | 'cancelled';type Job = { requestId: string; lastSequence: number; phase: Phase; previews: Map<number, string>; finalUrl?: string; error?: string };type Update =| { requestId: string; sequence: number; kind: 'generating' }| { requestId: string; sequence: number; kind: 'partial-image'; index: number; url: string }| { requestId: string; sequence: number; kind: 'completed'; url: string }| { requestId: string; sequence: number; kind: 'failed'; message: string }| { requestId: string; sequence: number; kind: 'cancelled' };export function applyUpdate(job: Job, update: Update): Job {if (update.requestId !== job.requestId || update.sequence <= job.lastSequence) return job;if (job.phase === 'completed' || job.phase === 'failed' || job.phase === 'cancelled') return job;const base = { ...job, lastSequence: update.sequence };switch (update.kind) {case 'generating': return { ...base, phase: 'generating' };case 'partial-image': {if (!Number.isInteger(update.index) || update.index < 0) return { ...base, phase: 'failed', error: 'Invalid preview index' };const previews = new Map(job.previews);previews.set(update.index, update.url);return { ...base, phase: 'preview', previews };}case 'completed': return { ...base, phase: 'completed', finalUrl: update.url };case 'failed': return { ...base, phase: 'failed', error: update.message };case 'cancelled': return { ...base, phase: 'cancelled' };}}