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
fix(utils.py): fix cost tracking for vertex ai partner models
Krrish Dholakia185a6857f976
diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.pyindex 852f1a2d920..83a88410ea8 100644--- a/litellm/litellm_core_utils/litellm_logging.py+++ b/litellm/litellm_core_utils/litellm_logging.py@@ -231,6 +231,9 @@ class Logging:):self.custom_pricing = True+ if "custom_llm_provider" in self.model_call_details:+ self.custom_llm_provider = self.model_call_details["custom_llm_provider"]+def _pre_call(self, input, api_key, model=None, additional_args={}):"""Common helper function across the sync + async pre-call functiondiff --git a/litellm/tests/test_amazing_vertex_completion.py b/litellm/tests/test_amazing_vertex_completion.pyindex e2d35c9720a..f4304a07a8b 100644--- a/litellm/tests/test_amazing_vertex_completion.py+++ b/litellm/tests/test_amazing_vertex_completion.py@@ -940,7 +940,7 @@ async def test_partner_models_httpx(model, sync_mode):print(f"response: {response}")- assert response._hidden_params["response_cost"] > 0+ assert isinstance(response._hidden_params["response_cost"], float)except litellm.RateLimitError as e:passexcept Exception as e:diff --git a/litellm/utils.py b/litellm/utils.pyindex 84b15cb1954..1e9a0e87c9a 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -4938,6 +4938,8 @@ def get_model_info(model: str, custom_llm_provider: Optional[str] = None) -> Modif custom_llm_provider is not None and custom_llm_provider == "vertex_ai":if "meta/" + model in litellm.vertex_llama3_models:model = "meta/" + model+ elif model + "@latest" in litellm.vertex_mistral_models:+ model = model + "@latest"##########################if custom_llm_provider is None:# Get custom_llm_provider