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]

Update litellm/proxy/response_api_endpoints/endpoints.py

Cesar Garcia39762983b10b
diff --git a/litellm/proxy/response_api_endpoints/endpoints.py b/litellm/proxy/response_api_endpoints/endpoints.py
index abfc25acbc8..f7d2153c5dd 100644
--- a/litellm/proxy/response_api_endpoints/endpoints.py
+++ b/litellm/proxy/response_api_endpoints/endpoints.py
@@ -469,6 +469,7 @@ async def count_response_input_tokens(
if isinstance(input_data, str):
messages.append({"role": "user", "content": input_data})
+ elif isinstance(input_data, list):
elif isinstance(input_data, list):
for item in input_data:
if isinstance(item, dict):
@@ -480,6 +481,18 @@ async def count_response_input_tokens(
"content": item.get("output", ""),
"tool_call_id": item.get("call_id", ""),
})
+ elif item.get("type") == "function_call":
+ messages.append({
+ "role": "assistant",
+ "tool_calls": [{
+ "id": item.get("call_id", ""),
+ "type": "function",
+ "function": {
+ "name": item.get("name", ""),
+ "arguments": item.get("arguments", ""),
+ },
+ }],
+ })
else:
messages.append({"role": role, "content": content})
elif isinstance(item, str):