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
Fix MCP streaming test skip logic and metadata None check (#20428)
jquinter199fbabfb3fd
diff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.pyindex 718773a1b16..8ab4ec15b07 100644--- a/litellm/litellm_core_utils/get_llm_provider_logic.py+++ b/litellm/litellm_core_utils/get_llm_provider_logic.py@@ -51,7 +51,7 @@ def handle_cohere_chat_model_custom_llm_provider(if custom_llm_provider == "cohere" and model in litellm.cohere_chat_models:return model, "cohere_chat"- if "/" in model:+ if model and "/" in model:_custom_llm_provider, _model = model.split("/", 1)if (_custom_llm_provider@@ -84,7 +84,7 @@ def handle_anthropic_text_model_custom_llm_provider():return model, "anthropic_text"- if "/" in model:+ if model and "/" in model:_custom_llm_provider, _model = model.split("/", 1)if (_custom_llm_provider@@ -113,6 +113,12 @@ def get_llm_provider( # noqa: PLR0915Return model, custom_llm_provider, dynamic_api_key, api_base"""try:+ # Early validation - model is required+ if model is None:+ raise ValueError(+ "model parameter is required but was None. Please provide a valid model name."+ )+if litellm.LiteLLMProxyChatConfig._should_use_litellm_proxy_by_default(litellm_params=litellm_params):diff --git a/litellm/utils.py b/litellm/utils.pyindex 0fa5436d98d..3fbc2ce1dc2 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -2008,9 +2008,9 @@ def client(original_function): # noqa: PLR0915kwargs["model"] = context_window_fallback_dict[model]return await original_function(*args, **kwargs)elif call_type == CallTypes.aresponses.value:- _is_litellm_router_call = "model_group" in kwargs.get(+ _is_litellm_router_call = "model_group" in (kwargs.get("metadata", {}- ) # check if call from litellm.router/proxy+ ) or {}) # check if call from litellm.router/proxyif (num_retries and not _is_litellm_router_calldiff --git a/tests/mcp_tests/test_aresponses_api_with_mcp.py b/tests/mcp_tests/test_aresponses_api_with_mcp.pyindex a7bbfef14af..bae0b15dfec 100644--- a/tests/mcp_tests/test_aresponses_api_with_mcp.py+++ b/tests/mcp_tests/test_aresponses_api_with_mcp.py@@ -683,8 +683,8 @@ async def test_streaming_responses_api_with_mcp_tools(Return the user the result of request 2"""- # Skip test if required API keys are not set- if ("anthropic" in model.lower() or "claude" in model.lower()) and not os.getenv("ANTHROPIC_API_KEY"):+ # Skip test if API keys are not set for the respective models+ if ("claude" in model.lower() or "anthropic" in model.lower()) and not os.getenv("ANTHROPIC_API_KEY"):pytest.skip("ANTHROPIC_API_KEY not set, skipping anthropic model test")if ("gpt" in model.lower() or "openai" in model.lower()) and not os.getenv("OPENAI_API_KEY"):pytest.skip("OPENAI_API_KEY not set, skipping openai model test")