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: map global location to us-central1 for vertex's claude models count_tokens endpoint (#20348)
milan-berriaa3325c1d5ea
diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.pyindex 3842159fd7b..c6914ac3d6b 100644--- a/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.py+++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/count_tokens/handler.py@@ -107,6 +107,11 @@ class VertexAIPartnerModelsTokenCounter(VertexBase):vertex_project = self.get_vertex_ai_project(litellm_params)vertex_location = self.get_vertex_ai_location(litellm_params)+ # Map empty location/cluade models to a supported region for count-tokens endpoint+ # https://docs.cloud.google.com/vertex-ai/generative-ai/docs/partner-models/claude/count-tokens+ if not vertex_location or "claude" in model.lower():+ vertex_location = "us-central1"+# Get access token and resolved project IDaccess_token, project_id = await self._ensure_access_token_async(credentials=vertex_credentials,@@ -118,7 +123,7 @@ class VertexAIPartnerModelsTokenCounter(VertexBase):endpoint_url = self._build_count_tokens_endpoint(model=model,project_id=project_id,- vertex_location=vertex_location or "us-central1",+ vertex_location=vertex_location,api_base=litellm_params.get("api_base"),)