Facebook Pixel

How do you design a status API for long-running generation?

Expose durable job progress and terminal outcomes without making the browser hold one request open indefinitely.

How do you design a status API for long-running generation?

A status API lets the interface reconnect to work that continues independently. It should describe the application’s job state consistently across reloads and devices.

Return useful state

Include the job identifier, stage or status, relevant timestamps, and a result reference only when available. Distinguish waiting, processing, failure, and completion. If progress cannot be measured accurately, return a truthful stage instead of an invented percentage.

Control polling and visibility

Define how often the client checks, when it stops, and what it does on temporary network failure. Enforce ownership on every lookup. Avoid leaking private provider payloads in status responses. Test reloading during generation and returning after completion. A status request failure should not automatically change the actual job to failed; it may only mean the browser could not retrieve the current state.

No. The network or status endpoint may be unavailable while the worker continues.

At a terminal state or when the view no longer needs updates, according to the application’s behavior.

No. Publish a usable result reference only after required storage and validation succeed.

Ready to master AI completely?

Want to upskill yourself, crack your next interview, and get your dream job? Join our comprehensive course to dive deeper with high-quality video tutorials, solve interview questions, and a premium community.