From 39762983b10bbe7f2cbcf26384963a66bff24e1f Mon Sep 17 00:00:00 2001 From: Cesar Garcia <128240629+Chesars@users.noreply.github.com> Date: Wed, 4 Mar 2026 18:51:01 -0300 Subject: [PATCH] Update litellm/proxy/response_api_endpoints/endpoints.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --- litellm/proxy/response_api_endpoints/endpoints.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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):