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
Merge remote-tracking branch 'origin/litellm_internal_staging' into litellm_bedrock_orphaned_tools_fix
Kent0eaf75b181fa
diff --cc litellm/__init__.pyindex 02d13864258,1dfd146a00e..40c61f9e7c5--- a/litellm/__init__.py+++ b/litellm/__init__.py@@@ -224,9 -242,8 +242,9 @@@ token: Optional[str] =)telemetry = Truemax_tokens: int = DEFAULT_MAX_TOKENS # OpenAI Defaults- drop_params = bool(os.getenv("LITELLM_DROP_PARAMS", False))+ drop_params = drop_params_env_flag(os.environ, verbose_logger)modify_params = bool(os.getenv("LITELLM_MODIFY_PARAMS", False))+bedrock_neutralize_orphaned_tool_blocks: bool = Trueuse_chat_completions_url_for_anthropic_messages: bool = bool(os.getenv("LITELLM_USE_CHAT_COMPLETIONS_URL_FOR_ANTHROPIC_MESSAGES", False)) # When True, routes OpenAI /v1/messages requests to chat/completions instead of the Responses APIdiff --cc litellm/llms/bedrock/chat/converse_transformation.pyindex b890742a5d1,fa18361e44c..d0d97ecb7f0--- a/litellm/llms/bedrock/chat/converse_transformation.py+++ b/litellm/llms/bedrock/chat/converse_transformation.py@@@ -1551,12 -1602,27 +1675,13 @@@ class AmazonConverseConfig(BaseConfig)def _transform_request_helper(self,model: str,- system_content_blocks: List[SystemContentBlock],+ system_content_blocks: list[SystemContentBlock],optional_params: dict,- messages: Optional[List[AllMessageValues]] = None,- headers: Optional[dict] = None,+ messages: list[AllMessageValues] | None = None,+ headers: dict | None = None,drop_params: bool = False,+ litellm_params: Mapping[str, object] | None = None,) -> CommonRequestObject:- ## VALIDATE REQUEST- """- Bedrock doesn't support tool calling without `tools=` param specified.- """- if "tools" not in optional_params and messages is not None and has_tool_call_blocks(messages):- if litellm.modify_params:- optional_params["tools"] = add_dummy_tool(custom_llm_provider="bedrock_converse")- else:- raise litellm.UnsupportedParamsError(- message="Bedrock doesn't support tool calling without `tools=` param specified. Pass `tools=` param OR set `litellm.modify_params = True` // `litellm_settings::modify_params: True` to add dummy tool to the request.",- model="",- llm_provider="bedrock",- )-# Drop thinking param if thinking is enabled but thinking_blocks are missing# This prevents the error: "Expected thinking or redacted_thinking, but found tool_use"#diff --cc tests/local_testing/test_function_calling.pyindex 3d32e2e24f9,5752f29daef..3a5e2209f1e--- a/tests/local_testing/test_function_calling.py+++ b/tests/local_testing/test_function_calling.py@@@ -298,13 -293,22 +292,13 @@@ _PARALLEL_TOOL_HISTORY_MESSAGES =@pytest.mark.parametrize(- "model, messages, expect_unsupported_params_error",+ "model, messages",[- # Bedrock Converse still requires modify_params to inject the dummy tool.- (- "us.anthropic.claude-sonnet-4-5-20250929-v1:0",- _PARALLEL_TOOL_HISTORY_MESSAGES,- True,- ),- # Anthropic Messages API: dummy tool is injected without modify_params.- (- "claude-haiku-4-5-20251001",- _PARALLEL_TOOL_HISTORY_MESSAGES,- False,- ),+ # Anthropic Messages API: a dummy tool is injected without modify_params,+ # so tool history with no tools= completes instead of raising.+ ("claude-haiku-4-5-20251001", _PARALLEL_TOOL_HISTORY_MESSAGES),(- "anthropic.claude-3-sonnet-20240229-v1:0",+ "us.anthropic.claude-sonnet-4-5-20250929-v1:0",[{"role": "user",