diff --git a/docs/src/content/docs/configuration/anthropic-bedrock.mdx b/docs/src/content/docs/configuration/anthropic-bedrock.mdx
index 73d130916c..0360b0b5cb 100644
--- a/docs/src/content/docs/configuration/anthropic-bedrock.mdx
+++ b/docs/src/content/docs/configuration/anthropic-bedrock.mdx
@@ -26,12 +26,78 @@ import LLMProviderFeatures from "../../../components/LLMProviderFeatures.astro";
The `anthropic_bedrock` provider accesses Anthropic models on Amazon Bedrock. You can find the model names in the [Anthropic model documentation](https://docs.anthropic.com/en/docs/about-claude/models#model-names).
-GenAIScript assumes that you have configured Amazon Web Services (AWS) credentials
-in a way that the [AWS Node SDK will recognize](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html).
-
```js "anthropic_bedrock:"
script({
model:
"anthropic_bedrock:anthropic.claude-3-sonnet-20240229-v1:0",
});
```
+
+## Configuration
+
+GenAIScript supports multiple ways to configure AWS credentials for Bedrock access:
+
+### Required Environment Variables
+
+- `AWS_REGION` - The AWS region where Bedrock is enabled (e.g., `us-east-1`, `us-west-2`)
+
+### Authentication Options
+
+Choose one of the following authentication methods:
+
+
+
+```bash
+export AWS_ACCESS_KEY_ID="AKIA..."
+export AWS_SECRET_ACCESS_KEY="..."
+export AWS_SESSION_TOKEN="..." # Optional, for temporary credentials
+```
+
+
+
+```bash
+export AWS_PROFILE="my-profile"
+```
+
+
+
+```bash
+export AWS_BEARER_TOKEN_BEDROCK="your-bedrock-api-key"
+```
+
+
+
+### Optional Environment Variables
+
+- `ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION` - Override AWS region for small/fast models
+- `DISABLE_PROMPT_CACHING` - Set to `1` to disable Anthropic prompt caching
+- `ANTHROPIC_MODEL` - Override the default Anthropic model ID for Bedrock
+
+### Setup Steps
+
+
+
+1. **Enable Bedrock Access**
+
+ Request access to Claude models in the [Amazon Bedrock console](https://console.aws.amazon.com/bedrock/) under "Model Access".
+
+2. **Configure Credentials**
+
+ Set up your AWS credentials using one of the methods above. GenAIScript follows the standard [AWS credential provider chain](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html).
+
+3. **Set Region**
+
+ Configure the AWS region where you have Bedrock access:
+ ```bash
+ export AWS_REGION="us-east-1"
+ ```
+
+4. **Test Configuration**
+
+ ```bash
+ genaiscript configure anthropic_bedrock
+ ```
+
+
+
+
diff --git a/packages/core/src/env.ts b/packages/core/src/env.ts
index 1ef290335f..0f00c0f4d6 100644
--- a/packages/core/src/env.ts
+++ b/packages/core/src/env.ts
@@ -535,6 +535,43 @@ export async function parseTokenFromEnv(
if (provider === MODEL_PROVIDER_ANTHROPIC_BEDROCK) {
dbg(`processing ${MODEL_PROVIDER_ANTHROPIC_BEDROCK}`);
+
+ // AWS region is required for Bedrock
+ const region = env.AWS_REGION;
+ if (!region) {
+ throw new Error("AWS_REGION is required for Anthropic Bedrock");
+ }
+
+ // Check for AWS credentials or Bedrock API key
+ const hasAwsCredentials = env.AWS_ACCESS_KEY_ID && env.AWS_SECRET_ACCESS_KEY;
+ const hasBedrockApiKey = env.AWS_BEARER_TOKEN_BEDROCK;
+ const hasAwsProfile = env.AWS_PROFILE;
+
+ if (!hasAwsCredentials && !hasBedrockApiKey && !hasAwsProfile) {
+ throw new Error(
+ "AWS credentials are required for Anthropic Bedrock. Set AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY, AWS_BEARER_TOKEN_BEDROCK, or AWS_PROFILE",
+ );
+ }
+
+ dbg(`AWS region: ${region}`);
+ if (hasAwsCredentials) {
+ dbg("using AWS access key credentials");
+ if (env.AWS_SESSION_TOKEN) dbg("with session token (temporary credentials)");
+ }
+ if (hasBedrockApiKey) dbg("using AWS Bedrock API key");
+ if (hasAwsProfile) dbg(`using AWS profile: ${env.AWS_PROFILE}`);
+
+ // Log optional configurations
+ if (env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION) {
+ dbg(`small/fast model region override: ${env.ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION}`);
+ }
+ if (env.DISABLE_PROMPT_CACHING) {
+ dbg(`prompt caching disabled: ${env.DISABLE_PROMPT_CACHING}`);
+ }
+ if (env.ANTHROPIC_MODEL) {
+ dbg(`model override: ${env.ANTHROPIC_MODEL}`);
+ }
+
return {
provider,
model,
@@ -542,6 +579,8 @@ export async function parseTokenFromEnv(
source: "AWS SDK",
base: undefined,
token: MODEL_PROVIDER_ANTHROPIC_BEDROCK,
+ // Store AWS-specific configuration for reference
+ version: region,
} satisfies LanguageModelConfiguration;
}
@@ -938,7 +977,7 @@ export function parseAllowedDomains(env: Record): string[] {
try {
const parsed = YAMLTryParse(envValue);
if (Array.isArray(parsed)) {
- return parsed.filter(domain => typeof domain === 'string' && domain.trim());
+ return parsed.filter((domain) => typeof domain === "string" && domain.trim());
}
} catch {
// Fall through to comma-separated parsing
@@ -946,9 +985,9 @@ export function parseAllowedDomains(env: Record): string[] {
// Parse as comma-separated list
return envValue
- .split(',')
- .map(domain => domain.trim())
- .filter(domain => domain.length > 0);
+ .split(",")
+ .map((domain) => domain.trim())
+ .filter((domain) => domain.length > 0);
}
/**
diff --git a/packages/core/src/llmsdata.ts b/packages/core/src/llmsdata.ts
index 5f2b7120e9..499d5d301e 100644
--- a/packages/core/src/llmsdata.ts
+++ b/packages/core/src/llmsdata.ts
@@ -460,7 +460,41 @@ export default {
vision: "anthropic.claude-3-7-sonnet-20250219-v1:0:0",
vision_small: "anthropic.claude-3-5-haiku-20241022-v1:0",
},
- env: {},
+ env: {
+ AWS_REGION: {
+ description: "AWS region where Bedrock is enabled (required)",
+ required: true,
+ },
+ AWS_ACCESS_KEY_ID: {
+ description: "AWS access key ID for authentication",
+ secret: true,
+ },
+ AWS_SECRET_ACCESS_KEY: {
+ description: "AWS secret access key for authentication",
+ secret: true,
+ },
+ AWS_SESSION_TOKEN: {
+ description: "AWS session token for temporary credentials",
+ secret: true,
+ },
+ AWS_PROFILE: {
+ description: "AWS profile name to use for authentication",
+ },
+ AWS_BEARER_TOKEN_BEDROCK: {
+ description: "AWS Bedrock API key for simplified authentication",
+ secret: true,
+ },
+ ANTHROPIC_SMALL_FAST_MODEL_AWS_REGION: {
+ description: "Override AWS region for small/fast models",
+ },
+ DISABLE_PROMPT_CACHING: {
+ description: "Set to '1' to disable Anthropic prompt caching",
+ enum: ["1", "true"],
+ },
+ ANTHROPIC_MODEL: {
+ description: "Override the default Anthropic model ID for Bedrock",
+ },
+ },
},
{
id: "google",