diff --git a/litellm/llms/gemini/count_tokens/handler.py b/litellm/llms/gemini/count_tokens/handler.py index 4d6c7fd886..fdb77452d4 100644 --- a/litellm/llms/gemini/count_tokens/handler.py +++ b/litellm/llms/gemini/count_tokens/handler.py @@ -30,6 +30,10 @@ class GoogleAIStudioTokenCounter: from google.genai.types import FunctionResponse + # Handle None or empty contents + if not contents: + return contents + cleaned_contents = copy.deepcopy(contents) for content in cleaned_contents: