Regional model access
An application must explicitly choose its AWS region for Bedrock requests.
AI Tools · Function
Creates a customized Amazon Bedrock provider for the AI SDK. Configure AWS settings such as the region and credential provider, then use the returned provider to select Bedrock models.
createAmazonBedrock constructs a customized provider instance for Amazon Bedrock. Configure it with a region and AWS credential settings or a credential provider, then call the resulting provider with a model identifier to obtain a language model.
createAmazonBedrock(options)| Name | Type | Description |
|---|---|---|
options | CreateAmazonBedrockOptions | Configuration object containing Amazon Bedrock provider settings, including region and AWS credential options. |
A customized Amazon Bedrock provider instance that can be called with a model identifier.
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
const bedrock = createAmazonBedrock({
region: 'us-east-1',
credentialProvider: fromNodeProviderChain(),
});
const model = bedrock('anthropic.claude-3-5-sonnet-20240620-v1:0');Creates a customized Amazon Bedrock provider using an AWS region and credential provider, then uses it to select a model.
An application must explicitly choose its AWS region for Bedrock requests.
A server uses the AWS SDK's standard runtime credential resolution.
Different application components require separate Bedrock configurations.
createAmazonBedrock is the factory for a customized Amazon Bedrock provider. The returned provider can be configured with settings such as an AWS region and credential provider, then called with a model identifier.
Follow-up: How would you avoid hard-coding credentials? Use the AWS SDK credential provider chain and pass it through credentialProvider, allowing the runtime to resolve credentials from its configured sources.
Import createAmazonBedrock from @ai-sdk/amazon-bedrock and call it with provider settings. A typical configuration supplies region: 'us-east-1' and credentialProvider: fromNodeProviderChain().
Follow-up: What alternative exists for an uncustomized setup? Import the package's default bedrock provider instance instead of creating a new one.
The factory returns a provider instance that is then invoked with a Bedrock model identifier. That model handle can be supplied to AI SDK generation APIs.
Follow-up: Why might a team create multiple instances? Separate instances can represent different regions or credential configurations while retaining the same provider interface.
bedrockcreateBedrockAnthropic@ai-sdk/amazon-bedrockfromNodeProviderChain