From fc2cfa9c7c0a8142101875a6af251dbe46574647 Mon Sep 17 00:00:00 2001 From: dom Date: Sun, 20 Jul 2025 13:23:38 -0400 Subject: [PATCH] Add VPC endpoint support to BedrockModel class - Add optional endpoint_url parameter to BedrockModel constructor - Pass endpoint_url to boto3 client for VPC endpoint connectivity - Maintains backward compatibility with existing code Resolves: Issue #496 --- src/strands/models/bedrock.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/strands/models/bedrock.py b/src/strands/models/bedrock.py index 679f1ea3d..398933b44 100644 --- a/src/strands/models/bedrock.py +++ b/src/strands/models/bedrock.py @@ -72,6 +72,7 @@ class BedrockConfig(TypedDict, total=False): streaming: Flag to enable/disable streaming. Defaults to True. temperature: Controls randomness in generation (higher = more random) top_p: Controls diversity via nucleus sampling (alternative to temperature) + endpoint_url: Custom endpoint URL for VPC endpoints (PrivateLink) """ additional_args: Optional[dict[str, Any]] @@ -93,6 +94,7 @@ class BedrockConfig(TypedDict, total=False): streaming: Optional[bool] temperature: Optional[float] top_p: Optional[float] + endpoint_url: Optional[str] #Adding Endpoint URL def __init__( self, @@ -110,6 +112,7 @@ def __init__( region_name: AWS region to use for the Bedrock service. Defaults to the AWS_REGION environment variable if set, or "us-west-2" if not set. **model_config: Configuration options for the Bedrock model. + Use endpoint_url for VPC endpoint connectivity. """ if region_name and boto_session: raise ValueError("Cannot specify both `region_name` and `boto_session`.") @@ -140,6 +143,7 @@ def __init__( self.client = session.client( service_name="bedrock-runtime", config=client_config, + endpoint_url=self.config.get("endpoint_url"), region_name=resolved_region, )