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]

fix(responses): preserve Bedrock Mantle validation status (#36580)

Ruiming Zhaoc1662258df4a
diff --git a/litellm/litellm_core_utils/exception_mapping_utils.py b/litellm/litellm_core_utils/exception_mapping_utils.py
index d23466938f2..ee179b582cf 100644
--- a/litellm/litellm_core_utils/exception_mapping_utils.py
+++ b/litellm/litellm_core_utils/exception_mapping_utils.py
@@ -2315,7 +2315,7 @@ def exception_type(
exception_provider=exception_provider,
extra_information=extra_information,
)
- elif custom_llm_provider == "bedrock":
+ elif custom_llm_provider in ("bedrock", "bedrock_mantle"):
_map_bedrock_exception(
model=model,
original_exception=mappable_exception,
diff --git a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py
index d5676aaf288..904675d4adc 100644
--- a/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py
+++ b/tests/test_litellm/litellm_core_utils/test_exception_mapping_utils.py
@@ -762,3 +762,26 @@ def test_azure_404_with_invalid_request_error_type_maps_to_not_found():
assert excinfo.value.status_code == 404
assert "Response with id 'resp_abc' not found." in excinfo.value.message
+
+
+def test_bedrock_mantle_400_maps_to_bad_request():
+ from litellm.llms.base_llm.chat.transformation import BaseLLMException
+
+ original_exception = BaseLLMException(
+ status_code=400,
+ message=(
+ '{"error": {"code": "validation_error", "message": '
+ "\"invalid request body: Invalid 'input': value did not match any expected variant\", "
+ '"type": "invalid_request_error"}}'
+ ),
+ )
+
+ with pytest.raises(litellm.BadRequestError) as excinfo:
+ exception_type(
+ model="gpt-5.6-terra",
+ original_exception=original_exception,
+ custom_llm_provider="bedrock_mantle",
+ )
+
+ assert excinfo.value.status_code == 400
+ assert "Invalid 'input'" in excinfo.value.message