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(bedrock_mantle): gate unsupported service_tier on drop_params for the Responses API

mateo-berri354f3971a9e5
diff --git a/litellm/llms/bedrock_mantle/responses/transformation.py b/litellm/llms/bedrock_mantle/responses/transformation.py
index 31975444a31..04cab10f2e3 100644
--- a/litellm/llms/bedrock_mantle/responses/transformation.py
+++ b/litellm/llms/bedrock_mantle/responses/transformation.py
@@ -17,6 +17,7 @@ BaseAWSLLM._sign_request after the request body is finalized.
from typing import Any, Dict, List, Optional
+import litellm
from litellm._logging import verbose_logger
from litellm.llms.bedrock.base_aws_llm import BaseAWSLLM
from litellm.llms.bedrock_mantle.common_utils import (
@@ -42,6 +43,8 @@ _BASE_SUFFIXES_TO_STRIP = (
# Per Bedrock Mantle Responses API validation errors.
_BEDROCK_MANTLE_SUPPORTED_RESPONSE_TOOL_TYPES = frozenset({"function", "mcp", "custom", "namespace", "tool_search"})
+_BEDROCK_MANTLE_SUPPORTED_SERVICE_TIERS = frozenset({"auto", "default"})
+
class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPIConfig):
def __init__(
@@ -116,15 +119,40 @@ class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPI
return kept
+ @staticmethod
+ def _handle_unsupported_service_tier(params: dict, drop_params: bool) -> dict:
+ service_tier = params.get("service_tier")
+ if service_tier is None or service_tier in _BEDROCK_MANTLE_SUPPORTED_SERVICE_TIERS:
+ return params
+ if not drop_params:
+ raise litellm.utils.UnsupportedParamsError(
+ status_code=400,
+ message=(
+ f"bedrock_mantle does not support service_tier={service_tier!r}; the Bedrock Mantle "
+ "Responses API only accepts 'auto' or 'default'. Set `drop_params: true` (litellm_settings "
+ "or this deployment's litellm_params) to have LiteLLM drop it, or remove service_tier from "
+ "the client (Codex CLI sends it when a speed tier is set in ~/.codex/config.toml)."
+ ),
+ )
+ verbose_logger.warning(
+ "Bedrock Mantle Responses API: dropping unsupported service_tier %r (supported: %s).",
+ service_tier,
+ sorted(_BEDROCK_MANTLE_SUPPORTED_SERVICE_TIERS),
+ )
+ return {key: value for key, value in params.items() if key != "service_tier"}
+
def map_openai_params(
self,
response_api_optional_params: ResponsesAPIOptionalRequestParams,
model: str,
drop_params: bool,
) -> Dict:
- params = super().map_openai_params(
- response_api_optional_params=response_api_optional_params,
- model=model,
+ params = self._handle_unsupported_service_tier(
+ super().map_openai_params(
+ response_api_optional_params=response_api_optional_params,
+ model=model,
+ drop_params=drop_params,
+ ),
drop_params=drop_params,
)
diff --git a/litellm/responses/main.py b/litellm/responses/main.py
index 12f9be970c7..206736f501a 100644
--- a/litellm/responses/main.py
+++ b/litellm/responses/main.py
@@ -1070,11 +1070,13 @@ def responses(
)
# Get optional parameters for the responses API
+ request_drop_params = kwargs.get("drop_params")
responses_api_request_params: Dict = ResponsesAPIRequestUtils.get_optional_params_responses_api(
model=model,
responses_api_provider_config=responses_api_provider_config,
response_api_optional_params=response_api_optional_params,
allowed_openai_params=allowed_openai_params,
+ drop_params=request_drop_params if isinstance(request_drop_params, bool) else None,
)
litellm_logging_obj.update_from_kwargs(
@@ -1896,11 +1898,13 @@ def compact_responses(
)
# Get optional parameters for the responses API
+ request_drop_params = kwargs.get("drop_params")
responses_api_request_params: Dict = ResponsesAPIRequestUtils.get_optional_params_responses_api(
model=model,
responses_api_provider_config=responses_api_provider_config,
response_api_optional_params=response_api_optional_params,
allowed_openai_params=None,
+ drop_params=request_drop_params if isinstance(request_drop_params, bool) else None,
)
# Pre Call logging
diff --git a/litellm/responses/utils.py b/litellm/responses/utils.py
index 234eb777aca..7a42cb96566 100644
--- a/litellm/responses/utils.py
+++ b/litellm/responses/utils.py
@@ -65,6 +65,7 @@ class ResponsesAPIRequestUtils:
responses_api_provider_config: BaseResponsesAPIConfig,
response_api_optional_params: ResponsesAPIOptionalRequestParams,
allowed_openai_params: Optional[List[str]] = None,
+ drop_params: bool | None = None,
) -> Dict:
"""
Get optional parameters for the responses API.
@@ -83,12 +84,14 @@ class ResponsesAPIRequestUtils:
# Get supported parameters for the model
supported_params = responses_api_provider_config.get_supported_openai_params(model)
+ should_drop_params = litellm.drop_params or drop_params is True
+
non_default_params = cast(Dict, response_api_optional_params)
# Check for unsupported parameters
ResponsesAPIRequestUtils._check_valid_arg(
supported_params=supported_params + (allowed_openai_params or []),
non_default_params=non_default_params,
- drop_params=litellm.drop_params,
+ drop_params=should_drop_params,
custom_llm_provider=responses_api_provider_config.custom_llm_provider,
model=model,
)
@@ -97,7 +100,7 @@ class ResponsesAPIRequestUtils:
mapped_params = responses_api_provider_config.map_openai_params(
response_api_optional_params=response_api_optional_params,
model=model,
- drop_params=litellm.drop_params,
+ drop_params=should_drop_params,
)
# add any allowed_openai_params to the mapped_params
diff --git a/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_responses_transformation.py b/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_responses_transformation.py
index 816a025e11a..7a3a84be65a 100644
--- a/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_responses_transformation.py
+++ b/tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_responses_transformation.py
@@ -373,6 +373,127 @@ class TestBedrockMantleResponsesTools:
assert "web_search" in str(mock_warning.call_args)
+def _codex_exec_tool():
+ return {
+ "type": "custom",
+ "name": "exec",
+ "description": "Run JavaScript code to orchestrate/compose tool calls",
+ "format": {
+ "type": "grammar",
+ "syntax": "lark",
+ "definition": "start: SOURCE\nSOURCE: /[\\s\\S]+/",
+ },
+ }
+
+
+def _codex_wait_tool():
+ return {
+ "type": "function",
+ "name": "wait",
+ "strict": False,
+ "parameters": {
+ "type": "object",
+ "properties": {"cell_id": {"type": "string"}},
+ "required": ["cell_id"],
+ "additionalProperties": False,
+ },
+ }
+
+
+class TestBedrockMantleServiceTier:
+ @pytest.mark.parametrize("tier", ["priority", "flex"])
+ def test_unsupported_service_tier_dropped_when_drop_params_true(self, tier):
+ cfg = BedrockMantleResponsesAPIConfig()
+ params = cfg.map_openai_params(
+ response_api_optional_params={"service_tier": tier},
+ model="openai.gpt-5.5",
+ drop_params=True,
+ )
+ assert "service_tier" not in params
+
+ @pytest.mark.parametrize("tier", ["priority", "flex"])
+ def test_unsupported_service_tier_raises_when_drop_params_false(self, tier):
+ cfg = BedrockMantleResponsesAPIConfig()
+ with pytest.raises(litellm.UnsupportedParamsError) as excinfo:
+ cfg.map_openai_params(
+ response_api_optional_params={"service_tier": tier},
+ model="openai.gpt-5.5",
+ drop_params=False,
+ )
+ assert tier in str(excinfo.value)
+ assert "drop_params" in str(excinfo.value)
+
+ @pytest.mark.parametrize("drop_params", [True, False])
+ @pytest.mark.parametrize("tier", ["auto", "default"])
+ def test_supported_service_tier_kept(self, tier, drop_params):
+ cfg = BedrockMantleResponsesAPIConfig()
+ params = cfg.map_openai_params(
+ response_api_optional_params={"service_tier": tier},
+ model="openai.gpt-5.5",
+ drop_params=drop_params,
+ )
+ assert params["service_tier"] == tier
+
+ def test_absent_service_tier_untouched(self):
+ cfg = BedrockMantleResponsesAPIConfig()
+ params = cfg.map_openai_params(
+ response_api_optional_params={"stream": True},
+ model="openai.gpt-5.5",
+ drop_params=False,
+ )
+ assert "service_tier" not in params
+ assert params["stream"] is True
+
+ def test_drop_logged_at_warning_level(self):
+ from unittest.mock import patch
+
+ cfg = BedrockMantleResponsesAPIConfig()
+ with patch(
+ "litellm.llms.bedrock_mantle.responses.transformation.verbose_logger.warning"
+ ) as mock_warning:
+ cfg.map_openai_params(
+ response_api_optional_params={"service_tier": "priority"},
+ model="openai.gpt-5.5",
+ drop_params=True,
+ )
+ assert mock_warning.call_count == 1
+ assert "priority" in str(mock_warning.call_args)
+
+
+class TestBedrockMantleCodexRequestEndToEnd:
+ def test_codex_priority_tier_request_becomes_mantle_acceptable(self):
+ cfg = BedrockMantleResponsesAPIConfig()
+ params = cfg.map_openai_params(
+ response_api_optional_params={
+ "service_tier": "priority",
+ "stream": True,
+ "store": False,
+ "tool_choice": "auto",
+ "parallel_tool_calls": False,
+ "tools": [_codex_exec_tool(), _codex_wait_tool()],
+ },
+ model="openai.gpt-5.5",
+ drop_params=True,
+ )
+ body = cfg.transform_responses_api_request(
+ model="openai.gpt-5.5",
+ input=[
+ {
+ "type": "message",
+ "role": "user",
+ "content": [{"type": "input_text", "text": "hi"}],
+ }
+ ],
+ response_api_optional_request_params=params,
+ litellm_params=GenericLiteLLMParams(),
+ headers={},
+ )
+ assert "service_tier" not in body
+ assert [tool["name"] for tool in body["tools"]] == ["exec", "wait"]
+ assert body["stream"] is True
+ assert body["tool_choice"] == "auto"
+
+
class TestBedrockMantleResponsesRegistry:
def test_registry_returns_config_for_gpt_5_5(self, local_cost_map):
# gpt-5.x advertises /v1/responses in supported_endpoints (capability)
diff --git a/tests/test_litellm/responses/test_responses_api_request_body.py b/tests/test_litellm/responses/test_responses_api_request_body.py
index c39ba75bd97..44dfa240d42 100644
--- a/tests/test_litellm/responses/test_responses_api_request_body.py
+++ b/tests/test_litellm/responses/test_responses_api_request_body.py
@@ -196,3 +196,66 @@ async def test_aresponses_azure_shell_tool_400_maps_to_bad_request_error():
assert excinfo.value.status_code == 400
assert "shell" in str(excinfo.value).lower()
assert "not supported" in str(excinfo.value).lower()
+
+
+async def test_aresponses_request_level_drop_params_drops_bedrock_mantle_service_tier(
+ monkeypatch,
+):
+ """
+ Request-level drop_params=True (as the proxy injects for agentic CLIs) must
+ reach the provider config so bedrock_mantle strips the unsupported
+ service_tier before the request hits the wire.
+ """
+ monkeypatch.setattr(litellm, "drop_params", False)
+
+ with patch(
+ "litellm.llms.custom_httpx.http_handler.AsyncHTTPHandler.post",
+ new_callable=AsyncMock,
+ ) as mock_post:
+ mock_post.return_value = MockResponse(
+ _minimal_responses_api_payload("resp_mantle_tier_test", "openai.gpt-5.5"),
+ 200,
+ )
+
+ await litellm.aresponses(
+ model="bedrock_mantle/openai.gpt-5.5",
+ api_key="fake-bearer-token",
+ aws_region_name="us-east-1",
+ input="hi",
+ service_tier="priority",
+ drop_params=True,
+ )
+
+ mock_post.assert_called_once()
+ post_kwargs = mock_post.call_args.kwargs
+ request_body = post_kwargs["json"] if "json" in post_kwargs else json.loads(post_kwargs["data"])
+ assert "service_tier" not in request_body
+
+
+async def test_aresponses_bedrock_mantle_service_tier_raises_without_drop_params(
+ monkeypatch,
+):
+ """
+ Without drop_params, an unsupported service_tier must fail fast with an
+ error that names drop_params instead of sending a request Mantle rejects.
+ """
+ monkeypatch.setattr(litellm, "drop_params", False)
+
+ with patch(
+ "litellm.llms.custom_httpx.http_handler.AsyncHTTPHandler.post",
+ new_callable=AsyncMock,
+ ) as mock_post:
+ with pytest.raises(litellm.BadRequestError) as excinfo:
+ await litellm.aresponses(
+ model="bedrock_mantle/openai.gpt-5.5",
+ api_key="fake-bearer-token",
+ aws_region_name="us-east-1",
+ input="hi",
+ service_tier="priority",
+ )
+
+ mock_post.assert_not_called()
+ assert "drop_params" in str(excinfo.value)
+ assert "priority" in str(excinfo.value)
diff --git a/tests/test_litellm/responses/test_responses_utils.py b/tests/test_litellm/responses/test_responses_utils.py
index bbc137b959f..3a75a33fdc7 100644
--- a/tests/test_litellm/responses/test_responses_utils.py
+++ b/tests/test_litellm/responses/test_responses_utils.py
@@ -69,6 +69,44 @@ class TestResponsesAPIRequestUtils:
assert "unsupported_param" in str(excinfo.value)
assert model in str(excinfo.value)
+ def test_get_optional_params_responses_api_request_level_drop_params(self, monkeypatch):
+ """Request-level drop_params must reach both _check_valid_arg and map_openai_params"""
+ monkeypatch.setattr(litellm, "drop_params", False)
+ config = MagicMock(spec=OpenAIResponsesAPIConfig)
+ config.get_supported_openai_params.return_value = ["temperature"]
+ config.custom_llm_provider = "openai"
+ config.map_openai_params.return_value = {"temperature": 0.7}
+
+ result = ResponsesAPIRequestUtils.get_optional_params_responses_api(
+ model="gpt-4o",
+ responses_api_provider_config=config,
+ response_api_optional_params=ResponsesAPIOptionalRequestParams(
+ {"temperature": 0.7, "service_tier": "priority"}
+ ),
+ drop_params=True,
+ )
+
+ assert config.map_openai_params.call_args.kwargs["drop_params"] is True
+ assert result == {"temperature": 0.7}
+
+ @pytest.mark.parametrize("request_drop_params", [None, False])
+ def test_get_optional_params_responses_api_still_raises_without_drop(
+ self, monkeypatch, request_drop_params
+ ):
+ """Absent or False request-level drop_params must not suppress the unsupported-param error"""
+ monkeypatch.setattr(litellm, "drop_params", False)
+ config = OpenAIResponsesAPIConfig()
+
+ with pytest.raises(litellm.UnsupportedParamsError):
+ ResponsesAPIRequestUtils.get_optional_params_responses_api(
+ model="gpt-4o",
+ responses_api_provider_config=config,
+ response_api_optional_params=ResponsesAPIOptionalRequestParams(
+ {"temperature": 0.7, "unsupported_param": "value"}
+ ),
+ drop_params=request_drop_params,
+ )
+
def test_get_requested_response_api_optional_param(self):
"""Test filtering parameters to only include those in ResponsesAPIOptionalRequestParams"""
# Setup