diff --git a/litellm/litellm_core_utils/allowed_tools_tool_choice.py b/litellm/litellm_core_utils/allowed_tools_tool_choice.py index 860d0932112..f633c4a5bfc 100644 --- a/litellm/litellm_core_utils/allowed_tools_tool_choice.py +++ b/litellm/litellm_core_utils/allowed_tools_tool_choice.py @@ -124,18 +124,23 @@ def is_allowed_tools_choice(tool_choice: object) -> bool: return False -def _accepts_allowed_tools(custom_llm_provider: str, model: str) -> bool: +def _accepts_allowed_tools(custom_llm_provider: str, model: str, base_model: str | None) -> bool: match custom_llm_provider: case "azure_ai": from litellm.llms.azure_ai.common_utils import azure_ai_serves_openai_chat_model - return azure_ai_serves_openai_chat_model(model) + return azure_ai_serves_openai_chat_model(model, base_model) case _: return custom_llm_provider in PROVIDERS_ACCEPTING_ALLOWED_TOOLS def tool_choice_for_provider( - tool_choice: _ToolChoiceT, *, custom_llm_provider: str, model: str, drop_params: bool + tool_choice: _ToolChoiceT, + *, + custom_llm_provider: str, + model: str, + drop_params: bool, + base_model: str | None = None, ) -> _ToolChoiceT | Mapping[str, JsonValue] | None: if not is_allowed_tools_choice(tool_choice): return tool_choice @@ -149,7 +154,7 @@ def tool_choice_for_provider( model=model, llm_provider=custom_llm_provider, ) from exc - if _accepts_allowed_tools(custom_llm_provider, model): + if _accepts_allowed_tools(custom_llm_provider, model, base_model): return dict(chat_allowed_tool_choice(allowed_tool_choice)) if drop_params: return None diff --git a/litellm/llms/azure_ai/common_utils.py b/litellm/llms/azure_ai/common_utils.py index 7722059aa2c..8055f7b1b22 100644 --- a/litellm/llms/azure_ai/common_utils.py +++ b/litellm/llms/azure_ai/common_utils.py @@ -151,9 +151,11 @@ def azure_ai_supports_native_responses(model: str | None, api_base: str | None) return AzureFoundryModelInfo.get_azure_ai_route(model) == "default" -def azure_ai_serves_openai_chat_model(model: str) -> bool: +def azure_ai_serves_openai_chat_model(model: str, base_model: str | None) -> bool: + served_model: Final = (base_model or model).rsplit("/", 1)[-1] return ( - AzureFoundryModelInfo.get_azure_ai_route(model) == "default" and model in litellm.open_ai_chat_completion_models + AzureFoundryModelInfo.get_azure_ai_route(model) == "default" + and served_model in litellm.open_ai_chat_completion_models ) diff --git a/litellm/main.py b/litellm/main.py index e282cec5700..adda4a7d680 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -5711,7 +5711,7 @@ def completion( ), ) routing_kwargs: Final = cast("Mapping[str, object]", kwargs) # cast-ok: kwargs is the untyped request dict - drops_unsupported_params: Final = ( + drop_unsupported_reasoning: Final = ( litellm.drop_params is True or normalize_drop_params(routing_kwargs.get("drop_params")) is True ) drops_tool_choice: Final = drop_policy(routing_kwargs).drops("tool_choice") @@ -5727,7 +5727,7 @@ def completion( custom_llm_provider=custom_llm_provider, deployment_model_info=routing_kwargs.get("model_info"), model_group=reasoning_model_group, - drop_params=drops_unsupported_params, + drop_params=drop_unsupported_reasoning, ) resolved_reasoning_effort: Final = chat_reasoning.effort.value resolved_output_config: Final = chat_reasoning.output_config @@ -5867,6 +5867,7 @@ def completion( custom_llm_provider=custom_llm_provider, model=model, drop_params=drops_tool_choice, + base_model=base_model if isinstance(base_model, str) else None, ), "max_retries": max_retries, "logprobs": logprobs, diff --git a/tests/unit/test_main.py b/tests/unit/test_main.py index 69e119ba208..cb80b1fc686 100644 --- a/tests/unit/test_main.py +++ b/tests/unit/test_main.py @@ -5541,6 +5541,10 @@ def _mock_chat_completion(respx_mock: respx.MockRouter) -> respx.Route: ("openai/gpt-4.1-mini", {"api_base": "http://localhost:12346/v1"}), ("litellm_proxy/gpt-4.1-mini", {"api_base": "http://localhost:12346/v1"}), ("azure_ai/gpt-4.1-mini", {"api_base": "http://localhost:12346/models"}), + ( + "azure_ai/my-luna-deployment", + {"api_base": "http://localhost:12346/models", "base_model": "azure_ai/gpt-4.1-mini"}, + ), ("azure/gpt-4.1-mini", {"api_base": "http://localhost:12346", "api_version": "2025-04-01-preview"}), ], )