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 tool call index assignment in Delta class

Tim Elfrink802f7011e260
diff --git a/litellm/types/utils.py b/litellm/types/utils.py
index 289291bde08..228677a17a7 100644
--- a/litellm/types/utils.py
+++ b/litellm/types/utils.py
@@ -754,10 +754,12 @@ class Delta(OpenAIObject):
self.function_call = function_call
if tool_calls is not None and isinstance(tool_calls, list):
self.tool_calls = []
+ current_index = 0
for tool_call in tool_calls:
if isinstance(tool_call, dict):
if tool_call.get("index", None) is None:
- tool_call["index"] = 0
+ tool_call["index"] = current_index
+ current_index += 1
self.tool_calls.append(ChatCompletionDeltaToolCall(**tool_call))
elif isinstance(tool_call, ChatCompletionDeltaToolCall):
self.tool_calls.append(tool_call)