Skip to content

Bedrock Runtime

Client

BedrockRuntimeClient

BedrockRuntimeClient(config: Config | None = None, plugins: list[Plugin] | None = None)

Describes the API operations for running inference using Amazon Bedrock models.

Parameters:

Name Type Description Default
config Config | None

Optional configuration for the client. Here you can set things like the endpoint for HTTP services or auth credentials.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. These can be used to set defaults, for example.

None
Source code in src/aws_sdk_bedrock_runtime/client.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
def __init__(
    self, config: Config | None = None, plugins: list[Plugin] | None = None
):
    """Constructor for `BedrockRuntimeClient`.

    Args:
        config:
            Optional configuration for the client. Here you can set things like
            the endpoint for HTTP services or auth credentials.
        plugins:
            A list of callables that modify the configuration dynamically. These
            can be used to set defaults, for example.
    """
    self._config = config or Config()

    client_plugins: list[Plugin] = [aws_user_agent_plugin, user_agent_plugin]
    if plugins:
        client_plugins.extend(plugins)

    for plugin in client_plugins:
        plugin(self._config)

Available Operations

Configuration

Config dataclass

Config(*, auth_scheme_resolver: HTTPAuthSchemeResolver | None = None, auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None = None, aws_access_key_id: str | None = None, aws_credentials_identity_resolver: IdentityResolver[AWSCredentialsIdentity, AWSIdentityProperties] | None = None, aws_secret_access_key: str | None = None, aws_session_token: str | None = None, endpoint_resolver: EndpointResolver | None = None, endpoint_uri: str | URI | None = None, http_request_config: HTTPRequestConfiguration | None = None, interceptors: list[_ServiceInterceptor] | None = None, protocol: ClientProtocol[Any, Any] | None = None, region: str | None = None, retry_strategy: RetryStrategy | None = None, sdk_ua_app_id: str | None = None, transport: ClientTransport[Any, Any] | None = None, user_agent_extra: str | None = None)

Configuration settings for BedrockRuntimeClient.

Source code in src/aws_sdk_bedrock_runtime/config.py
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
def __init__(
    self,
    *,
    auth_scheme_resolver: HTTPAuthSchemeResolver | None = None,
    auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None = None,
    aws_access_key_id: str | None = None,
    aws_credentials_identity_resolver: IdentityResolver[
        AWSCredentialsIdentity, AWSIdentityProperties
    ]
    | None = None,
    aws_secret_access_key: str | None = None,
    aws_session_token: str | None = None,
    endpoint_resolver: _EndpointResolver | None = None,
    endpoint_uri: str | URI | None = None,
    http_request_config: HTTPRequestConfiguration | None = None,
    interceptors: list[_ServiceInterceptor] | None = None,
    protocol: ClientProtocol[Any, Any] | None = None,
    region: str | None = None,
    retry_strategy: RetryStrategy | None = None,
    sdk_ua_app_id: str | None = None,
    transport: ClientTransport[Any, Any] | None = None,
    user_agent_extra: str | None = None,
):
    self.auth_scheme_resolver = auth_scheme_resolver or HTTPAuthSchemeResolver()
    self.auth_schemes = auth_schemes or {
        ShapeID("aws.auth#sigv4"): SigV4AuthScheme(service="bedrock")
    }
    self.aws_access_key_id = aws_access_key_id
    self.aws_credentials_identity_resolver = aws_credentials_identity_resolver
    self.aws_secret_access_key = aws_secret_access_key
    self.aws_session_token = aws_session_token
    self.endpoint_resolver = endpoint_resolver or _RegionalResolver(
        endpoint_prefix="bedrock-runtime"
    )
    self.endpoint_uri = endpoint_uri
    self.http_request_config = http_request_config
    self.interceptors = interceptors or []
    self.protocol = protocol or RestJsonClientProtocol(
        _SCHEMA_AMAZON_BEDROCK_FRONTEND_SERVICE
    )
    self.region = region
    self.retry_strategy = retry_strategy or SimpleRetryStrategy()
    self.sdk_ua_app_id = sdk_ua_app_id
    self.transport = transport or AWSCRTHTTPClient()
    self.user_agent_extra = user_agent_extra

Attributes

auth_scheme_resolver instance-attribute
auth_scheme_resolver: HTTPAuthSchemeResolver = auth_scheme_resolver or HTTPAuthSchemeResolver()

An auth scheme resolver that determines the auth scheme for each operation.

auth_schemes instance-attribute
auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] = auth_schemes or {ShapeID('aws.auth#sigv4'): SigV4AuthScheme(service='bedrock')}

A map of auth scheme ids to auth schemes.

aws_access_key_id instance-attribute
aws_access_key_id: str | None = aws_access_key_id

The identifier for a secret access key.

aws_credentials_identity_resolver instance-attribute
aws_credentials_identity_resolver: IdentityResolver[AWSCredentialsIdentity, AWSIdentityProperties] | None = aws_credentials_identity_resolver

Resolves AWS Credentials. Required for operations that use Sigv4 Auth.

aws_secret_access_key instance-attribute
aws_secret_access_key: str | None = aws_secret_access_key

A secret access key that can be used to sign requests.

aws_session_token instance-attribute
aws_session_token: str | None = aws_session_token

An access key ID that identifies temporary security credentials.

endpoint_resolver instance-attribute
endpoint_resolver: EndpointResolver = endpoint_resolver or StandardRegionalEndpointsResolver(endpoint_prefix='bedrock-runtime')

The endpoint resolver used to resolve the final endpoint per-operation based on the configuration.

endpoint_uri instance-attribute
endpoint_uri: str | URI | None = endpoint_uri

A static URI to route requests to.

http_request_config instance-attribute
http_request_config: HTTPRequestConfiguration | None = http_request_config

Configuration for individual HTTP requests.

interceptors instance-attribute
interceptors: list[_ServiceInterceptor] = interceptors or []

The list of interceptors, which are hooks that are called during the execution of a request.

protocol instance-attribute
protocol: ClientProtocol[Any, Any] | None = protocol or RestJsonClientProtocol(AMAZON_BEDROCK_FRONTEND_SERVICE)

The protocol to serialize and deserialize requests with.

region instance-attribute
region: str | None = region

The AWS region to connect to. The configured region is used to determine the service endpoint.

retry_strategy instance-attribute
retry_strategy: RetryStrategy = retry_strategy or SimpleRetryStrategy()

The retry strategy for issuing retry tokens and computing retry delays.

sdk_ua_app_id instance-attribute
sdk_ua_app_id: str | None = sdk_ua_app_id

A unique and opaque application ID that is appended to the User-Agent header.

transport instance-attribute
transport: ClientTransport[Any, Any] | None = transport or AWSCRTHTTPClient()

The transport to use to send requests (e.g. an HTTP client).

user_agent_extra instance-attribute
user_agent_extra: str | None = user_agent_extra

Additional suffix to be added to the User-Agent header.

Functions

set_auth_scheme
set_auth_scheme(scheme: AuthScheme[Any, Any, Any, Any]) -> None

Sets the implementation of an auth scheme.

Using this method ensures the correct key is used.

Parameters:

Name Type Description Default
scheme AuthScheme[Any, Any, Any, Any]

The auth scheme to add.

required
Source code in src/aws_sdk_bedrock_runtime/config.py
189
190
191
192
193
194
195
196
197
198
def set_auth_scheme(self, scheme: AuthScheme[Any, Any, Any, Any]) -> None:
    """Sets the implementation of an auth scheme.

    Using this method ensures the correct key is used.

    Args:
        scheme:
            The auth scheme to add.
    """
    self.auth_schemes[scheme.scheme_id] = scheme

Errors

Structures

Unions

Enums