From a115df8ea3685a08c0ab53cbdae7eed475d89972 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Sat, 30 May 2026 03:31:14 +0000 Subject: [PATCH] fix(batch_rate_limiter): guard model-embedded credential lookup on llm_router presence --- litellm/proxy/hooks/batch_rate_limiter.py | 27 ++++++++++++----------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/litellm/proxy/hooks/batch_rate_limiter.py b/litellm/proxy/hooks/batch_rate_limiter.py index baeadc98c33..3e0f5a523f4 100644 --- a/litellm/proxy/hooks/batch_rate_limiter.py +++ b/litellm/proxy/hooks/batch_rate_limiter.py @@ -302,19 +302,20 @@ class _PROXY_BatchRateLimiter(CustomLogger): model_from_file_id = decode_model_from_file_id(file_id) if model_from_file_id: - try: - credentials = get_credentials_for_model( - llm_router=llm_router, - model_id=model_from_file_id, - operation_context="batch input file read (rate limiting)", - ) - fetch_kwargs.update(_extract_file_access_credentials(credentials)) - fetch_kwargs["model"] = model_from_file_id - provider = credentials.get("custom_llm_provider") - if provider: - fetch_kwargs["custom_llm_provider"] = provider - except HTTPException: - pass + if llm_router is not None: + try: + credentials = get_credentials_for_model( + llm_router=llm_router, + model_id=model_from_file_id, + operation_context="batch input file read (rate limiting)", + ) + fetch_kwargs.update(_extract_file_access_credentials(credentials)) + fetch_kwargs["model"] = model_from_file_id + provider = credentials.get("custom_llm_provider") + if provider: + fetch_kwargs["custom_llm_provider"] = provider + except HTTPException: + pass return get_original_file_id(file_id), fetch_kwargs request_model = data.get("model")