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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add image tokens in usage object
Sameer Kankute5713eae75cff
diff --git a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.pyindex 84a5958ee5e..b1810b40cf9 100644--- a/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py+++ b/litellm/llms/vertex_ai/gemini/vertex_and_google_ai_studio_gemini.py@@ -1476,6 +1476,7 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):cached_tokens: Optional[int] = Noneaudio_tokens: Optional[int] = Nonetext_tokens: Optional[int] = None+ image_tokens: Optional[int] = Noneprompt_tokens_details: Optional[PromptTokensDetailsWrapper] = Nonereasoning_tokens: Optional[int] = Noneresponse_tokens: Optional[int] = None@@ -1526,6 +1527,8 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):audio_tokens = detail.get("tokenCount", 0)elif detail["modality"] == "TEXT":text_tokens = detail.get("tokenCount", 0)+ elif detail["modality"] == "IMAGE":+ image_tokens = detail.get("tokenCount", 0)if "thoughtsTokenCount" in usage_metadata:reasoning_tokens = usage_metadata["thoughtsTokenCount"]# Also add reasoning tokens to response_tokens_details@@ -1546,6 +1549,7 @@ class VertexGeminiConfig(VertexAIBaseConfig, BaseConfig):cached_tokens=cached_tokens,audio_tokens=audio_tokens,text_tokens=text_tokens,+ image_tokens=image_tokens,)completion_tokens = response_tokens or completion_response["usageMetadata"].get(