Select your cookie preferences

We use cookies and similar tools to enhance your experience, provide our services, deliver relevant advertising, and make improvements. Approved third parties also use these tools to help us deliver advertising and provide certain site features.

WebSocket API to Lambda to Bedrock with streaming response

Created with SnapAPI Gateway WebSocket APIAWS LambdaAmazon Bedrock

Creates an API Gateway WebSocketand Lambda functions that provides a streaming response from the LLMs in Amazon Bedrock.

This sample project demonstrates how to use WebSocket API as a front door to Lambda functions that perform inference on Amazon Bedrock LLMs using the [InvokeModelWithResponseStream API, where the LLM responses are returned in a stream.
With WebSocket API, developers of interactive LLM chatbot interfaces can provide a better user experience by displaying the LLM responses as they are generated (which at times can be long, rather than relying on the synchronous InvokeModel API request.
This pattern deploys one API Gateway WebSocket API, four Lambda functions, and one DynamoDB table.

< Back to all patterns


GitHub icon Visit the GitHub repo for this pattern.

Download

git clone https://github.com/aws-samples/serverless-patterns/ cd serverless-patterns/apigw-websocket-api-bedrock-streaming

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete --stack-name STACK_NAME.

Presented by Windrich

I am a Solutions Architect in AWS who works with customers in industries such as finance and transport, to help accelerate their cloud adoption journey. He is especially interested in Serverless technologies and how customers can leverage them to bring values to their business.

Follow on LinkedIn