Streaming response with Amazon Bedrock and AWS Lambda function URLs

AWS Lambda → Amazon Bedrock

Create an LLM streaming response API with Lambda Function URLs.

This sample project demonstrates how to use an Lambda Function URL streaming ability and Bedrock runtime InvokeModelWithResponseStreamCommand to build an LLM response streaming API.
This pattern deploys a Lambda Function. Since Bedrock access is limited to certain Regions, user must set BEDROCK_AWS_ACCESS_KEY_ID and BEDROCK_AWS_SECRET_ACCESS_KEY environment variables for the Lambda Function to allow request across Regions.

< Back to all patterns

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/lambda-streaming-ttfb-write-sam-with-bedrock-streaming

Deploy

sam deploy


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Created by: