

# 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
<a name="integrations-bedrock-models"></a>

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
<a name="integrations-bedrock-env-vars"></a>

When you connect a Bedrock integration, Amplify sets the following environment variables:


| Variable | Value | 
| --- | --- | 
|  `BEDROCK_REGION`  | The integration’s AWS Region. Always set. | 
|  `BEDROCK_MODEL_ID`  | The pinned model or inference profile ID. Set only when the integration pins a model. | 

## Permissions for Bedrock
<a name="integrations-bedrock-permissions"></a>

The integration grants your app the following permissions:
+  `bedrock:InvokeModel`, `bedrock:InvokeModelWithResponseStream`, and `bedrock:GetInferenceProfile` on the pinned model, or on all models if the integration doesn’t pin one.
+  `bedrock:ListFoundationModels`, `bedrock:GetFoundationModel`, `bedrock:GetFoundationModelAvailability`, and `bedrock:ListInferenceProfiles` on 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
<a name="integrations-bedrock-create"></a>

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](bedrock/latest/userguide/model-access.html). 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
<a name="_create_a_bedrock_integration_in_the_console"></a>

1. Sign in to the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home.

1. For **Integrations**, choose **Add**.

1. For **Select integration**, select **Amazon Bedrock**, and then choose **Add**.

1. For **Integration name**, enter a unique integration name.

1. For **Bedrock model**, choose the model for your integration. Amplify sets `BEDROCK_MODEL_ID` to this model.

1. (Optional) Choose **Connect to app**, select your app, and then choose the environments to connect the integration to.

1. Choose **Add**.

### Create a Bedrock integration using the CLI
<a name="_create_a_bedrock_integration_using_the_cli"></a>

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](bedrock/latest/userguide/models-supported.html).

```bash
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
<a name="integrations-bedrock-code"></a>

The following example uses the [Amazon Bedrock provider on the AI SDK website](https://ai-sdk.dev/providers/ai-sdk-providers/amazon-bedrock). Set the provider’s Region to `BEDROCK_REGION`, so that requests go to the integration’s Region instead of the app’s.

```bash
npm install ai @ai-sdk/amazon-bedrock @aws-sdk/credential-providers
```

```typescript
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
<a name="integrations-bedrock-delete"></a>

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
<a name="_delete_a_bedrock_integration_in_the_console"></a>

1. Sign in to the Amplify console at https://us-east-2.console.aws.amazon.com/amplifygen3/home.

1. For **Integrations**, choose your Bedrock integration.

1. Choose **Delete**.

1. Confirm your choice and choose **Delete**.

### Delete a Bedrock integration using the CLI
<a name="_delete_a_bedrock_integration_using_the_cli"></a>

The following commands disconnect the integration from the `preview` environment and then delete it.

```bash
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`.