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(utils.py): check if tools is iterable before indexing into it

Krrish Dholakia52b1ca292cd9
diff --git a/litellm/utils.py b/litellm/utils.py
index ec1370c3076..411d2509d5f 100644
--- a/litellm/utils.py
+++ b/litellm/utils.py
@@ -2772,7 +2772,9 @@ def get_optional_params(
message=f"Function calling is not supported by {custom_llm_provider}.",
)
- if "tools" in non_default_params:
+ if "tools" in non_default_params and isinstance(
+ non_default_params, list
+ ): # fixes https://github.com/BerriAI/litellm/issues/4933
tools = non_default_params["tools"]
for (
tool