OpenAI API Request Timed Out / 504 Gateway Timeout
Quick answer
Timeouts usually come from slow long generations hitting a client or proxy timeout. Stream the response, lower max_tokens and raise client timeouts.
Most likely fix: Stream the response
How to fix it
Try these in order — the most common fix is first.
1. Stream the response
- Set stream: true so tokens arrive immediately
Did this fix it?2. Lower max_tokens and shorten prompts
- Cap output length
Did this fix it?3. Raise timeouts in the chain
- SDK timeout option, load balancer and serverless limits
Did this fix it?4. Use background mode or Batch for long jobs
- Poll for results instead of holding one connection
Did this fix it?
Symptoms
APITimeoutError "Request timed out" or 504 from a proxy.
Why it happens
- Long outputs or reasoning models
- Client or gateway timeout too short
- Serverless function limits
- Network or proxy issues
This guide also covers
- openai api request timed out
- openai 504 gateway timeout
- openai apitimeouterror
Still not working?
If OpenAI keeps failing, you're not alone. See every OpenAI problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usThe same problem in other apps
All ai & editing tools not working guides →
- Gemini Image Generation Not Working (Google Gemini)
Other OpenAI errors
- OpenAI API 429 Too Many Requests (Rate Limit)
- OpenAI API Error: You Exceeded Your Current Quota (insufficient_quota)
- OpenAI API 401 Incorrect API Key Provided
- OpenAI API 500 and 503 Server Errors (server_is_overloaded)
- OpenAI API Credits Expired or Balance Disappeared
- OpenAI "Your Organization Must Be Verified" 403 Error
- OpenAI API model_not_found: Model Does Not Exist or You Do Not Have Access
- OpenAI API context_length_exceeded: Maximum Context Length Error