Skip to content
Open
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
9 changes: 7 additions & 2 deletions py_zerox/pyzerox/models/modellitellm.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ def system_prompt(self, prompt: str) -> None:
## custom method on top of BaseModel
def validate_environment(self) -> None:
"""Validates the environment variables required for the model."""
env_config = litellm.validate_environment(model=self.model)
env_config = litellm.validate_environment(
model=self.model,
api_key=self.kwargs.get("api_key"),
api_base=self.kwargs.get("api_base"),
api_version=self.kwargs.get("api_version"),
)

if not env_config["keys_in_environment"]:
raise MissingEnvironmentVariables(extra_info=env_config)
Expand All @@ -64,7 +69,7 @@ def validate_model(self) -> None:

def validate_access(self) -> None:
"""Validates access to the model -> if environment variables are set correctly with correct values."""
if not litellm.check_valid_key(model=self.model,api_key=None):
if not litellm.check_valid_key(model=self.model, api_key=self.kwargs.get("api_key")):
raise ModelAccessError(extra_info={"model": self.model})


Expand Down