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): resolve gpt-5 sampling rules from the OpenAI catalogue entry

mateo-berri9ae5bde829a7
diff --git a/litellm/llms/bedrock_mantle/responses/transformation.py b/litellm/llms/bedrock_mantle/responses/transformation.py
index 57590601a3c..86e20e31d7f 100644
--- a/litellm/llms/bedrock_mantle/responses/transformation.py
+++ b/litellm/llms/bedrock_mantle/responses/transformation.py
@@ -344,6 +344,10 @@ class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPI
kept: Final = [item for item, _ in normalized if item is not None] # mutable-ok: ResponseInputParam is a list
return kept # pyright: ignore[reportReturnType] # Codex passthrough items sit outside the OpenAI input union
+ @staticmethod
+ def _model_map_lookup_name(model: str) -> str:
+ return model.split("/")[-1].removeprefix("openai.")
+
def map_openai_params(
self,
response_api_optional_params: ResponsesAPIOptionalRequestParams,
diff --git a/litellm/llms/openai/responses/transformation.py b/litellm/llms/openai/responses/transformation.py
index 0d8d6934795..6c1d8698652 100644
--- a/litellm/llms/openai/responses/transformation.py
+++ b/litellm/llms/openai/responses/transformation.py
@@ -125,6 +125,10 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
return False
return is_gpt_reasoning_series_name(model)
+ @staticmethod
+ def _model_map_lookup_name(model: str) -> str:
+ return model
+
@staticmethod
def _supports_reasoning_effort_none(model: str) -> bool:
"""Return True if the model supports reasoning.effort='none'."""
@@ -235,11 +239,12 @@ class OpenAIResponsesAPIConfig(BaseResponsesAPIConfig):
status_code=400,
)
- if self._is_gpt_5_model(model=model):
+ lookup_name: Final = self._model_map_lookup_name(model)
+ if self._is_gpt_5_model(model=lookup_name):
reasoning: Final = params.get("reasoning") or {}
effort: Final = reasoning.get("effort") if isinstance(reasoning, dict) else None
- supports_none: Final = self._supports_reasoning_effort_none(model=model)
- effort_is_none: Final = supports_none and self._effort_resolves_to_none(model, effort)
+ supports_none: Final = self._supports_reasoning_effort_none(model=lookup_name)
+ effort_is_none: Final = supports_none and self._effort_resolves_to_none(lookup_name, effort)
temperature: Final = params.get("temperature")
if temperature is not None and temperature != 1:
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 afd284d31c8..88d9e103f86 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
@@ -370,26 +370,49 @@ class TestBedrockMantleResponsesTools:
class TestBedrockMantleSamplingParams:
- """Mantle rejects top_p on its gpt-5 reasoning models and non-default temperature
- while reasoning is active, the same rule the OpenAI Responses surface applies, so
- drop_params must strip both before the request leaves."""
+ """Mantle serves OpenAI's gpt-5 models under their OpenAI sampling rule: top_p and a
+ non-default temperature are accepted only when reasoning.effort resolves to none, so
+ the `openai.` catalogue name (region-prefixed on GovCloud) must answer from the OpenAI
+ model's map entry instead of dropping both params on every request."""
@pytest.mark.parametrize(
- "model",
+ "model, effort, survives",
[
- "openai.gpt-5.4",
- "openai.gpt-5.5",
- "openai.gpt-5.6-luna",
+ ("openai.gpt-5.4", None, True),
+ ("openai.gpt-5.5", None, False),
+ ("openai.gpt-5.6-luna", None, False),
+ ("openai.gpt-5.6-luna", "none", True),
+ ("openai.gpt-5.6-luna", "low", False),
+ ("us-gov-west-1/openai.gpt-5.4", None, True),
+ ("us-gov-west-1/openai.gpt-5.6-luna", None, False),
],
)
- def test_map_openai_params_drops_top_p_and_temperature(self, local_cost_map, model):
- params = BedrockMantleResponsesAPIConfig().map_openai_params(
- response_api_optional_params={"top_p": 0.9, "temperature": 0.2},
+ def test_top_p_and_temperature_follow_the_resolved_effort(self, local_cost_map, model, effort, survives):
+ params = {"top_p": 0.9, "temperature": 0.2}
+ if effort is not None:
+ params["reasoning"] = {"effort": effort}
+ mapped = BedrockMantleResponsesAPIConfig().map_openai_params(
+ response_api_optional_params=params,
model=model,
drop_params=True,
)
- assert "top_p" not in params
- assert "temperature" not in params
+ assert ("top_p" in mapped) is survives
+ assert ("temperature" in mapped) is survives
+
+ def test_top_p_without_drop_params_raises_only_while_reasoning_is_active(self, local_cost_map):
+ with pytest.raises(litellm.UnsupportedParamsError):
+ BedrockMantleResponsesAPIConfig().map_openai_params(
+ response_api_optional_params={"top_p": 0.9},
+ model="openai.gpt-5.6-luna",
+ drop_params=False,
+ )
+
+ mapped = BedrockMantleResponsesAPIConfig().map_openai_params(
+ response_api_optional_params={"top_p": 0.9},
+ model="openai.gpt-5.4",
+ drop_params=False,
+ )
+ assert mapped["top_p"] == 0.9
class TestBedrockMantleResponsesWebSearch: