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(vertex_ai): apply regional endpoint uplift to cost tracking
mateo-berrib39a339b7d9e
diff --git a/basedpyright-code-budget.json b/basedpyright-code-budget.jsonindex 1ce71c5bd2c..32c77146b42 100644--- a/basedpyright-code-budget.json+++ b/basedpyright-code-budget.json@@ -57,7 +57,7 @@"limit": 5663},"reportMissingTypeArgument": {- "limit": 15557+ "limit": 15556},"reportMissingTypeStubs": {"limit": 40@@ -105,13 +105,13 @@"limit": 109},"reportUnknownMemberType": {- "limit": 39043+ "limit": 39030},"reportUnknownParameterType": {- "limit": 19887+ "limit": 19886},"reportUnknownVariableType": {- "limit": 30574+ "limit": 30573},"reportUnnecessaryCast": {"limit": 117diff --git a/ci_cd/generate_model_prices_schema.py b/ci_cd/generate_model_prices_schema.pyindex 153fbc0fdc2..252e3675329 100644--- a/ci_cd/generate_model_prices_schema.py+++ b/ci_cd/generate_model_prices_schema.py@@ -145,6 +145,11 @@ NUMBER_KEYS: dict[str, JsonSchema] = {"minimum": 1,"description": "Multiplier applied to all token costs for US data residency (e.g. 1.10 = +10%).",},+ "regional_endpoint_uplift_multiplier": {+ "type": "number",+ "minimum": 1,+ "description": "Multiplier applied to all token costs when served from a non-global Vertex AI endpoint (e.g. 1.10 = +10%).",+ },}COST_DESCRIPTIONS: dict[str, str] = {diff --git a/litellm/cost_calculator.py b/litellm/cost_calculator.pyindex 7d7380665d3..8f7cd09d364 100644--- a/litellm/cost_calculator.py+++ b/litellm/cost_calculator.py@@ -327,6 +327,8 @@ def cost_per_token(service_tier: str | None = None, # for OpenAI service tier pricing### DATA RESIDENCY ###data_residency: str | None = None, # for OpenAI regional-processing uplift (e.g. "eu", "us")+ ### VERTEX LOCATION ###+ vertex_location: str | None = None, # for Vertex AI regional-endpoint uplift (e.g. "us-east5", "global")response: Any | None = None,### REQUEST MODEL ###request_model: str | None = None, # original request model for router detection@@ -587,6 +589,7 @@ def cost_per_token(prompt_characters=prompt_characters,completion_characters=completion_characters,usage=usage_block,+ vertex_location=vertex_location,)elif cost_router == "cost_per_token":return google_cost_per_token(@@ -594,6 +597,7 @@ def cost_per_token(custom_llm_provider=custom_llm_provider,usage=usage_block,service_tier=service_tier,+ vertex_location=vertex_location,)elif custom_llm_provider == "anthropic":return anthropic_cost_per_token(model=model, usage=usage_block, service_tier=service_tier)@@ -1071,6 +1075,7 @@ def _store_cost_breakdown_in_logging_obj(reasoning_cost: float | None = None,service_tier: str | None = None,data_residency: str | None = None,+ vertex_location: str | None = None,) -> None:"""Helper function to store cost breakdown in the logging object.@@ -1090,6 +1095,7 @@ def _store_cost_breakdown_in_logging_obj(margin_total_amount: Total margin added in USDservice_tier: Tier the costs above were priced on, already resolveddata_residency: Region uplift the costs above were priced on, already resolved+ vertex_location: Vertex AI location the costs above were priced on, already resolved"""if litellm_logging_obj is None:return@@ -1113,6 +1119,7 @@ def _store_cost_breakdown_in_logging_obj(reasoning_cost=reasoning_cost,service_tier=service_tier,data_residency=data_residency,+ vertex_location=vertex_location,)except Exception as breakdown_error:@@ -1149,6 +1156,8 @@ def completion_cost(service_tier: str | None = None, # for OpenAI service tier pricing### DATA RESIDENCY ###data_residency: str | None = None, # for OpenAI regional-processing uplift (e.g. "eu", "us")+ ### VERTEX LOCATION ###+ vertex_location: str | None = None, # for Vertex AI regional-endpoint uplift (e.g. "us-east5", "global")) -> float:"""Calculate the cost of a given completion call fot GPT-3.5-turbo, llama2, any litellm supported llm.@@ -1577,6 +1586,7 @@ def completion_cost(rerank_billed_units=rerank_billed_units,service_tier=service_tier,data_residency=data_residency,+ vertex_location=vertex_location,response=completion_response,request_model=request_model_for_cost,)@@ -1664,6 +1674,7 @@ def completion_cost(usage=cost_per_token_usage_object,service_tier=service_tier,data_residency=data_residency,+ vertex_location=vertex_location,)_reasoning_cost = _token_type_breakdown.reasoning_cost_cache_read_cost = _token_type_breakdown.cache_read_cost@@ -1686,6 +1697,7 @@ def completion_cost(reasoning_cost=_reasoning_cost,service_tier=service_tier,data_residency=data_residency,+ vertex_location=vertex_location,)return _final_cost@@ -1765,6 +1777,8 @@ def response_cost_calculator(service_tier: str | None = None, # for OpenAI service tier pricing### DATA RESIDENCY ###data_residency: str | None = None, # for OpenAI regional-processing uplift (e.g. "eu", "us")+ ### VERTEX LOCATION ###+ vertex_location: str | None = None, # for Vertex AI regional-endpoint uplift (e.g. "us-east5", "global")) -> float:"""Returns@@ -1797,6 +1811,7 @@ def response_cost_calculator(litellm_logging_obj=litellm_logging_obj,service_tier=service_tier,data_residency=data_residency,+ vertex_location=vertex_location,)return response_costexcept Exception as e:diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.pyindex 946110abf9e..e97abcf0af6 100644--- a/litellm/litellm_core_utils/litellm_logging.py+++ b/litellm/litellm_core_utils/litellm_logging.py@@ -13,7 +13,7 @@ import tracebackfrom collections.abc import Callable, Mapping, Sequencefrom datetime import datetime as dt_objectfrom functools import lru_cache-from types import TracebackType+from types import MappingProxyType, TracebackTypefrom typing import TYPE_CHECKING, Any, Final, Literal, Optional, Union, castfrom httpx import Response@@ -372,6 +372,24 @@ def _published_pricing(deployment_model: str | None) -> ModelInfo | None:return None+def _resolve_vertex_location_for_cost(+ custom_llm_provider: str | None,+ litellm_params: Mapping[str, object] | None,+ model: str,+) -> str | None:+ """+ The Vertex AI location a request was served from, resolved the same way+ dispatch resolves it, so regional deployments price with the+ regional-endpoint uplift. None for non-Vertex providers.+ """+ if custom_llm_provider is None or not custom_llm_provider.startswith("vertex_ai"):+ return None+ from litellm.llms.vertex_ai.vertex_llm_base import VertexBase++ configured_location: Final = VertexBase.safe_get_vertex_ai_location(litellm_params or MappingProxyType({}))+ return VertexBase.get_vertex_region(configured_location, model)++class Logging(LiteLLMLoggingBaseClass):global \supabaseClient, \@@ -1432,6 +1450,7 @@ class Logging(LiteLLMLoggingBaseClass):reasoning_cost: float | None = None,service_tier: str | None = None,data_residency: str | None = None,+ vertex_location: str | None = None,) -> None:"""Helper method to store cost breakdown in the logging object.@@ -1450,6 +1469,7 @@ class Logging(LiteLLMLoggingBaseClass):margin_total_amount: Total margin added in USDservice_tier: Tier the costs above were priced on, already resolveddata_residency: Region uplift the costs above were priced on, already resolved+ vertex_location: Vertex AI location the costs above were priced on, already resolved"""self.cost_breakdown = CostBreakdown(@@ -1459,6 +1479,7 @@ class Logging(LiteLLMLoggingBaseClass):tool_usage_cost=cost_for_built_in_tools_cost_usd_dollar,service_tier=service_tier,data_residency=data_residency,+ vertex_location=vertex_location,)if cache_read_cost is not None and cache_read_cost > 0:self.cost_breakdown["cache_read_cost"] = cache_read_cost@@ -1574,6 +1595,11 @@ class Logging(LiteLLMLoggingBaseClass):if hasattr(self, "litellm_params") and self.litellm_paramselse None),+ "vertex_location": _resolve_vertex_location_for_cost(+ custom_llm_provider=self.model_call_details.get("custom_llm_provider", None),+ litellm_params=(self.litellm_params if hasattr(self, "litellm_params") else None),+ model=litellm_model_name or self.model,+ ),}except Exception as e: # error creating kwargs for cost calculationdebug_info = StandardLoggingModelCostFailureDebugInformation(diff --git a/litellm/litellm_core_utils/llm_cost_calc/utils.py b/litellm/litellm_core_utils/llm_cost_calc/utils.pyindex f73c4942a1c..dec35d16ea0 100644--- a/litellm/litellm_core_utils/llm_cost_calc/utils.py+++ b/litellm/litellm_core_utils/llm_cost_calc/utils.py@@ -757,6 +757,33 @@ def _get_regional_uplift_multiplier(model_info: ModelInfo, data_residency: str |return 1.0+def get_vertex_regional_endpoint_uplift(model_info: ModelInfo, vertex_location: str | None) -> float:+ """+ Resolve the per-model uplift multiplier for Vertex AI non-global (regional and+ multi-region) endpoints.++ Google prices every non-global endpoint at a flat premium over the global+ endpoint (e.g. 1.10 = +10%) on all token types for the models that carry+ regional pricing. The multiplier is stored on the model entry as+ ``regional_endpoint_uplift_multiplier``.++ Returns 1.0 (no uplift) when ``vertex_location`` is ``None`` or ``"global"``,+ or when the model has no multiplier configured.+ """+ if vertex_location is None or vertex_location.lower() == "global":+ return 1.0+ multiplier: Final = model_info.get("regional_endpoint_uplift_multiplier")+ if multiplier is None:+ return 1.0+ try:+ return float(cast(float, multiplier))+ except (TypeError, ValueError):+ verbose_logger.exception(+ "Invalid regional_endpoint_uplift_multiplier for model; defaulting to 1.0",+ )+ return 1.0++def get_provider_specific_geo_multiplier(model_info: ModelInfo, usage: Usage) -> float:"""Resolve the provider-specific regional pricing multiplier for the geo the@@ -798,6 +825,7 @@ def generic_cost_per_token(service_tier: str | None = None,data_residency: str | None = None,model_info: ModelInfo | None = None,+ vertex_location: str | None = None,) -> tuple[float, float]:"""Calculates the cost per token for a given model, prompt tokens, and completion tokens.@@ -809,6 +837,9 @@ def generic_cost_per_token(- usage: LiteLLM Usage block, containing anthropic caching information- data_residency: optional OpenAI data-residency region (e.g. "eu", "us"),used to apply the per-model regional-processing uplift multiplier.+ - vertex_location: optional Vertex AI location the request was served from+ (e.g. "us-east5", "global"), used to apply the per-model+ regional-endpoint uplift multiplier when non-global.Returns:Tuple[float, float] - prompt_cost_in_usd, completion_cost_in_usd@@ -968,6 +999,14 @@ def generic_cost_per_token(prompt_cost *= upliftcompletion_cost *= uplift+ ## VERTEX REGIONAL-ENDPOINT UPLIFT+ # Applied as a flat multiplier across all token costs for the request+ # when the Vertex AI endpoint serving it is non-global.+ vertex_uplift: Final = get_vertex_regional_endpoint_uplift(model_info, vertex_location)+ if vertex_uplift != 1.0:+ prompt_cost *= vertex_uplift+ completion_cost *= vertex_uplift+return prompt_cost, completion_cost@@ -988,6 +1027,7 @@ def get_token_type_cost_breakdown(usage: Usage,service_tier: str | None = None,data_residency: str | None = None,+ vertex_location: str | None = None,) -> TokenTypeCostBreakdown:"""Provider-agnostic cost of reasoning and cache tokens, derived from the usage@@ -1069,6 +1109,14 @@ def get_token_type_cost_breakdown(cache_read_cost *= upliftcache_creation_cost *= uplift+ # Same flat uplift for Vertex AI non-global endpoints, keeping per-type+ # costs reconciled with the totals for regional Vertex deployments.+ vertex_uplift: Final = get_vertex_regional_endpoint_uplift(model_info, vertex_location)+ if vertex_uplift != 1.0:+ reasoning_cost *= vertex_uplift+ cache_read_cost *= vertex_uplift+ cache_creation_cost *= vertex_uplift+# Mirror the provider-specific geo uplift (e.g. Anthropic us: 1.1) the totals# apply, so cache and reasoning line items stay reconciled with them.geo_multiplier: Final = get_provider_specific_geo_multiplier(model_info=model_info, usage=usage)diff --git a/litellm/llms/vertex_ai/cost_calculator.py b/litellm/llms/vertex_ai/cost_calculator.pyindex 86a5bb207ec..a9f5d77350c 100644--- a/litellm/llms/vertex_ai/cost_calculator.py+++ b/litellm/llms/vertex_ai/cost_calculator.py@@ -7,6 +7,7 @@ from litellm import verbose_loggerfrom litellm.litellm_core_utils.llm_cost_calc.utils import (_is_above_128k,generic_cost_per_token,+ get_vertex_regional_endpoint_uplift,)from litellm.types.utils import ModelInfo, Usage@@ -63,6 +64,7 @@ def cost_per_character(usage: Usage,prompt_characters: float | None = None,completion_characters: float | None = None,+ vertex_location: str | None = None,) -> tuple[float, float]:"""Calculates the cost per character for a given VertexAI model, input messages, and response object.@@ -72,6 +74,8 @@ def cost_per_character(- custom_llm_provider: str, "vertex_ai-*"- prompt_characters: float, the number of input characters- completion_characters: float, the number of output characters+ - vertex_location: the Vertex AI location serving the request; non-global+ locations apply the model's regional-endpoint uplift multiplierReturns:Tuple[float, float] - prompt_cost_in_usd, completion_cost_in_usd@@ -79,8 +83,6 @@ def cost_per_character(Raises:Exception if model requires >128k pricing, but model cost not mapped"""- model_info = litellm.get_model_info(model=model, custom_llm_provider=custom_llm_provider)-## GET MODEL INFOmodel_info = litellm.get_model_info(model=model, custom_llm_provider=custom_llm_provider)@@ -162,7 +164,10 @@ def cost_per_character(usage=usage,)- return prompt_cost, completion_cost+ # Applied once here; the cost_per_token fallbacks above are called without+ # vertex_location so the uplift can never compound.+ vertex_uplift: Final = get_vertex_regional_endpoint_uplift(model_info, vertex_location)+ return prompt_cost * vertex_uplift, completion_cost * vertex_upliftdef _handle_128k_pricing(@@ -196,6 +201,7 @@ def cost_per_token(custom_llm_provider: str,usage: Usage,service_tier: str | None = None,+ vertex_location: str | None = None,) -> tuple[float, float]:"""Calculates the cost per token for a given model, prompt tokens, and completion tokens.@@ -207,6 +213,8 @@ def cost_per_token(- completion_tokens: float, the number of output tokens- service_tier: optional tier derived from Gemini trafficType("priority" for ON_DEMAND_PRIORITY, "flex" for FLEX/batch).+ - vertex_location: the Vertex AI location serving the request; non-global+ locations apply the model's regional-endpoint uplift multiplierReturns:Tuple[float, float] - prompt_cost_in_usd, completion_cost_in_usd@@ -222,14 +230,17 @@ def cost_per_token(input_cost_per_token_above_128k_tokens: Final = model_info.get("input_cost_per_token_above_128k_tokens")output_cost_per_token_above_128k_tokens: Final = model_info.get("output_cost_per_token_above_128k_tokens")if input_cost_per_token_above_128k_tokens is not None or output_cost_per_token_above_128k_tokens is not None:- return _handle_128k_pricing(+ prompt_cost_128k, completion_cost_128k = _handle_128k_pricing(model_info=model_info,usage=usage,)+ vertex_uplift: Final = get_vertex_regional_endpoint_uplift(model_info, vertex_location)+ return prompt_cost_128k * vertex_uplift, completion_cost_128k * vertex_upliftreturn generic_cost_per_token(model=model,custom_llm_provider=custom_llm_provider,usage=usage,service_tier=service_tier,+ vertex_location=vertex_location,)diff --git a/litellm/llms/vertex_ai/vertex_llm_base.py b/litellm/llms/vertex_ai/vertex_llm_base.pyindex 445e34966a9..0b3c003a60a 100644--- a/litellm/llms/vertex_ai/vertex_llm_base.py+++ b/litellm/llms/vertex_ai/vertex_llm_base.py@@ -8,6 +8,7 @@ import asyncioimport jsonimport osimport threading+from collections.abc import Mappingfrom typing import TYPE_CHECKING, Any, Final, Literalfrom urllib.parse import urlparse@@ -68,7 +69,8 @@ class VertexBase:# re-acquire it without deadlocking the current thread.self._sync_refresh_lock = threading.RLock()- def get_vertex_region(self, vertex_region: str | None, model: str) -> str:+ @staticmethod+ def get_vertex_region(vertex_region: str | None, model: str) -> str:import litellm# Try to get supported_regions directly from model_cost@@ -1191,7 +1193,7 @@ class VertexBase:)@staticmethod- def safe_get_vertex_ai_location(litellm_params: dict) -> str | None:+ def safe_get_vertex_ai_location(litellm_params: Mapping[str, object]) -> str | None:"""Safely get Vertex AI location without mutating the litellm_params dict.@@ -1204,10 +1206,7 @@ class VertexBase:Returns:Vertex AI location/region or None"""- return (- litellm_params.get("vertex_location")- or litellm_params.get("vertex_ai_location")- or litellm.vertex_location- or get_secret_str("VERTEXAI_LOCATION")- or get_secret_str("VERTEX_LOCATION")- )+ for configured in (litellm_params.get("vertex_location"), litellm_params.get("vertex_ai_location")):+ if isinstance(configured, str) and configured:+ return configured+ return litellm.vertex_location or get_secret_str("VERTEXAI_LOCATION") or get_secret_str("VERTEX_LOCATION")diff --git a/litellm/model_prices_and_context_window_backup.json b/litellm/model_prices_and_context_window_backup.jsonindex 07f9027313b..52f1763a5ba 100644--- a/litellm/model_prices_and_context_window_backup.json+++ b/litellm/model_prices_and_context_window_backup.json@@ -19624,6 +19624,7 @@"mode": "chat","output_cost_per_reasoning_token": 9e-06,"output_cost_per_token": 9e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing","supported_endpoints": ["/v1/chat/completions",@@ -19679,6 +19680,7 @@"output_cost_per_token": 3.75e-06,"output_cost_per_token_batches": 1.875e-06,"output_cost_per_token_flex": 1.875e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing","supported_endpoints": ["/v1/chat/completions",@@ -19733,6 +19735,7 @@"output_cost_per_token": 3.75e-06,"output_cost_per_token_batches": 1.875e-06,"output_cost_per_token_flex": 1.875e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing","supported_endpoints": ["/v1/chat/completions",@@ -38685,6 +38688,7 @@"max_tokens": 8192,"mode": "chat","output_cost_per_token": 5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/haiku-4-5","supports_assistant_prefill": true,"supports_function_calling": true,@@ -38708,6 +38712,7 @@"max_tokens": 8192,"mode": "chat","output_cost_per_token": 5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/haiku-4-5","supports_assistant_prefill": true,"supports_function_calling": true,@@ -38923,6 +38928,7 @@"max_tokens": 64000,"mode": "chat","output_cost_per_token": 2.5e-05,+ "regional_endpoint_uplift_multiplier": 1.1,"search_context_cost_per_query": {"search_context_size_high": 0.01,"search_context_size_low": 0.01,@@ -38951,6 +38957,7 @@"max_tokens": 64000,"mode": "chat","output_cost_per_token": 2.5e-05,+ "regional_endpoint_uplift_multiplier": 1.1,"search_context_cost_per_query": {"search_context_size_high": 0.01,"search_context_size_low": 0.01,@@ -38970,6 +38977,7 @@"prompt_cache_min_tokens": 4096},"vertex_ai/claude-opus-4-6": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39000,6 +39008,7 @@"prompt_cache_min_tokens": 4096},"vertex_ai/claude-opus-4-6@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39030,6 +39039,7 @@"prompt_cache_min_tokens": 4096},"vertex_ai/claude-opus-4-7": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39061,6 +39071,7 @@"prompt_cache_min_tokens": 2048},"vertex_ai/claude-opus-4-7@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39092,6 +39103,7 @@"prompt_cache_min_tokens": 2048},"vertex_ai/claude-fable-5": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 1.25e-05,"cache_creation_input_token_cost_above_1hr": 2e-05,@@ -39123,6 +39135,7 @@"supports_max_reasoning_effort": true},"vertex_ai/claude-fable-5@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 1.25e-05,"cache_creation_input_token_cost_above_1hr": 2e-05,@@ -39154,6 +39167,7 @@"supports_max_reasoning_effort": true},"vertex_ai/claude-opus-5": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39186,6 +39200,7 @@"prompt_cache_min_tokens": 512},"vertex_ai/claude-opus-5@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39218,6 +39233,7 @@"prompt_cache_min_tokens": 512},"vertex_ai/claude-opus-4-8": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39250,6 +39266,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-opus-4-8@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39298,6 +39315,7 @@"mode": "chat","output_cost_per_token": 1.5e-05,"output_cost_per_token_batches": 7.5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"supports_assistant_prefill": true,"supports_computer_use": true,"supports_function_calling": true,@@ -39310,6 +39328,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-sonnet-5": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 2.5e-06,"cache_creation_input_token_cost_above_1hr": 4e-06,@@ -39342,6 +39361,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-sonnet-4-6": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 3.75e-06,"cache_creation_input_token_cost_above_1hr": 6e-06,@@ -39388,6 +39408,7 @@"mode": "chat","output_cost_per_token": 1.5e-05,"output_cost_per_token_batches": 7.5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"supports_assistant_prefill": true,"supports_computer_use": true,"supports_function_calling": true,@@ -39794,6 +39815,7 @@"output_cost_per_token_batches": 7.5e-07,"output_cost_per_token_flex": 7.5e-07,"output_cost_per_token_priority": 2.7e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models","supported_endpoints": ["/v1/chat/completions",@@ -39849,6 +39871,7 @@"output_cost_per_token_batches": 1.25e-06,"output_cost_per_token_flex": 1.25e-06,"output_cost_per_token_priority": 4.5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models","supported_endpoints": ["/v1/chat/completions",@@ -47014,6 +47037,7 @@}},"vertex_ai/claude-sonnet-5@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 2.5e-06,"cache_creation_input_token_cost_above_1hr": 4e-06,@@ -47046,6 +47070,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-sonnet-4-6@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 3.75e-06,"cache_creation_input_token_cost_above_1hr": 6e-06,diff --git a/litellm/proxy/spend_tracking/savings.py b/litellm/proxy/spend_tracking/savings.pyindex 448723ab3bc..997180efdde 100644--- a/litellm/proxy/spend_tracking/savings.py+++ b/litellm/proxy/spend_tracking/savings.py@@ -130,6 +130,7 @@ class PricingBasis(NamedTuple):service_tier: str | None = Nonedata_residency: str | None = None+ vertex_location: str | None = None_STANDARD_RATES: Final = PricingBasis()@@ -141,8 +142,8 @@ def _pricing_basis(cost_breakdown: Mapping[str, object] | None) -> PricingBasis:Rows written before this field shipped carry neither key, and there is no backfill:they price at standard rates, which is what they already did.- Both values survive a JSON round trip on the way here, so neither is guaranteed to be- a string. `generic_cost_per_token` calls `.lower()` on both without a type check, and+ These values survive a JSON round trip on the way here, so none is guaranteed to be+ a string. `generic_cost_per_token` calls `.lower()` on them without a type check, andthe resulting `AttributeError` would be swallowed into a silent zero by the caller's`except`, so anything that is not a string is dropped here instead."""@@ -150,9 +151,11 @@ def _pricing_basis(cost_breakdown: Mapping[str, object] | None) -> PricingBasis:return _STANDARD_RATESservice_tier: Final = cost_breakdown.get("service_tier")data_residency: Final = cost_breakdown.get("data_residency")+ vertex_location: Final = cost_breakdown.get("vertex_location")return PricingBasis(service_tier=service_tier if isinstance(service_tier, str) else None,data_residency=data_residency if isinstance(data_residency, str) else None,+ vertex_location=vertex_location if isinstance(vertex_location, str) else None,)@@ -193,6 +196,7 @@ def _cost_of_usage(service_tier=basis.service_tier,data_residency=basis.data_residency,model_info=model_info,+ vertex_location=basis.vertex_location,)except Exception as e: # noqa: BLE001 # get_model_info raises bare Exception for unmapped models; degrade to zero savingsverbose_proxy_logger.debug(diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 07005d7f9ad..5f629eb129f 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -248,6 +248,9 @@ class ModelInfoBase(ProviderSpecificModelInfo, total=False):regional_processing_uplift_multiplier_us: (float | None) # OpenAI US data-residency uplift multiplier applied to all token costs (e.g. 1.10 = +10%)+ regional_endpoint_uplift_multiplier: ReadOnly[+ float | None+ ] # Vertex AI non-global (regional) endpoint uplift multiplier applied to all token costs (e.g. 1.10 = +10%)output_cost_per_character: float | None # only for vertex ai modelsoutput_cost_per_audio_token: float | Noneoutput_cost_per_token_above_128k_tokens: float | None # only for vertex ai models@@ -3113,16 +3116,17 @@ class CostBreakdown(TypedDict, total=False):"""Detailed cost breakdown for a request.- ``service_tier`` and ``data_residency`` record the pricing basis the cost was- computed on, not what the caller asked for. A consumer that has to price a- counterfactual against this request (what another model would have charged for- it) needs the same basis to compare like with like, and re-deriving it from the- request is not possible after the fact: the tier the biller used comes from- ``optional_params``, which no log record carries.+ ``service_tier``, ``data_residency``, and ``vertex_location`` record the pricing+ basis the cost was computed on, not what the caller asked for. A consumer that has+ to price a counterfactual against this request (what another model would have+ charged for it) needs the same basis to compare like with like, and re-deriving it+ from the request is not possible after the fact: the tier the biller used comes+ from ``optional_params``, which no log record carries."""service_tier: str | Nonedata_residency: str | None+ vertex_location: ReadOnly[str | None]input_cost: float # Cost of raw (non-cached) input tokens onlycache_read_cost: float # Cost of cache-read tokens (discounted rate)cache_creation_cost: float # Cost of cache-write tokens (premium rate)@@ -3388,6 +3392,7 @@ class CustomPricingLiteLLMParams(MirroredPricingParams):annotation_cost_per_page: float | None = Noneregional_processing_uplift_multiplier_eu: float | None = Noneregional_processing_uplift_multiplier_us: float | None = None+ regional_endpoint_uplift_multiplier: float | None = None@classmethoddef strip_custom_pricing_fields(cls, model_info: dict[str, Any]) -> dict[str, Any]:diff --git a/litellm/utils.py b/litellm/utils.pyindex a7b70c4129a..8be2c98fc68 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -5662,6 +5662,7 @@ def _get_model_info_helper(regional_processing_uplift_multiplier_us=_model_info.get("regional_processing_uplift_multiplier_us", None),+ regional_endpoint_uplift_multiplier=_model_info.get("regional_endpoint_uplift_multiplier", None),output_cost_per_audio_token=_model_info.get("output_cost_per_audio_token", None),output_cost_per_character=_model_info.get("output_cost_per_character", None),output_cost_per_reasoning_token=_model_info.get("output_cost_per_reasoning_token", None),diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex 07f9027313b..52f1763a5ba 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -19624,6 +19624,7 @@"mode": "chat","output_cost_per_reasoning_token": 9e-06,"output_cost_per_token": 9e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing","supported_endpoints": ["/v1/chat/completions",@@ -19679,6 +19680,7 @@"output_cost_per_token": 3.75e-06,"output_cost_per_token_batches": 1.875e-06,"output_cost_per_token_flex": 1.875e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing","supported_endpoints": ["/v1/chat/completions",@@ -19733,6 +19735,7 @@"output_cost_per_token": 3.75e-06,"output_cost_per_token_batches": 1.875e-06,"output_cost_per_token_flex": 1.875e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing","supported_endpoints": ["/v1/chat/completions",@@ -38685,6 +38688,7 @@"max_tokens": 8192,"mode": "chat","output_cost_per_token": 5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/haiku-4-5","supports_assistant_prefill": true,"supports_function_calling": true,@@ -38708,6 +38712,7 @@"max_tokens": 8192,"mode": "chat","output_cost_per_token": 5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/haiku-4-5","supports_assistant_prefill": true,"supports_function_calling": true,@@ -38923,6 +38928,7 @@"max_tokens": 64000,"mode": "chat","output_cost_per_token": 2.5e-05,+ "regional_endpoint_uplift_multiplier": 1.1,"search_context_cost_per_query": {"search_context_size_high": 0.01,"search_context_size_low": 0.01,@@ -38951,6 +38957,7 @@"max_tokens": 64000,"mode": "chat","output_cost_per_token": 2.5e-05,+ "regional_endpoint_uplift_multiplier": 1.1,"search_context_cost_per_query": {"search_context_size_high": 0.01,"search_context_size_low": 0.01,@@ -38970,6 +38977,7 @@"prompt_cache_min_tokens": 4096},"vertex_ai/claude-opus-4-6": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39000,6 +39008,7 @@"prompt_cache_min_tokens": 4096},"vertex_ai/claude-opus-4-6@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39030,6 +39039,7 @@"prompt_cache_min_tokens": 4096},"vertex_ai/claude-opus-4-7": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39061,6 +39071,7 @@"prompt_cache_min_tokens": 2048},"vertex_ai/claude-opus-4-7@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,"cache_creation_input_token_cost_above_1hr": 1e-05,@@ -39092,6 +39103,7 @@"prompt_cache_min_tokens": 2048},"vertex_ai/claude-fable-5": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 1.25e-05,"cache_creation_input_token_cost_above_1hr": 2e-05,@@ -39123,6 +39135,7 @@"supports_max_reasoning_effort": true},"vertex_ai/claude-fable-5@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 1.25e-05,"cache_creation_input_token_cost_above_1hr": 2e-05,@@ -39154,6 +39167,7 @@"supports_max_reasoning_effort": true},"vertex_ai/claude-opus-5": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39186,6 +39200,7 @@"prompt_cache_min_tokens": 512},"vertex_ai/claude-opus-5@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39218,6 +39233,7 @@"prompt_cache_min_tokens": 512},"vertex_ai/claude-opus-4-8": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39250,6 +39266,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-opus-4-8@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 6.25e-06,@@ -39298,6 +39315,7 @@"mode": "chat","output_cost_per_token": 1.5e-05,"output_cost_per_token_batches": 7.5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"supports_assistant_prefill": true,"supports_computer_use": true,"supports_function_calling": true,@@ -39310,6 +39328,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-sonnet-5": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 2.5e-06,"cache_creation_input_token_cost_above_1hr": 4e-06,@@ -39342,6 +39361,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-sonnet-4-6": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 3.75e-06,"cache_creation_input_token_cost_above_1hr": 6e-06,@@ -39388,6 +39408,7 @@"mode": "chat","output_cost_per_token": 1.5e-05,"output_cost_per_token_batches": 7.5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"supports_assistant_prefill": true,"supports_computer_use": true,"supports_function_calling": true,@@ -39794,6 +39815,7 @@"output_cost_per_token_batches": 7.5e-07,"output_cost_per_token_flex": 7.5e-07,"output_cost_per_token_priority": 2.7e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models","supported_endpoints": ["/v1/chat/completions",@@ -39849,6 +39871,7 @@"output_cost_per_token_batches": 1.25e-06,"output_cost_per_token_flex": 1.25e-06,"output_cost_per_token_priority": 4.5e-06,+ "regional_endpoint_uplift_multiplier": 1.1,"source": "https://cloud.google.com/vertex-ai/generative-ai/pricing#gemini-models","supported_endpoints": ["/v1/chat/completions",@@ -47014,6 +47037,7 @@}},"vertex_ai/claude-sonnet-5@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_mid_conversation_system": true,"cache_creation_input_token_cost": 2.5e-06,"cache_creation_input_token_cost_above_1hr": 4e-06,@@ -47046,6 +47070,7 @@"prompt_cache_min_tokens": 1024},"vertex_ai/claude-sonnet-4-6@default": {+ "regional_endpoint_uplift_multiplier": 1.1,"supports_adaptive_thinking": true,"cache_creation_input_token_cost": 3.75e-06,"cache_creation_input_token_cost_above_1hr": 6e-06,diff --git a/model_prices_and_context_window.schema.json b/model_prices_and_context_window.schema.jsonindex cd02fde595f..82854a3b717 100644--- a/model_prices_and_context_window.schema.json+++ b/model_prices_and_context_window.schema.json@@ -514,6 +514,11 @@"type": "object","description": "Provider-internal routing hints (e.g. bedrock_invocation_schema)."},+ "regional_endpoint_uplift_multiplier": {+ "type": "number",+ "minimum": 1,+ "description": "Multiplier applied to all token costs when served from a non-global Vertex AI endpoint (e.g. 1.10 = +10%)."+ },"regional_processing_uplift_multiplier_eu": {"type": "number","minimum": 1,diff --git a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.pyindex 1826f56d667..06be96fefdf 100644--- a/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py+++ b/tests/test_litellm/litellm_core_utils/llm_cost_calc/test_llm_cost_calc_utils.py@@ -2324,6 +2324,87 @@ def test_data_residency_composes_with_service_tier(_local_model_cost_map):assert priority_eu_total == pytest.approx(priority_base_total * 1.10, rel=1e-9)[email protected]("model", ["gemini-3.5-flash", "claude-haiku-4-5@20251001"])[email protected]("vertex_location", ["us-central1", "us-east5", "europe-west1", "asia-southeast1"])+def test_vertex_regional_location_applies_uplift(vertex_location, model, _local_model_cost_map):+ """Google bills every non-global Vertex endpoint at 1.1x the global rate for GA+ Gemini 3+ and regional-pricing Claude models, so a request served from a regional+ location must cost 1.1x what the same usage costs on the global endpoint."""+ from litellm.types.utils import Usage++ usage = Usage(prompt_tokens=1000, completion_tokens=500, total_tokens=1500)++ base = generic_cost_per_token(model=model, usage=usage, custom_llm_provider="vertex_ai")+ regional = generic_cost_per_token(+ model=model,+ usage=usage,+ custom_llm_provider="vertex_ai",+ vertex_location=vertex_location,+ )++ base_total = base[0] + base[1]+ regional_total = regional[0] + regional[1]++ assert base_total > 0+ assert regional_total == pytest.approx(base_total * 1.10, rel=1e-9)+ assert regional[0] == pytest.approx(base[0] * 1.10, rel=1e-9)+ assert regional[1] == pytest.approx(base[1] * 1.10, rel=1e-9)++[email protected]("vertex_location", [None, "global", "GLOBAL"])+def test_vertex_global_or_absent_location_no_uplift(vertex_location, _local_model_cost_map):+ """The global endpoint prices at the base rate, whatever the casing, and an+ unresolved location must never uplift."""+ from litellm.types.utils import Usage++ usage = Usage(prompt_tokens=1000, completion_tokens=500, total_tokens=1500)++ base = generic_cost_per_token(+ model="claude-haiku-4-5@20251001", usage=usage, custom_llm_provider="vertex_ai"+ )+ located = generic_cost_per_token(+ model="claude-haiku-4-5@20251001",+ usage=usage,+ custom_llm_provider="vertex_ai",+ vertex_location=vertex_location,+ )++ assert base == located++[email protected]("model", ["claude-opus-4-1", "gemini-2.0-flash-001"])+def test_vertex_location_no_uplift_for_uniformly_priced_model(model, _local_model_cost_map):+ """Models Google prices uniformly across endpoints (Gemini 2.x, Claude Opus 4.1+ and older) carry no multiplier and must not move with the location."""+ from litellm.types.utils import Usage++ usage = Usage(prompt_tokens=1000, completion_tokens=500, total_tokens=1500)++ base = generic_cost_per_token(model=model, usage=usage, custom_llm_provider="vertex_ai")+ regional = generic_cost_per_token(+ model=model,+ usage=usage,+ custom_llm_provider="vertex_ai",+ vertex_location="us-east5",+ )++ assert base == regional, f"{model} should not have a regional-endpoint uplift"+++def test_vertex_uplift_invalid_multiplier_defaults_to_one():+ """A malformed multiplier in the cost map degrades to base pricing, never raises."""+ from litellm.litellm_core_utils.llm_cost_calc.utils import (+ get_vertex_regional_endpoint_uplift,+ )++ assert (+ get_vertex_regional_endpoint_uplift(+ {"regional_endpoint_uplift_multiplier": "not-a-number"}, "us-east5"+ )+ == 1.0+ )++def test_priority_service_tier_above_threshold_uses_priority_tier_rates_for_cached_tokens(_local_model_cost_map,):@@ -2877,6 +2958,57 @@ def test_token_type_cost_breakdown_applies_regional_uplift():assert text_input_cost + eu.cache_read_cost == pytest.approx(prompt_cost)+def test_token_type_cost_breakdown_applies_vertex_regional_uplift():+ """+ Non-global Vertex endpoints apply a flat 1.1x uplift to every token cost. The+ per-type breakdown must apply the same uplift via vertex_location so it stays+ reconciled with the uplifted input_cost/output_cost totals, instead of being+ logged at the global rate.+ """+ os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"+ litellm.model_cost = litellm.get_model_cost_map(url="")++ model = "claude-haiku-4-5@20251001"+ custom_llm_provider = "vertex_ai"+ usage = Usage(+ prompt_tokens=1000,+ completion_tokens=500,+ total_tokens=1500,+ prompt_tokens_details=PromptTokensDetailsWrapper(+ cached_tokens=400, text_tokens=600+ ),+ )++ model_info = litellm.get_model_info(+ model=model, custom_llm_provider=custom_llm_provider+ )+ uplift = model_info["regional_endpoint_uplift_multiplier"]+ assert uplift > 1.0++ base = get_token_type_cost_breakdown(+ model=model, custom_llm_provider=custom_llm_provider, usage=usage+ )+ regional = get_token_type_cost_breakdown(+ model=model,+ custom_llm_provider=custom_llm_provider,+ usage=usage,+ vertex_location="us-east5",+ )++ assert base.cache_read_cost > 0+ assert regional.cache_read_cost == pytest.approx(base.cache_read_cost * uplift)++ # The uplifted breakdown must still reconcile with the uplifted totals.+ prompt_cost, _completion_cost = generic_cost_per_token(+ model=model,+ usage=usage,+ custom_llm_provider=custom_llm_provider,+ vertex_location="us-east5",+ )+ text_input_cost = 600 * model_info["input_cost_per_token"] * uplift+ assert text_input_cost + regional.cache_read_cost == pytest.approx(prompt_cost)++def test_token_type_cost_breakdown_applies_anthropic_geo_multiplier(monkeypatch):"""Anthropic's regional (geo) uplift lives in provider_specific_entry and isdiff --git a/tests/test_litellm/litellm_core_utils/test_litellm_logging.py b/tests/test_litellm/litellm_core_utils/test_litellm_logging.pyindex 54016470f8b..01e5ec26b1e 100644--- a/tests/test_litellm/litellm_core_utils/test_litellm_logging.py+++ b/tests/test_litellm/litellm_core_utils/test_litellm_logging.py@@ -4958,3 +4958,80 @@ def test_pre_call_redacts_and_masks_raw_request(logging_obj):raw_api_base = logging_obj.model_call_details["raw_request_typed_dict"]["raw_request_api_base"]assert _GEMINI_KEY not in raw_api_baseassert "key=*****" in raw_api_base+++def test_resolve_vertex_location_for_cost():+ """Vertex requests resolve the serving location the way dispatch does; other providers get None."""+ from litellm.litellm_core_utils.litellm_logging import (+ _resolve_vertex_location_for_cost,+ )++ assert _resolve_vertex_location_for_cost("openai", {"vertex_location": "us-east5"}, "gpt-4o") is None+ assert _resolve_vertex_location_for_cost(None, {}, "gemini-3.5-flash") is None+ assert (+ _resolve_vertex_location_for_cost("vertex_ai", {"vertex_location": "us-east5"}, "gemini-3.5-flash")+ == "us-east5"+ )+ assert (+ _resolve_vertex_location_for_cost("vertex_ai", {"vertex_location": "global"}, "gemini-3.5-flash") == "global"+ )+ assert (+ _resolve_vertex_location_for_cost(+ "vertex_ai_beta", {"vertex_ai_location": "europe-west1"}, "claude-haiku-4-5@20251001"+ )+ == "europe-west1"+ )+++def test_resolve_vertex_location_for_cost_default_region(monkeypatch):+ """With no location configured anywhere, resolution lands on the dispatch default us-central1."""+ from litellm.litellm_core_utils.litellm_logging import (+ _resolve_vertex_location_for_cost,+ )++ monkeypatch.delenv("VERTEXAI_LOCATION", raising=False)+ monkeypatch.delenv("VERTEX_LOCATION", raising=False)+ monkeypatch.setattr(litellm, "vertex_location", None)++ assert _resolve_vertex_location_for_cost("vertex_ai", {}, "gemini-3.5-flash") == "us-central1"+ assert _resolve_vertex_location_for_cost("vertex_ai", None, "gemini-3.5-flash") == "us-central1"+++def test_set_cost_breakdown_stores_vertex_location():+ """vertex_location is recorded in the pricing basis, None for non-vertex requests."""+ from datetime import datetime++ logging_obj = LitellmLogging(+ model="vertex_ai/claude-haiku-4-5@20251001",+ messages=[{"role": "user", "content": "hi"}],+ stream=False,+ call_type="completion",+ start_time=datetime.now(),+ litellm_call_id="vertex-location-set",+ function_id="f",+ )+ logging_obj.set_cost_breakdown(+ input_cost=0.001,+ output_cost=0.002,+ total_cost=0.003,+ cost_for_built_in_tools_cost_usd_dollar=0.0,+ vertex_location="us-east5",+ )+ assert logging_obj.cost_breakdown["vertex_location"] == "us-east5"++ no_location = LitellmLogging(+ model="gpt-4o",+ messages=[{"role": "user", "content": "hi"}],+ stream=False,+ call_type="completion",+ start_time=datetime.now(),+ litellm_call_id="vertex-location-absent",+ function_id="f",+ )+ no_location.set_cost_breakdown(+ input_cost=0.001,+ output_cost=0.002,+ total_cost=0.003,+ cost_for_built_in_tools_cost_usd_dollar=0.0,+ )+ assert no_location.cost_breakdown.get("vertex_location") is Nonediff --git a/tests/test_litellm/proxy/spend_tracking/test_savings.py b/tests/test_litellm/proxy/spend_tracking/test_savings.pyindex 1435547c434..9006288bdae 100644--- a/tests/test_litellm/proxy/spend_tracking/test_savings.py+++ b/tests/test_litellm/proxy/spend_tracking/test_savings.py@@ -841,6 +841,44 @@ def test_the_baseline_is_priced_on_the_basis_the_request_was_billed_at(basis, exassert reported == pytest.approx(expected_multiplier * baseline - served)+def test_the_baseline_is_priced_on_the_vertex_location_the_request_was_billed_at(monkeypatch):+ """A request served from a regional Vertex endpoint was billed with the+ regional-endpoint uplift, so the counterfactual single-model operator would+ have paid it too. The served model carries no uplift field, so only the+ baseline moves with the recorded location."""+ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")+ monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))++ gemini = litellm.get_model_info("gemini-3.5-flash", "vertex_ai")+ haiku = litellm.get_model_info("claude-haiku-4-5", "anthropic")+ assert gemini.get("regional_endpoint_uplift_multiplier") == 1.1+ assert haiku.get("regional_endpoint_uplift_multiplier") is None, "served model must not move with the basis"++ usage = _usage(fresh=20_000, cached=0, written=0, out=1_000)+ served = 20_000 * haiku["input_cost_per_token"] + 1_000 * haiku["output_cost_per_token"]+ baseline = 20_000 * gemini["input_cost_per_token"] + 1_000 * gemini["output_cost_per_token"]++ regional = compute_autorouter_savings(+ baseline_model="vertex_ai/gemini-3.5-flash",+ selected_model="claude-haiku-4-5",+ selected_provider="anthropic",+ usage=usage,+ conversation_continuing=False,+ cost_breakdown=_breakdown(served, vertex_location="us-east5"),+ )+ global_endpoint = compute_autorouter_savings(+ baseline_model="vertex_ai/gemini-3.5-flash",+ selected_model="claude-haiku-4-5",+ selected_provider="anthropic",+ usage=usage,+ conversation_continuing=False,+ cost_breakdown=_breakdown(served, vertex_location="global"),+ )++ assert regional == pytest.approx(1.1 * baseline - served)+ assert global_endpoint == pytest.approx(baseline - served)++def test_a_baseline_recorded_on_the_decision_turns_the_driver_on():"""An operator who configures nothing still sees the driver work."""result = compute_savings_spend(diff --git a/tests/test_litellm/test_cost_calculator.py b/tests/test_litellm/test_cost_calculator.pyindex 75c90d793fe..6deaf5479e0 100644--- a/tests/test_litellm/test_cost_calculator.py+++ b/tests/test_litellm/test_cost_calculator.py@@ -1742,6 +1742,75 @@ def test_azure_ai_cache_cost_calculation():), f"Output cost mismatch: got {output_cost}, expected {expected_output_cost}"+def test_vertex_regional_deployment_costs_uplift_over_global(monkeypatch):+ """+ Regression for https://github.com/BerriAI/litellm/issues/34393: two Vertex+ deployments differing only in vertex_location must not price identically.+ Google bills non-global endpoints at 1.1x for regional-pricing models, so the+ regional request costs 1.1x the global one for the exact same usage, through+ both vertex cost routes (Claude via cost_per_token, Gemini via+ cost_per_character's token fallback).+ """+ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")+ monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))++ usage = Usage(prompt_tokens=15, completion_tokens=5, total_tokens=20)+ for model in ("claude-haiku-4-5@20251001", "gemini-3.5-flash"):+ global_prompt, global_completion = cost_per_token(+ model=model,+ custom_llm_provider="vertex_ai",+ usage_object=usage,+ vertex_location="global",+ )+ regional_prompt, regional_completion = cost_per_token(+ model=model,+ custom_llm_provider="vertex_ai",+ usage_object=usage,+ vertex_location="us-east5",+ )+ global_total = global_prompt + global_completion+ regional_total = regional_prompt + regional_completion+ assert global_total > 0+ assert regional_total == pytest.approx(global_total * 1.10, rel=1e-9), (+ f"{model}: regional Vertex request must cost 1.1x the global one"+ )+++def test_vertex_uplift_composes_with_above_128k_pricing(monkeypatch):+ """The regional-endpoint uplift multiplies whatever rate the request priced at,+ including the above-128k dynamic rates, so a synthetic model carrying both keys+ prices regional above-128k usage at 1.1x the above-128k rate."""+ monkeypatch.setenv("LITELLM_LOCAL_MODEL_COST_MAP", "True")+ monkeypatch.setattr(litellm, "model_cost", litellm.get_model_cost_map(url=""))+ litellm.model_cost["vertex_ai/fake-regional-128k-model"] = {+ "litellm_provider": "vertex_ai",+ "mode": "chat",+ "input_cost_per_token": 1e-06,+ "output_cost_per_token": 2e-06,+ "input_cost_per_token_above_128k_tokens": 2e-06,+ "output_cost_per_token_above_128k_tokens": 4e-06,+ "regional_endpoint_uplift_multiplier": 1.1,+ }++ usage = Usage(prompt_tokens=200_000, completion_tokens=10, total_tokens=200_010)+ global_prompt, global_completion = cost_per_token(+ model="fake-regional-128k-model",+ custom_llm_provider="vertex_ai",+ usage_object=usage,+ vertex_location="global",+ )+ regional_prompt, regional_completion = cost_per_token(+ model="fake-regional-128k-model",+ custom_llm_provider="vertex_ai",+ usage_object=usage,+ vertex_location="europe-west1",+ )++ assert global_prompt == pytest.approx(200_000 * 2e-06, rel=1e-9)+ assert regional_prompt == pytest.approx(global_prompt * 1.10, rel=1e-9)+ assert regional_completion == pytest.approx(global_completion * 1.10, rel=1e-9)++def test_cost_discount_vertex_ai():"""Test that cost discount is applied correctly for Vertex AI providerdiff --git a/type-discipline-budget.json b/type-discipline-budget.jsonindex 6f77a621a9e..56ffbe9fde8 100644--- a/type-discipline-budget.json+++ b/type-discipline-budget.json@@ -1,6 +1,6 @@{"LIT001": {- "limit": 22809+ "limit": 22808},"LIT002": {"limit": 26878diff --git a/ui/litellm-dashboard/src/lib/http/schema.d.ts b/ui/litellm-dashboard/src/lib/http/schema.d.tsindex 5794c60e97b..3cc7397f5bb 100644--- a/ui/litellm-dashboard/src/lib/http/schema.d.ts+++ b/ui/litellm-dashboard/src/lib/http/schema.d.ts@@ -27559,6 +27559,8 @@ export interface components {quality_router_default_model?: string | null;/** Region Name */region_name?: string | null;+ /** Regional Endpoint Uplift Multiplier */+ regional_endpoint_uplift_multiplier?: number | null;/** Regional Processing Uplift Multiplier Eu */regional_processing_uplift_multiplier_eu?: number | null;/** Regional Processing Uplift Multiplier Us */@@ -36689,6 +36691,8 @@ export interface components {quality_router_default_model?: string | null;/** Region Name */region_name?: string | null;+ /** Regional Endpoint Uplift Multiplier */+ regional_endpoint_uplift_multiplier?: number | null;/** Regional Processing Uplift Multiplier Eu */regional_processing_uplift_multiplier_eu?: number | null;/** Regional Processing Uplift Multiplier Us */