The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
test fixes
Ishaan Jaffereaa7e61f57f9
diff --git a/litellm/__init__.py b/litellm/__init__.pyindex 10ea521cc9c..0e88873d1f5 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -1305,6 +1305,7 @@ from .llms.friendliai.chat.transformation import FriendliaiChatConfigfrom .llms.jina_ai.embedding.transformation import JinaAIEmbeddingConfigfrom .llms.xai.chat.transformation import XAIChatConfigfrom .llms.xai.common_utils import XAIModelInfo+from .llms.zai.chat.transformation import ZAIChatConfigfrom .llms.aiml.chat.transformation import AIMLChatConfigfrom .llms.volcengine.chat.transformation import (VolcEngineChatConfig as VolcEngineConfig,diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.pyindex 955858cd6ef..1673f8ae483 100644--- a/litellm/litellm_core_utils/get_llm_provider_logic.py+++ b/litellm/litellm_core_utils/get_llm_provider_logic.py@@ -687,12 +687,12 @@ def _get_openai_compatible_provider_info( # noqa: PLR0915api_base, api_key)elif custom_llm_provider == "zai":- api_base = (- api_base- or get_secret_str("ZAI_API_BASE")- or "https://api.z.ai/api/paas/v4"+ (+ api_base,+ dynamic_api_key,+ ) = litellm.ZAIChatConfig()._get_openai_compatible_provider_info(+ api_base, api_key)- dynamic_api_key = api_key or get_secret_str("ZAI_API_KEY")elif custom_llm_provider == "together_ai":api_base = (api_basediff --git a/litellm/llms/zai/__init__.py b/litellm/llms/zai/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/litellm/llms/zai/chat/__init__.py b/litellm/llms/zai/chat/__init__.pynew file mode 100644index 00000000000..e69de29bb2ddiff --git a/litellm/llms/zai/chat/transformation.py b/litellm/llms/zai/chat/transformation.pynew file mode 100644index 00000000000..47b314d4e0d--- /dev/null+++ b/litellm/llms/zai/chat/transformation.py@@ -0,0 +1,33 @@+from typing import Optional, Tuple++from litellm.secret_managers.main import get_secret_str++from ...openai.chat.gpt_transformation import OpenAIGPTConfig++ZAI_API_BASE = "https://api.z.ai/api/paas/v4"+++class ZAIChatConfig(OpenAIGPTConfig):+ @property+ def custom_llm_provider(self) -> Optional[str]:+ return "zai"++ def _get_openai_compatible_provider_info(+ self, api_base: Optional[str], api_key: Optional[str]+ ) -> Tuple[Optional[str], Optional[str]]:+ api_base = api_base or get_secret_str("ZAI_API_BASE") or ZAI_API_BASE+ dynamic_api_key = api_key or get_secret_str("ZAI_API_KEY")+ return api_base, dynamic_api_key++ def get_supported_openai_params(self, model: str) -> list:+ return [+ "max_tokens",+ "stream",+ "stream_options",+ "temperature",+ "top_p",+ "stop",+ "tools",+ "tool_choice",+ ]+diff --git a/litellm/types/services.py b/litellm/types/services.pyindex 812ff5821a2..bb34f817f29 100644--- a/litellm/types/services.py+++ b/litellm/types/services.py@@ -38,7 +38,6 @@ class ServiceTypes(str, enum.Enum):REDIS_DAILY_ORG_SPEND_UPDATE_QUEUE = "redis_daily_org_spend_update_queue"REDIS_DAILY_TEAM_SPEND_UPDATE_QUEUE = "redis_daily_team_spend_update_queue"REDIS_DAILY_TAG_SPEND_UPDATE_QUEUE = "redis_daily_tag_spend_update_queue"- REDIS_DAILY_END_USER_SPEND_UPDATE_QUEUE = "redis_daily_end_user_spend_update_queue"# spend update queue - current spend of key, user, teamIN_MEMORY_SPEND_UPDATE_QUEUE = "in_memory_spend_update_queue"REDIS_SPEND_UPDATE_QUEUE = "redis_spend_update_queue"diff --git a/litellm/utils.py b/litellm/utils.pyindex 1d10ecce016..244eedc9cb4 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -7052,6 +7052,8 @@ class ProviderConfigManager:return litellm.DatabricksConfig()elif litellm.LlmProviders.XAI == provider:return litellm.XAIChatConfig()+ elif litellm.LlmProviders.ZAI == provider:+ return litellm.ZAIChatConfig()elif litellm.LlmProviders.LAMBDA_AI == provider:return litellm.LambdaAIChatConfig()elif litellm.LlmProviders.LLAMA == provider:diff --git a/tests/litellm_utils_tests/test_utils.py b/tests/litellm_utils_tests/test_utils.pyindex c75edba8500..a679fa4e4cb 100644--- a/tests/litellm_utils_tests/test_utils.py+++ b/tests/litellm_utils_tests/test_utils.py@@ -1065,7 +1065,7 @@ def test_parse_content_for_reasoning(content, expected_reasoning, expected_conte("gemini/gemini-1.5-pro", True),("predibase/llama3-8b-instruct", True),("gpt-3.5-turbo", False),- ("groq/llama-3.3-70b-versatile", True),+ ("groq/llama-3.3-70b-versatile", False),],)def test_supports_response_schema(model, expected_bool):diff --git a/tests/proxy_unit_tests/test_jwt.py b/tests/proxy_unit_tests/test_jwt.pyindex ed75a56361a..b8df16d135b 100644--- a/tests/proxy_unit_tests/test_jwt.py+++ b/tests/proxy_unit_tests/test_jwt.py@@ -1389,7 +1389,9 @@ async def test_custom_validate_called():jwt_handler = MagicMock()jwt_handler.litellm_jwtauth = MagicMock(- custom_validate=mock_custom_validate, allowed_routes=["/chat/completions"]+ custom_validate=mock_custom_validate,+ allowed_routes=["/chat/completions"],+ oidc_userinfo_enabled=False,)jwt_handler.auth_jwt = AsyncMock(return_value={"sub": "test_user"})