ElevenLabs Text-to-Speech Streaming Fails with httpx.ReadTimeout and ApiError 500 in Production
Description
When using ElevenLabs’ text_to_speech_stream method in production, the request frequently fails with httpx.ReadTimeout followed by an elevenlabs.core.api_error.ApiError. The error seems to occur during long-running streaming requests.
This is affecting production workloads where speech synthesis needs to run in parallel across multiple threads. The error leads to unhandled exceptions and stops audio generation mid-stream.
Code example
Exception in thread Thread-2589 (convert_to_speech_eleven): Traceback (most recent call last): ... httpcore.ReadTimeout: The read operation timed out
During handling of the above exception, another exception occurred:
httpx.ReadTimeout: The read operation timed out
During streaming:
elevenlabs.core.api_error.ApiError: headers: {...} status_code: 500 body: {'status': 'internal_server_error', 'message': 'Internal Server error. All such crashes are reported to us automatically.'}
Additional context
- This seems related to streaming responses timing out under certain conditions.
- Other ElevenLabs endpoints appear to work fine; only text_to_speech_stream is failing.
- Increasing timeout in httpx did not reliably resolve the issue.
- Errors are intermittent but frequent under load (about 1 in 5–10 requests).
Could this be a client library bug (stream handling), or is the ElevenLabs API intermittently returning 500s under concurrency? Any guidance on workarounds (e.g., retry logic, recommended timeouts, or best practices for streaming requests) would be appreciated.