feat: add Zhipu API support and set glm-4.7-flash as default model

This commit is contained in:
Manus AI
2026-02-01 14:36:15 -05:00
parent 959c4dadf8
commit 2dd284661d
3 changed files with 22 additions and 5 deletions

View File

@@ -21,7 +21,7 @@ class LiteLLMProvider(LLMProvider):
self,
api_key: str | None = None,
api_base: str | None = None,
default_model: str = "anthropic/claude-opus-4-5"
default_model: str = "glm-4.7-flash"
):
super().__init__(api_key, api_base)
self.default_model = default_model
@@ -41,6 +41,8 @@ class LiteLLMProvider(LLMProvider):
os.environ.setdefault("ANTHROPIC_API_KEY", api_key)
elif "openai" in default_model or "gpt" in default_model:
os.environ.setdefault("OPENAI_API_KEY", api_key)
elif "zhipu" in default_model or "glm" in default_model or "zai" in default_model:
os.environ.setdefault("ZHIPUAI_API_KEY", api_key)
if api_base:
litellm.api_base = api_base
@@ -75,6 +77,15 @@ class LiteLLMProvider(LLMProvider):
if self.is_openrouter and not model.startswith("openrouter/"):
model = f"openrouter/{model}"
# For Zhipu/Z.ai, ensure prefix is present
# Handle cases like "glm-4.7-flash" -> "zhipu/glm-4.7-flash"
if ("glm" in model.lower() or "zhipu" in model.lower()) and not (
model.startswith("zhipu/") or
model.startswith("zai/") or
model.startswith("openrouter/")
):
model = f"zhipu/{model}"
kwargs: dict[str, Any] = {
"model": model,
"messages": messages,