Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class LiteLLMOnlineRequestProcessor(BaseOnlineRequestProcessor):
def __init__(self, config: OnlineRequestProcessorConfig):
"""Initialize the LiteLLMOnlineRequestProcessor."""
super().__init__(config)
if self.config.base_url is not None:
litellm.api_base = self.config.base_url
# NOTE: Removed global litellm.api_base assignment - now passed per-request
# to allow multiple LLM instances with different base_urls
self.client = instructor.from_litellm(litellm.acompletion)
self.header_based_max_requests_per_minute, self.header_based_max_tokens_per_minute = self.get_header_based_rate_limits()

Expand Down Expand Up @@ -185,6 +185,7 @@ def test_call(self):
completion = litellm.completion(
model=self.config.model,
messages=[{"role": "user", "content": "hi"}], # Some models (e.g. Claude) require an non-empty message to get rate limits.
api_base=self.config.base_url, # Pass api_base per-request
**self.config.generation_params,
)
# Try the method of caculating cost
Expand Down Expand Up @@ -252,6 +253,10 @@ def create_api_specific_request_online(self, generic_request: GenericRequest) ->
for key, value in generic_request.generation_params.items():
request[key] = value

# Pass api_base per-request instead of globally
if self.config.base_url is not None:
request["api_base"] = self.config.base_url

# Add safety settings for Gemini models
if "gemini" in generic_request.model.lower():
request["safety_settings"] = [
Expand Down