Prerequisites
AWS Bedrock requires theboto3 library to be installed. This is used internally by LiteLLM - you don’t need to import it in your code.
AWS Bedrock Configuration
When running OpenHands, you’ll need to set AWS credentials using environment variables with-e in the docker run command.
Authentication Options
| Method | Environment Variables |
|---|---|
| Access Keys | AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY |
| Session Token | AWS_SESSION_TOKEN (in addition to access keys) |
| AWS Profile | AWS_PROFILE_NAME |
| IAM Role | AWS_ROLE_NAME, AWS_WEB_IDENTITY_TOKEN |
| Bedrock API Key | AWS_BEARER_TOKEN_BEDROCK |
Example with Access Keys
LLM tab:
- Enable
Advancedoptions. - Set the following:
Custom Modeltobedrock/<model-id>(e.g.,bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0)
Model Names
Use thebedrock/ prefix followed by the Bedrock model ID:
| Model | Model ID |
|---|---|
| Claude 3.5 Sonnet v2 | bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0 |
| Claude 3 Opus | bedrock/anthropic.claude-3-opus-20240229-v1:0 |
| Claude 3 Haiku | bedrock/anthropic.claude-3-haiku-20240307-v1:0 |
| Claude 3.5 Haiku | bedrock/anthropic.claude-3-5-haiku-20241022-v1:0 |
You can find the full list of available Bedrock model IDs in the AWS Bedrock documentation or in the AWS Console under Bedrock > Model access.
Cross-Region Inference
AWS Bedrock supports cross-region inference for improved availability. To use it, include the region in your model ID:Troubleshooting
Common Issues
-
Access Denied: Ensure your AWS credentials have the necessary permissions for Bedrock. You need
bedrock:InvokeModelpermission. - Model Not Found: Verify that the model is enabled in your AWS account. Go to AWS Console > Bedrock > Model access to enable models.
-
Region Issues: Make sure
AWS_REGION_NAMEis set to a region where Bedrock is available and where you have model access enabled.

