Skip to main content

Prerequisites

AWS Bedrock requires the boto3 library to be installed. This is used internally by LiteLLM - you don’t need to import it in your code.
pip install boto3>=1.28.57

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

MethodEnvironment Variables
Access KeysAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
Session TokenAWS_SESSION_TOKEN (in addition to access keys)
AWS ProfileAWS_PROFILE_NAME
IAM RoleAWS_ROLE_NAME, AWS_WEB_IDENTITY_TOKEN
Bedrock API KeyAWS_BEARER_TOKEN_BEDROCK

Example with Access Keys

docker run -it --pull=always \
    -e AWS_ACCESS_KEY_ID="your-access-key" \
    -e AWS_SECRET_ACCESS_KEY="your-secret-key" \
    -e AWS_REGION_NAME="us-east-1" \
    ...
Then in the OpenHands UI Settings under the LLM tab:
  1. Enable Advanced options.
  2. Set the following:
    • Custom Model to bedrock/<model-id> (e.g., bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0)

Model Names

Use the bedrock/ prefix followed by the Bedrock model ID:
ModelModel ID
Claude 3.5 Sonnet v2bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0
Claude 3 Opusbedrock/anthropic.claude-3-opus-20240229-v1:0
Claude 3 Haikubedrock/anthropic.claude-3-haiku-20240307-v1:0
Claude 3.5 Haikubedrock/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:
bedrock/us.anthropic.claude-3-5-sonnet-20241022-v2:0

Troubleshooting

Common Issues

  1. Access Denied: Ensure your AWS credentials have the necessary permissions for Bedrock. You need bedrock:InvokeModel permission.
  2. Model Not Found: Verify that the model is enabled in your AWS account. Go to AWS Console > Bedrock > Model access to enable models.
  3. Region Issues: Make sure AWS_REGION_NAME is set to a region where Bedrock is available and where you have model access enabled.