Dynamic Amazon Bedrock model selection with Amazon API Gateway

API Gateway → AWS Lambda → Amazon Bedrock

Generates image or text responses using Amazon Bedrock models with API Gateway and Lambda integrations

This pattern creates a REST API that has /image and /text resources. Both resources integrate with a Lambda function over proxy integration.
The /image POST endpoint generates an image using StabilityAI Stable Diffusion XL model.
The /text/{model} POST method with the required prompt generates a text output using various Bedrock models offered by Anthropic, AI21 labs.

< Back to all patterns

GitHub icon Download this pattern (.zip)

GitHub icon View this pattern on GitHub


Clone repo

git clone https://github.com/aws-samples/serverless-patterns/cd serverless-patterns/dynamic-bedrock-svls-sam

Deploy

sam deploy --guided


Testing

See the GitHub repo for detailed testing instructions.

Cleanup

Delete the stack: sam delete.

Additional resources

Created by:

Abha Tripathi

Abha Tripathi

Cloud Engineer @ AWS

Follow on LinkedIn

Sushir V R

Sushir V R

Cloud Engineer @ AWS

Follow on LinkedIn