diff --git a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py index 77e4e31465d..fde1dd18752 100644 --- a/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py +++ b/litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/transformation.py @@ -66,12 +66,11 @@ class VertexAIAnthropicConfig(AnthropicConfig): @staticmethod def get_max_tokens_for_model(model: str | None = None) -> int: if model is not None: - try: - vertex_max: Final = get_max_tokens(f"vertex_ai/{model}") + vertex_key: Final = f"vertex_ai/{model}" + if vertex_key in litellm.model_cost: # pyright: ignore[reportUnknownMemberType] # registry is dynamically typed + vertex_max: Final = get_max_tokens(vertex_key) if vertex_max is not None: return vertex_max - except Exception: - return AnthropicConfig.get_max_tokens_for_model(model) return AnthropicConfig.get_max_tokens_for_model(model) def _add_context_management_beta_headers(self, beta_set: set, context_management: dict) -> None: