From 2a138a202f034ffec3bc919e39c9f71dd61a3f0f Mon Sep 17 00:00:00 2001 From: Lucas Rothman <51925729+lucasrothman@users.noreply.github.com> Date: Thu, 8 Jan 2026 10:02:47 -0800 Subject: [PATCH] fix: properly use litellm api keys (#18832) --- litellm/responses/main.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/litellm/responses/main.py b/litellm/responses/main.py index 8177b177fe..07fc3cb02c 100644 --- a/litellm/responses/main.py +++ b/litellm/responses/main.py @@ -577,7 +577,13 @@ def responses( api_base=litellm_params.api_base, api_key=litellm_params.api_key, ) - + + # Use dynamic credentials from get_llm_provider (e.g., when use_litellm_proxy=True) + if dynamic_api_key is not None: + litellm_params.api_key = dynamic_api_key + if dynamic_api_base is not None: + litellm_params.api_base = dynamic_api_base + ######################################################### # Update input with provider-specific file IDs if managed files are used ######################################################### @@ -1483,6 +1489,12 @@ def compact_responses( api_key=litellm_params.api_key, ) + # Use dynamic credentials from get_llm_provider (e.g., when use_litellm_proxy=True) + if dynamic_api_key is not None: + litellm_params.api_key = dynamic_api_key + if dynamic_api_base is not None: + litellm_params.api_base = dynamic_api_base + if custom_llm_provider is None: raise ValueError("custom_llm_provider is required but passed as None")