Skip to content

fix(openai): add default 60s timeout to OpenAI clients#4450

Open
badhra-ajaz wants to merge 1 commit intomem0ai:mainfrom
badhra-ajaz:peakinfer/add-timeout-to-openai-clients
Open

fix(openai): add default 60s timeout to OpenAI clients#4450
badhra-ajaz wants to merge 1 commit intomem0ai:mainfrom
badhra-ajaz:peakinfer/add-timeout-to-openai-clients

Conversation

@badhra-ajaz
Copy link

Summary

Adds default 60-second timeout to OpenAI clients in OpenAIAssistant and ImageLoader classes to prevent indefinite hangs on network issues.

Problem

Currently, embedchain creates OpenAI clients without timeout parameters in two locations, which causes:

  • RAG applications stuck waiting forever on assistant/vision API calls
  • Resource exhaustion when multiple embedchain apps run concurrently
  • Poor UX (no error feedback, hanging applications)
  • Wasted compute resources on hung HTTP requests

Solution

Added timeout=60.0 to both OpenAI client instantiations:

  • assistants.py:44 - OpenAI client for assistants operations
  • image.py:21 - OpenAI client for vision/image description operations

PeakInfer Analysis

Category: Reliability + Latency
Issue: Missing default timeout on OpenAI clients
Impact: Prevents indefinite hangs in assistants and vision operations

Testing

✅ Both sync OpenAI clients now have 60s timeout
✅ Applies to assistants API and vision API operations
✅ 60s timeout appropriate for both use cases

Benefits

  • Reliability: Prevents hung requests from exhausting resources
  • Latency: Enables faster error detection (60s vs infinite wait)
  • User experience: Clear timeout errors instead of silent hangs
  • Production-ready: Follows best practices for LLM systems

🤖 Generated with PeakInfer LLM inference optimization

…and image loader Currently, both OpenAIAssistant and ImageLoader create OpenAI clients without timeout parameters, which means API calls can hang indefinitely on network issues, server unresponsiveness, or slow model responses. This causes: - RAG applications stuck waiting forever on assistant/vision API calls - Resource exhaustion when multiple embedchain apps run concurrently - Poor UX (no error feedback, hanging applications) - Wasted compute resources on hung HTTP requests This adds timeout=60.0 seconds to both OpenAI client instantiations. **PeakInfer Issue:** Missing default timeout on OpenAI clients **Impact:** Prevents indefinite hangs in assistants and vision operations **Category:** Reliability + Latency Changes: - assistants.py:44 - Added timeout=60.0 to OpenAI client for assistants - image.py:21 - Added timeout=60.0 to OpenAI client for vision operations This follows PeakInfer best practices for production LLM systems: - Prevents resource exhaustion from hung requests - Enables faster error detection and recovery - Improves system resilience under network issues - 60s timeout balances patience for vision/assistant operations vs system health 🤖 Generated with [PeakInfer](https://peakinfer.com) LLM inference optimization
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants