Suggested timeouts
Reasoning models think before they answer, and one request can run for several minutes. Examples:
gpt-6-solandgpt-5.6-solgpt-5.4-proando3-pro(gpt-5.5-prowas retired in October 2026)gemini-3.1-pro-preview
Stream long outputs
A non-streaming request returns only after the whole answer is generated, so your read timeout races the full generation time. With streaming (stream=True), output arrives as it’s generated:
- The first data arrives quickly, and events keep coming after that.
- The read timeout only needs to cover the gap between events; 90–120 seconds is usually enough.
- Total time stays the same, but the connection no longer drops while it waits for the full answer.
Turn off automatic retries for long requests
The official OpenAI Python SDK retries twice by default after a timeout and some other errors. For image and reasoning requests, setmax_retries to 0 and let your own code decide when to retry:
- Python
- Node.js
- cURL
Still timing out after raising the timeout
Work through these in order:1
Confirm the new timeout is in effect
Some frameworks wrap the HTTP client in a timeout of their own. Print the effective settings and make sure you changed the one that’s used.
2
Check every hop
Any hop with a shorter timeout than the generation closes the connection first. Raise each one:
- a reverse proxy you run, such as Nginx, whose
proxy_read_timeoutdefaults to 60 seconds; - your cloud load balancer’s idle timeout;
- your serverless function’s maximum run time;
- your queue worker’s per-job timeout.
3
Tell timeouts apart from rate limits
A dropped connection or read timeout means you didn’t wait long enough. A
429 is a rate or capacity limit and has nothing to do with duration. Retry a 429 a few times with backoff, and contact support if it keeps happening.4
Check the real duration in call logs
Open call logs, find the request’s duration and charge, and set your timeout above it with some headroom.
FAQ
Is a request billed if my client times out?
Yes, if the upstream provider finished generating. The disconnect happens on your side; the gateway and the provider keep going. Non-200 upstream responses, such as429 or 503, aren’t billed. Call logs show the actual charge, and refunds and balance adjustments follow the Terms of Service.
Can I fetch an image by ID after the connection drops?
No. Image endpoints are synchronous, and LaoZhang API doesn’t store generated results by default, so a dropped result is lost. If you need asynchronous behavior, put a task queue in your own backend, as described in Do image APIs return a task ID?The call log shows the image, but my client never gets it
The duration in the call log stops when generation finishes; it doesn’t include sending the image back to your server. A 2K or 4K image returned as Base64 makes a response of several MB, up to about 10 MB. On a slow route between your server and the API host, that download can take minutes or get cut off. Pick the base URL for where your server runs. All three hosts take the same API key and paths:- Servers in Europe or North America that want a direct connection:
api-vip.laozhang.ai. - Servers anywhere else: the default
api.laozhang.ai, notapi-vip.laozhang.ai. api.laozhang.aiis slow or can’t be reached from your network:api2.laozhang.ai.
Why does my browser or image tool say “Failed to fetch”?
If it appears after a fixed wait, often 60 seconds, it’s usually not an API error. The web tool, client, or a proxy in front of it closed the connection first. Image generation often takes longer than 60 seconds, so the gateway keeps generating, bills the request when it finishes, and has nowhere to send the result. Each browser words the error differently:
A result from a request that dropped before you raised the timeout can’t be retrieved, as explained above.