mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-14 23:21:35 +00:00
fix(utils): report missing ZAI_API_KEY in validate_environment for zai models
This commit is contained in:
parent
b6dbda48f9
commit
f0420734f3
2 changed files with 23 additions and 0 deletions
|
|
@ -6139,6 +6139,11 @@ def validate_environment(
|
|||
keys_in_environment = True
|
||||
else:
|
||||
missing_keys.append("MOONSHOT_API_KEY")
|
||||
elif custom_llm_provider == "zai":
|
||||
if "ZAI_API_KEY" in os.environ:
|
||||
keys_in_environment = True
|
||||
else:
|
||||
missing_keys.append("ZAI_API_KEY")
|
||||
else:
|
||||
## openai - chatcompletion + text completion
|
||||
if (
|
||||
|
|
|
|||
|
|
@ -4710,3 +4710,21 @@ class TestValidateEnvironmentTencent:
|
|||
assert "TENCENT_API_KEY" in result["missing_keys"]
|
||||
|
||||
|
||||
class TestValidateEnvironmentZai:
|
||||
"""Tests that validate_environment resolves ZAI_API_KEY for the zai provider."""
|
||||
|
||||
def test_reports_key_present(self):
|
||||
with patch.dict(os.environ, {"ZAI_API_KEY": "sk-zai"}):
|
||||
result = litellm.validate_environment(model="zai/glm-5.1")
|
||||
|
||||
assert result["keys_in_environment"] is True
|
||||
assert result["missing_keys"] == []
|
||||
|
||||
def test_reports_key_missing(self):
|
||||
with patch.dict(os.environ, {}, clear=True):
|
||||
result = litellm.validate_environment(model="zai/glm-5.1")
|
||||
|
||||
assert result["keys_in_environment"] is False
|
||||
assert "ZAI_API_KEY" in result["missing_keys"]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue