Skip to content

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]

fix(bedrock): ensure toolUse.input is always a dict when converting from OpenAI format (#18414)

LouisSharkea8a94988fc5
diff --git a/litellm/litellm_core_utils/prompt_templates/factory.py b/litellm/litellm_core_utils/prompt_templates/factory.py
index f359dbbb707..0c331e43038 100644
--- a/litellm/litellm_core_utils/prompt_templates/factory.py
+++ b/litellm/litellm_core_utils/prompt_templates/factory.py
@@ -3176,6 +3176,11 @@ def _convert_to_bedrock_tool_call_invoke(
id = tool["id"]
name = tool["function"].get("name", "")
arguments = tool["function"].get("arguments", "")
+ arguments_dict = json.loads(arguments) if arguments else {}
+ # Ensure arguments_dict is always a dict (Bedrock requires toolUse.input to be an object)
+ # When some providers return arguments: '""' (JSON-encoded empty string), json.loads returns ""
+ if not isinstance(arguments_dict, dict):
+ arguments_dict = {}
if not arguments or not arguments.strip():
arguments_dict = {}
else: