Skip to main content

AWS Bedrock

The aws-bedrock provider supports all text-output models via the Converse API.

Quick Start​

client<llm> MyClient {
provider aws-bedrock
options {
model "anthropic.claude-3-sonnet-20240229-v1:0"
inference_configuration {
max_tokens 100
temperature 0.7
}
}
}

Authentication​

AWS Bedrock uses standard AWS authentication. BAML supports:

AWS Profile (Development)​

# ~/.aws/config
[default]
sso_start_url = https://your-sso.awsapps.com/start
sso_region = us-west-2
sso_account_id = 123456789012
sso_role_name = YourSSORole
region = us-west-2
client<llm> MyClient {
provider aws-bedrock
options {
profile "staging-profile"
model "anthropic.claude-3-sonnet-20240229-v1:0"
}
}

Environment Variables​

export AWS_ACCESS_KEY_ID="your_key"
export AWS_SECRET_ACCESS_KEY="your_secret"
export AWS_REGION="us-east-1"

Explicit Credentials​

client<llm> MyClient {
provider aws-bedrock
options {
access_key_id env.AWS_ACCESS_KEY_ID
secret_access_key env.AWS_SECRET_ACCESS_KEY
region "us-east-1"
model "anthropic.claude-3-sonnet-20240229-v1:0"
}
}

AWS Services (Lambda/ECS/EC2)​

BAML automatically uses IAM roles in AWS environments:

client<llm> MyClient {
provider aws-bedrock
options {
region "us-east-1"
model "anthropic.claude-3-sonnet-20240229-v1:0"
}
}

BAML-Specific Options​

OptionTypeDefaultDescription
regionstringenv.AWS_REGIONAWS region
access_key_idstringenv.AWS_ACCESS_KEY_IDAccess key
secret_access_keystringenv.AWS_SECRET_ACCESS_KEYSecret key
session_tokenstringenv.AWS_SESSION_TOKENSession token
profilestringenv.AWS_PROFILEAWS profile name
endpoint_urlstring-Custom endpoint (VPC)

Available Models​

Anthropic Claude​

  • anthropic.claude-opus-4-1-20250805-v1:0 - Most powerful
  • anthropic.claude-sonnet-4-20250514-v1:0 - Best default, 1M context
  • anthropic.claude-3-5-haiku-20241022-v1:0 - Fast and efficient

Meta Llama​

  • meta.llama4-maverick-17b-instruct-v1:0 - Latest Llama 4
  • meta.llama3-3-70b-instruct-v1:0 - Enhanced Llama 3.3

Run aws bedrock list-foundation-models | jq '.modelSummaries.[].modelId' to see all available models.

note

You must request model access before use.

Provider Parameters​

OptionTypeDescription
modelstringModel identifier (required)
inference_configurationobjectTemperature, max_tokens, top_p
additional_model_request_fieldsobjectModel-specific parameters

Inference Configuration​

client<llm> MyClient {
provider aws-bedrock
options {
model "anthropic.claude-3-sonnet-20240229-v1:0"
inference_configuration {
max_tokens 1000
temperature 1.0
top_p 0.8
}
}
}

Claude Thinking Models​

client<llm> MyClient {
provider aws-bedrock
options {
model "anthropic.claude-3-sonnet-20240229-v1:0"
additional_model_request_fields {
thinking {
type "enabled"
budget_tokens 1030
}
}
}
}

IAM Permissions​

Required permissions:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"bedrock:InvokeModel",
"bedrock:InvokeModelWithResponseStream"
],
"Resource": "arn:aws:bedrock:*:*:model/*"
}
]
}

Troubleshooting​

AccessDeniedException
  • Check IAM permissions
  • Verify execution role in Lambda/ECS
  • Ensure credentials have Bedrock access
Model not supported in Region
  • Check model availability in your region
  • Request model access if needed
  • Consider using a different region
Account not authorized to use model
  • Request model access through AWS Console
  • Wait for approval (1-2 business days)
  • Verify model ID is correct

See Also​