diff --git a/litellm/llms/bedrock/responses/transformation.py b/litellm/llms/bedrock/responses/transformation.py index a2996c97a10..7b735dd0b29 100644 --- a/litellm/llms/bedrock/responses/transformation.py +++ b/litellm/llms/bedrock/responses/transformation.py @@ -1,7 +1,7 @@ """Amazon Bedrock Runtime - native OpenAI Responses API. AWS serves the OpenAI models on ``bedrock-runtime`` through an OpenAI-compatible -surface at ``https://bedrock-runtime.{region}.amazonaws.com/openai/v1/responses``, +surface at ``https://bedrock-runtime.{region}.{dns_suffix}/openai/v1/responses``, alongside Converse. Without this config the ``bedrock`` provider has no Responses config at all, so ``/v1/responses`` falls back to the Chat Completions bridge and the request is translated into Converse. A realistic Codex session does not @@ -86,7 +86,11 @@ class BedrockOpenAIResponsesConfig(BaseAWSLLM, OpenAIResponsesAPIConfig): or litellm_params.get("aws_bedrock_runtime_endpoint") or get_secret_str("AWS_BEDROCK_RUNTIME_ENDPOINT") ) - host: Final = (override or f"https://bedrock-runtime.{region}.amazonaws.com").rstrip("/") + # Partition-aware: bedrock-runtime is amazonaws.com.cn in China, and other + # suffixes in GovCloud/ISO, so defer to the shared endpoint builder. + host: Final = ( + override or self._select_default_endpoint_url(endpoint_type="runtime", aws_region_name=region) + ).rstrip("/") if host.endswith(BEDROCK_RUNTIME_OPENAI_RESPONSES_PATH): return host base: Final = next( diff --git a/litellm/llms/bedrock_mantle/responses/transformation.py b/litellm/llms/bedrock_mantle/responses/transformation.py index 79a5789c151..0ab8467d222 100644 --- a/litellm/llms/bedrock_mantle/responses/transformation.py +++ b/litellm/llms/bedrock_mantle/responses/transformation.py @@ -59,7 +59,6 @@ _BEDROCK_MANTLE_SUPPORTED_SERVICE_TIERS: Final = frozenset({"auto", "default"}) _BEDROCK_MANTLE_OPENAI_PATH_SUPPORTED_REASONING_SUMMARIES: Final = frozenset({"auto"}) - class BedrockMantleResponsesAPIConfig(BedrockMantleAuthMixin, OpenAIResponsesAPIConfig): def __init__( self, diff --git a/tests/test_litellm/litellm_core_utils/test_aws_partition.py b/tests/test_litellm/litellm_core_utils/test_aws_partition.py index 3594d3c354c..b7f99cf0f18 100644 --- a/tests/test_litellm/litellm_core_utils/test_aws_partition.py +++ b/tests/test_litellm/litellm_core_utils/test_aws_partition.py @@ -21,6 +21,7 @@ from litellm.llms.bedrock.base_aws_llm import BaseAWSLLM from litellm.llms.bedrock.batches.transformation import BedrockBatchesConfig from litellm.llms.bedrock.chat.agentcore.transformation import AmazonAgentCoreConfig from litellm.llms.bedrock.common_utils import init_bedrock_client +from litellm.llms.bedrock.responses.transformation import BedrockOpenAIResponsesConfig from litellm.llms.sagemaker.chat.transformation import SagemakerChatConfig @@ -152,6 +153,10 @@ ENDPOINT_BUILDERS: Final = { litellm_params={}, stream=True, ), + "bedrock_openai_responses": lambda region: BedrockOpenAIResponsesConfig().get_complete_url( + api_base=None, + litellm_params={"aws_region_name": region}, + ), "s3_object_url": _s3_object_url, }