This commit is contained in:
Bartok 2026-10-25 21:23:25 +00:00 • committed by GitHub
commit 2dda87a4b1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 67 additions and 0 deletions

View file

@ -6149,6 +6149,21 @@ def validate_environment(
keys_in_environment = True
else:
missing_keys.append("MOONSHOT_API_KEY")
elif custom_llm_provider == "sambanova":
if "SAMBANOVA_API_KEY" in os.environ:
keys_in_environment = True
else:
missing_keys.append("SAMBANOVA_API_KEY")
elif custom_llm_provider == "hyperbolic":
if "HYPERBOLIC_API_KEY" in os.environ:
keys_in_environment = True
else:
missing_keys.append("HYPERBOLIC_API_KEY")
elif custom_llm_provider == "lambda_ai":
if "LAMBDA_API_KEY" in os.environ:
keys_in_environment = True
else:
missing_keys.append("LAMBDA_API_KEY")
else:
## openai - chatcompletion + text completion
if (

View file

@ -4863,3 +4863,55 @@ def test_is_prompt_caching_valid_prompt_explicit_min_token_count_overrides_model
is_prompt_caching_valid_prompt(model="claude-opus-4-8", messages=PROMPT_CACHE_MESSAGES, min_token_count=8192)
is False
)
class TestValidateEnvironmentProviderKeys:
def test_sambanova_reports_key_present(self):
with patch.dict(os.environ, {"SAMBANOVA_API_KEY": "test-key"}, clear=True):
result = litellm.validate_environment(
model="sambanova/Meta-Llama-3.1-8B-Instruct"
)
assert result["keys_in_environment"] is True
assert "SAMBANOVA_API_KEY" not in result["missing_keys"]
def test_sambanova_reports_key_missing(self):
with patch.dict(os.environ, {}, clear=True):
result = litellm.validate_environment(
model="sambanova/Meta-Llama-3.1-8B-Instruct"
)
assert result["keys_in_environment"] is False
assert "SAMBANOVA_API_KEY" in result["missing_keys"]
def test_hyperbolic_reports_key_present(self):
with patch.dict(
os.environ, {"HYPERBOLIC_API_KEY": "test-key"}, clear=True
):
result = litellm.validate_environment(
model="hyperbolic/meta-llama/Meta-Llama-3.1-70B-Instruct"
)
assert result["keys_in_environment"] is True
assert "HYPERBOLIC_API_KEY" not in result["missing_keys"]
def test_hyperbolic_reports_key_missing(self):
with patch.dict(os.environ, {}, clear=True):
result = litellm.validate_environment(
model="hyperbolic/meta-llama/Meta-Llama-3.1-70B-Instruct"
)
assert result["keys_in_environment"] is False
assert "HYPERBOLIC_API_KEY" in result["missing_keys"]
def test_lambda_ai_reports_key_present(self):
with patch.dict(os.environ, {"LAMBDA_API_KEY": "test-key"}, clear=True):
result = litellm.validate_environment(
model="lambda_ai/llama3.1-70b-instruct-fp8"
)
assert result["keys_in_environment"] is True
assert "LAMBDA_API_KEY" not in result["missing_keys"]
def test_lambda_ai_reports_key_missing(self):
with patch.dict(os.environ, {}, clear=True):
result = litellm.validate_environment(
model="lambda_ai/llama3.1-70b-instruct-fp8"
)
assert result["keys_in_environment"] is False
assert "LAMBDA_API_KEY" in result["missing_keys"]