From 2488c791307c7a60c684fe1f8f155ca9f6df362d Mon Sep 17 00:00:00 2001 From: zapagenrevdale Date: Fri, 10 Oct 2025 13:42:37 +0800 Subject: [PATCH 1/2] docs(amazon-bedrock): add API key authentication documentation --- .../01-ai-sdk-providers/08-amazon-bedrock.mdx | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/content/providers/01-ai-sdk-providers/08-amazon-bedrock.mdx b/content/providers/01-ai-sdk-providers/08-amazon-bedrock.mdx index fc9e30d3ab74..dddad9849cdb 100644 --- a/content/providers/01-ai-sdk-providers/08-amazon-bedrock.mdx +++ b/content/providers/01-ai-sdk-providers/08-amazon-bedrock.mdx @@ -35,6 +35,18 @@ See the [Model Access Docs](https://docs.aws.amazon.com/bedrock/latest/userguide ### Authentication +The Amazon Bedrock provider supports API key authentication and AWS credentials (IAM/SigV4). API keys are recommended for simpler setup. + +#### Using API Key (Recommended) + +Set the `AWS_BEARER_TOKEN_BEDROCK` environment variable: + +```makefile +AWS_BEARER_TOKEN_BEDROCK=your-api-key-here +``` + +The API key will be automatically used. If not provided, the provider falls back to AWS credentials. + #### Using IAM Access Key and Secret Key **Step 1: Creating AWS Access Key and Secret Key** @@ -124,6 +136,13 @@ If you need a customized setup, you can import `createAmazonBedrock` from `@ai-s ```ts import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock'; +// With API key: +const bedrock = createAmazonBedrock({ + apiKey: 'your-api-key', + region: 'us-east-1', +}); + +// Or with IAM credentials: const bedrock = createAmazonBedrock({ region: 'us-east-1', accessKeyId: 'xxxxxxxxx', @@ -143,6 +162,10 @@ const bedrock = createAmazonBedrock({ You can use the following optional settings to customize the Amazon Bedrock provider instance: +- **apiKey** _string_ + + The API key for authentication. It uses the `AWS_BEARER_TOKEN_BEDROCK` environment variable by default. When provided, this takes precedence over AWS credentials. + - **region** _string_ The AWS region that you want to use for the API calls. From cc4a4bc98b9974de9aa993a70da215f6b359b501 Mon Sep 17 00:00:00 2001 From: zapagenrevdale Date: Fri, 10 Oct 2025 13:46:26 +0800 Subject: [PATCH 2/2] docs(amazon-bedrock): fix README to use createAmazonBedrock instead of non-existent withSettings --- packages/amazon-bedrock/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/amazon-bedrock/README.md b/packages/amazon-bedrock/README.md index 1b2ad764661d..f05b7d407e57 100644 --- a/packages/amazon-bedrock/README.md +++ b/packages/amazon-bedrock/README.md @@ -48,13 +48,13 @@ const { text } = await generateText({ #### Using Direct Configuration -You can also pass the API key directly in the provider configuration: +You can also pass the API key directly when creating a custom provider instance: ```ts -import { bedrock } from '@ai-sdk/amazon-bedrock'; +import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock'; import { generateText } from 'ai'; -const bedrockWithApiKey = bedrock.withSettings({ +const bedrockWithApiKey = createAmazonBedrock({ apiKey: process.env.AWS_BEARER_TOKEN_BEDROCK, // or your API key directly region: 'us-east-1', // Optional: specify region }); @@ -90,7 +90,7 @@ This method requires standard AWS environment variables: The provider uses the following authentication precedence: -1. **API key from direct configuration** (`apiKey` in `withSettings()`) +1. **API key from direct configuration** (`apiKey` in `createAmazonBedrock()`) 2. **API key from environment variable** (`AWS_BEARER_TOKEN_BEDROCK`) 3. **SigV4 authentication** (AWS credential chain fallback)