From 7241b4e9b505ea433563a88916cece2d062cd063 Mon Sep 17 00:00:00 2001 From: AlexsanderHamir Date: Mon, 17 Nov 2025 12:59:48 -0800 Subject: [PATCH] add: comment above optimization For anybody that would change this value for whatever reason, the comment makes the tradeoff clear. --- litellm/proxy/proxy_server.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/litellm/proxy/proxy_server.py b/litellm/proxy/proxy_server.py index 16988205530..da592c90720 100644 --- a/litellm/proxy/proxy_server.py +++ b/litellm/proxy/proxy_server.py @@ -5236,6 +5236,10 @@ async def moderations( async def _audio_speech_chunk_generator( _response: HttpxBinaryResponseContent, ) -> AsyncGenerator[bytes, None]: + # chunk_size has a big impact on latency, it can't be too small or too large + # too small: latency is high + # too large: latency is low, but memory usage is high + # 8192 is a good compromise _generator = await _response.aiter_bytes(chunk_size=8192) async for chunk in _generator: yield chunk