Why there’s no task ID
- Image endpoints keep the same synchronous behavior as the upstream APIs, with no queue in between that would add latency or change behavior.
- LaoZhang API doesn’t store prompts or generated images by default, so there’s nothing to fetch by ID afterward. See how LaoZhang API handles data and logs.
- With a long enough timeout and an open connection, nearly all image requests finish within a single call.
What to do instead
1
Set the timeout high enough
Give your client and any proxy 360 seconds, or 600 seconds for 4K output or many reference images. See API request timeouts for setup and troubleshooting.
2
Turn off SDK retries
An automatic retry after a timeout generates and bills the image again. Set
max_retries to 0 in the OpenAI SDK and let your code decide when to retry.3
Record every job in your backend
Give each request your own job ID and store the prompt, parameters, result, or error in your database. If the frontend disconnects, the backend still has the full record.
Add an async queue in your backend
If your frontend can’t wait on a long request, split the flow:- The frontend submits a job; the backend saves it and returns a job ID.
- A backend worker calls LaoZhang API synchronously and writes the result back.
- The frontend polls your backend with the job ID, or receives the result over a WebSocket.
pip install openai and set LAOZHANG_API_KEY first. save_image handles both Base64 and URL responses; each model’s guide lists the format it returns.
You create and store the job ID; LaoZhang API only handles the synchronous generation step.