Skill 1.2.2

Create flexible architecture patterns to enable dynamic model selection and provider switching without requiring code modifications (for example, by using AWS Lambda, Amazon API Gateway, AWS AppConfig)

Key Concepts

A common pattern puts an API Gateway endpoint in front of a Lambda function that calls the model. The function reads the model ID, inference parameters and routing rules from AWS AppConfig, which validates configuration, deploys it gradually and rolls it back automatically if a CloudWatch alarm fires. The Lambda AppConfig extension caches the configuration locally so each invocation does not call AppConfig.

The Converse API makes switching practical because it uses one request and response format for all Bedrock models that support it, so changing modelId does not require rewriting the request body. To switch providers outside Bedrock, a provider abstraction layer in the function maps a common interface to each provider's API. Feature flags in AppConfig can send a percentage of traffic to a new model for comparison.