@@ -45,8 +45,8 @@ class LiteLLMOnlineRequestProcessor(BaseOnlineRequestProcessor):
4545 def __init__ (self , config : OnlineRequestProcessorConfig ):
4646 """Initialize the LiteLLMOnlineRequestProcessor."""
4747 super ().__init__ (config )
48- if self . config . base_url is not None :
49- litellm . api_base = self . config . base_url
48+ # NOTE: Removed global litellm.api_base assignment - now passed per-request
49+ # to allow multiple LLM instances with different base_urls
5050 self .client = instructor .from_litellm (litellm .acompletion )
5151 self .header_based_max_requests_per_minute , self .header_based_max_tokens_per_minute = self .get_header_based_rate_limits ()
5252
@@ -185,6 +185,7 @@ def test_call(self):
185185 completion = litellm .completion (
186186 model = self .config .model ,
187187 messages = [{"role" : "user" , "content" : "hi" }], # Some models (e.g. Claude) require an non-empty message to get rate limits.
188+ api_base = self .config .base_url , # Pass api_base per-request
188189 ** self .config .generation_params ,
189190 )
190191 # Try the method of caculating cost
@@ -252,6 +253,10 @@ def create_api_specific_request_online(self, generic_request: GenericRequest) ->
252253 for key , value in generic_request .generation_params .items ():
253254 request [key ] = value
254255
256+ # Pass api_base per-request instead of globally
257+ if self .config .base_url is not None :
258+ request ["api_base" ] = self .config .base_url
259+
255260 # Add safety settings for Gemini models
256261 if "gemini" in generic_request .model .lower ():
257262 request ["safety_settings" ] = [
0 commit comments