Skip to content

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]

merge: bring litellm_internal_staging into litellm_bedrock_mantle_govcloud_cost_row

mateo-berri0308b05c7a27
diff --cc litellm/llms/bedrock_mantle/chat/transformation.py
index 31edeb7ec51,d91157c3d10..a1153dffc93
--- a/litellm/llms/bedrock_mantle/chat/transformation.py
+++ b/litellm/llms/bedrock_mantle/chat/transformation.py
@@@ -24,8 -26,10 +26,10 @@@ from litellm.secret_managers.main impor
from litellm.types.llms.openai import AllMessageValues
from litellm.types.router import GenericLiteLLMParams
+ from ...base_llm.chat.transformation import BaseLLMException
+ from ...bedrock.common_utils import BedrockError
from ...openai_like.chat.transformation import OpenAILikeChatConfig
-from ..common_utils import mantle_base_segment
+from ..common_utils import mantle_base_segment, split_mantle_region_prefix
class BedrockMantleChatConfig(BedrockMantleAuthMixin, OpenAILikeChatConfig):
diff --cc litellm/llms/bedrock_mantle/common_utils.py
index 952642d3cd9,ac94d9cb922..9892ef6224e
--- a/litellm/llms/bedrock_mantle/common_utils.py
+++ b/litellm/llms/bedrock_mantle/common_utils.py
@@@ -23,11 -23,10 +23,12 @@@ from botocore.exceptions import
ProfileNotFound,
)
- from litellm.llms.bedrock.base_aws_llm import BaseAWSLLM
- from litellm.llms.bedrock.common_utils import _get_all_bedrock_regions
+ from litellm.llms.bedrock.base_aws_llm import BaseAWSLLM, SignsRequestsWithAWS
++from litellm.llms.bedrock.common_utils import AmazonBedrockGlobalConfig
from litellm.secret_managers.main import get_secret_str
BEDROCK_MANTLE_DEFAULT_REGION: Final = "us-east-1"
++BEDROCK_REGIONS: Final = frozenset(AmazonBedrockGlobalConfig().get_all_regions())
# Standard Mantle host: https://bedrock-mantle.<region>.api.aws (group 1 = region).
MANTLE_HOST_RE: Final = re.compile(r"^https?://bedrock-mantle\.([^/.]+)\.api\.aws(?=/|$)", re.IGNORECASE)
@@@ -37,13 -36,6 +38,13 @@@ def resolve_mantle_bearer_token(api_key
return api_key or get_secret_str("BEDROCK_MANTLE_API_KEY") or get_secret_str("AWS_BEARER_TOKEN_BEDROCK")
+def split_mantle_region_prefix(model: str) -> tuple[str | None, str]:
+ head, sep, tail = model.partition("/")
- if sep and head in _get_all_bedrock_regions():
++ if sep and head in BEDROCK_REGIONS:
+ return head, tail
+ return None, model
+
+
def resolve_mantle_region(params: Mapping[str, object]) -> str:
region: Final = params.get("aws_region_name")
if isinstance(region, str) and region:
diff --cc tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_transformation.py
index efe1a0b057a,e83a844c87e..c948dfb3553
--- a/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_transformation.py
+++ b/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_transformation.py
@@@ -6,7 -6,8 +6,8 @@@ API docs: https://docs.aws.amazon.com/b
"""
import json
+ import asyncio
-from unittest.mock import patch
+from unittest.mock import Mock, patch
import httpx