Switching Models Without Code Changes
This lesson describes architectures that make the model, its parameters and even the provider a configuration choice, so applications do not need a release whenever models improve, prices fall or providers appear.
Learning outcomes
After completing this lesson, you will be able to:
- Use the Converse API as a provider-neutral abstraction.
- Store model configuration in AWS AppConfig and deploy it safely.
- Build a model abstraction layer with API Gateway and Lambda.
The Converse API as an abstraction
Each model provider on Amazon Bedrock defines its own request body for the InvokeModel API, so code written for one provider's format must be rewritten to use another provider's model. The Converse API removes this dependency. It offers one request and response format for all Bedrock models that support messages, covering system prompts, multi-turn conversations, images and documents, tool use and streaming through ConverseStream, and it returns token usage and the stop reason in a consistent structure.
With the Converse API, switching between supported models requires only a different modelId, which can come from configuration rather than code. Differences between models do not disappear entirely: models differ in the features they support, such as tool use or document input, and in some parameters. Common parameters go in inferenceConfig, while parameters specific to one provider are passed in additionalModelRequestFields, which can also be held in configuration for each model.
What the Converse API changes
Configuration in AWS AppConfig
AWS AppConfig, a capability of AWS Systems Manager, stores application configuration and deploys it safely. A configuration profile, for example a JSON document, maps each use case to a model ID or inference profile, prompt version, inference parameters and fallback model. AppConfig validators (a JSON Schema or a Lambda function) reject invalid configurations, deployment strategies roll changes out gradually, and CloudWatch alarms trigger automatic rollback if errors rise during deployment.
Feature flags in AppConfig can enable a new model for a percentage of users or for specific tenants. Lambda functions read configuration through the AppConfig Lambda extension, which caches it locally and refreshes it in the background, so each invocation reads from memory instead of calling the service.
# Configuration profile "model-routing" (JSON), validated with a JSON Schema
{
"summarize": {"modelId": "us.amazon.nova-lite-v1:0", "temperature": 0.2, "maxTokens": 400,
"fallback": "us.amazon.nova-micro-v1:0"},
"reason": {"modelId": "us.amazon.nova-premier-v1:0", "temperature": 0.3, "maxTokens": 1500,
"fallback": "us.amazon.nova-pro-v1:0"}
}The following diagram shows a model change moving through AWS AppConfig to the Lambda functions that call the model.

Switching a model with AppConfig
API Gateway and Lambda as a model abstraction layer
Applications call a stable API, such as POST /v1/generate with a use case name, exposed by Amazon API Gateway. A Lambda function looks up the use case in the configuration, calls the configured model and returns a normalised response. Clients never see model IDs, so switching models or providers changes only configuration.
To switch providers outside Bedrock, the function implements an adapter per provider that maps the common request to that provider's API and its response back, with credentials in AWS Secrets Manager. The same layer is the natural place for routing, fallback, logging and cost attribution, which is the basis of the GenAI gateway pattern covered in a later module. The following table compares the places where a model choice can live.
| Where the model choice lives | Change requires | Suitability |
|---|---|---|
| Hard-coded in application | Code change and deployment | Prototypes only |
| Environment variable | Function configuration update | Simple, no gradual rollout or validation |
| AppConfig configuration profile | Configuration deployment | Validated, gradual, automatic rollback |
| Prompt Management prompt version | Promoting a new prompt version | Model tied to a specific prompt |
The following diagram shows the abstraction layer between clients and models.

Switching models safely
A company wants to move its summarisation feature to a newer, cheaper model, test it on 10% of traffic, and revert automatically if error rates rise, with no application deployment.
Storing the model ID in an environment variable would require updating every function and offers no gradual rollout. The answer is an AppConfig feature flag or configuration profile read by the Lambda function through the AppConfig extension, deployed with a gradual deployment strategy and a CloudWatch alarm on the error metric for automatic rollback, with the Converse API so the request format does not change.
What does the AWS AppConfig Lambda extension add?
Show answer
It retrieves and caches configuration locally, so functions read the current model ID without calling AppConfig on every invocation.
Exam Tips
Remember for the exam
- Converse API: switch Bedrock models by changing modelId only.
- AppConfig: validated, gradual configuration deployment with automatic rollback.
- AppConfig Lambda extension caches configuration locally.
- A stable API in front of models lets you switch providers without client changes.