Class BedrockMessagesStreamingAsyncExample
-
- All Implemented Interfaces:
public final class BedrockMessagesStreamingAsyncExampleAn example of retrieving messages asynchronously in a streaming response from an Anthropic model running on the Amazon Bedrock backend.
To use the BedrockBackend, the SDK module for Bedrock must be added to the dependencies. Many of the other examples can be adapted to create a client with the
BedrockBackend. Once a client is created, the rest of the code does not need to be changed (subject to the endpoint being supported). See the SDK documentation for details on dependencies and endpoint support for Bedrock.AWS credentials must be configured to access Amazon Bedrock. This example resolves the required credentials from the environment. The credentials can be in system properties, environment variables, AWS CLI configuration files, an AWS SSO configuration, etc. See AWS documentation for details. Alternatively, the credentials and region can be set explicitly from other sources. See BedrockMessagesAsyncExample for comparison.
With an Anthropic model deployed on a Bedrock service, it may be sufficient to set the following environment variables to run this example:
AWS_REGION: The name of the AWS region hosting the service.AWS_ACCESS_KEY_ID: The AWS access key ID identifying the service user.AWS_SECRET_ACCESS_KEY: The AWS secret access key used to sign the requests to the AWS service.