Amazon Bedrock
Amazon Bedrock is a fully managed service that offers foundation models from leading AI companies through a single API. You can use Bedrock to build generative AI applications with text generation, summarization, image generation, and conversational experiences without managing any infrastructure.
Choose the models your app can use
With a Bedrock integration, you can pin one model or let your app use all models:
-
One model – Your app can call only that model. You can pin a foundation model or a system-defined cross-Region inference profile, such as
us.anthropic.<model>. -
All models – Your app can call any foundation model or inference profile, in any AWS Region. Cross-Region inference profiles route requests to the Region that has capacity, so access isn’t limited to one Region.
Pin the model that your app uses, so that it can call only that model.
Environment variables for Bedrock
When you connect a Bedrock integration, Amplify sets the following environment variables:
| Variable | Value |
|---|---|
|
|
The integration’s AWS Region. Always set. |
|
|
The pinned model or inference profile ID. Set only when the integration pins a model. |
Permissions for Bedrock
The integration grants your app the following permissions:
-
bedrock:InvokeModel,bedrock:InvokeModelWithResponseStream, andbedrock:GetInferenceProfileon the pinned model, or on all models if the integration doesn’t pin one. -
bedrock:ListFoundationModels,bedrock:GetFoundationModel,bedrock:GetFoundationModelAvailability, andbedrock:ListInferenceProfileson all resources, so that your app can look up models.
For an inference profile, the invoke permissions cover the profile and each model that it routes to. The Converse API uses the same permissions as InvokeModel.
Create a Bedrock integration
Before you create a Bedrock integration, call each new model once yourself, so that your AWS account can use it. A model from AWS Marketplace needs aws-marketplace:Subscribe on its first call, and the integration doesn’t grant that permission. Anthropic models released before Claude Opus 4.7 also need a one-time use case submission. For more information, see Request access to models. Amplify doesn’t request model access for you, and it rejects a model that has reached its end of life.
Create a Bedrock integration in the console
-
Sign in to the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home.
-
For Integrations, choose Add.
-
For Select integration, select Amazon Bedrock, and then choose Add.
-
For Integration name, enter a unique integration name.
-
For Bedrock model, choose the model for your integration. Amplify sets
BEDROCK_MODEL_IDto this model. -
(Optional) Choose Connect to app, select your app, and then choose the environments to connect the integration to.
-
Choose Add.
Create a Bedrock integration using the CLI
The following command creates a Bedrock integration that pins one model and connects it to the preview and production environments. Replace my-app with the name of your app. For --arn, enter the ARN of a foundation model or of a system-defined inference profile, replacing region and model-id. For the current models, see Supported foundation models in Amazon Bedrock.
aws amplifygen3 integration connect bedrock --name my-ai --app my-app \ --arn arn:aws:bedrock:region::foundation-model/model-id \ --env preview --env production
To allow all models, leave out --arn.
For a system-defined inference profile, pass its ARN in the form arn:aws:bedrock:<region>:<account-id>:inference-profile/<profile-id>. Application inference profiles aren’t supported.
Use Bedrock in your code
The following example uses the Amazon Bedrock provider on the AI SDK websiteBEDROCK_REGION, so that requests go to the integration’s Region instead of the app’s.
npm install ai @ai-sdk/amazon-bedrock @aws-sdk/credential-providers
import { createAmazonBedrock } from "@ai-sdk/amazon-bedrock"; import { fromNodeProviderChain } from "@aws-sdk/credential-providers"; import { generateText } from "ai"; const bedrock = createAmazonBedrock({ region: process.env.BEDROCK_REGION, credentialProvider: fromNodeProviderChain(), }); const { text } = await generateText({ model: bedrock(process.env.BEDROCK_MODEL_ID!), prompt: "Explain quantum computing in simple terms.", });
The fromNodeProviderChain() credential provider uses your app’s permissions when it runs on Amplify, and your local AWS credentials when you run it locally. To get the variables locally, run aws amplifygen3 var download .env.local --env preview.
This example assumes that the integration pins a model. If it doesn’t, BEDROCK_MODEL_ID isn’t set and bedrock(undefined) fails. Store the model ID in an environment variable of your own, such as AI_MODEL_ID, and read that instead: bedrock(process.env.BEDROCK_MODEL_ID ?? process.env.AI_MODEL_ID!).
Delete a Bedrock integration
Before you delete an integration, disconnect it from every environment, and then redeploy those environments so that they stop using it. Deleting the integration doesn’t remove model access from your account.
Delete a Bedrock integration in the console
-
Sign in to the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home.
-
For Integrations, choose your Bedrock integration.
-
Choose Delete.
-
Confirm your choice and choose Delete.
Delete a Bedrock integration using the CLI
The following commands disconnect the integration from the preview environment and then delete it.
aws amplifygen3 integration disconnect --name my-ai --env preview aws amplifygen3 integration delete --name my-ai
The delete command asks for confirmation. In a non-interactive session such as CI, add --yes.