Skip to content

Add AWS Bedrock configuration guide for SDK users #264

@jpshackelford

Description

@jpshackelford

Problem

Users trying to use the OpenHands Software Agent SDK with AWS Bedrock models (like Claude) often find it tricky to configure. The current documentation doesn't have a dedicated Bedrock guide, and users need to piece together information from the LiteLLM docs.

Common pain points:

  • Not knowing that boto3 is required (but doesn't need to be imported in user code)
  • Confusion about the bedrock/ model prefix format
  • Understanding which AWS authentication methods are supported
  • Finding the correct Bedrock model IDs

Suggestion

Add a Bedrock-specific guide to the LLM provider documentation, similar to the existing guides for Azure, Google, OpenRouter, etc.

Draft Tutorial

I've created a draft HTML tutorial that covers:

  1. Prerequisites and boto3 installation
  2. AWS credential configuration (multiple auth methods)
  3. Bedrock model name format
  4. Complete working code example
  5. Environment variable configuration

The key content that should be documented:

Installation

pip install openhands-sdk boto3>=1.28.57

Note: boto3 is used internally by LiteLLM - users don't need to import it in their code.

Authentication Options

Method Environment Variables
Access Keys AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY
Session Token AWS_SESSION_TOKEN
AWS Profile AWS_PROFILE_NAME
IAM Role AWS_ROLE_NAME, AWS_WEB_IDENTITY_TOKEN
Bedrock API Key AWS_BEARER_TOKEN_BEDROCK

Model Names

Use the bedrock/ prefix followed by the Bedrock model ID:

  • bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0
  • bedrock/anthropic.claude-3-opus-20240229-v1:0
  • bedrock/anthropic.claude-3-haiku-20240307-v1:0

Example Code

import os
from openhands.sdk import LLM, Agent, Conversation, Tool
from openhands.tools.terminal import TerminalTool
from openhands.tools.file_editor import FileEditorTool

os.environ["AWS_ACCESS_KEY_ID"] = "your-access-key"
os.environ["AWS_SECRET_ACCESS_KEY"] = "your-secret-key"
os.environ["AWS_REGION_NAME"] = "us-east-1"

llm = LLM(
    model="bedrock/anthropic.claude-3-5-sonnet-20241022-v2:0",
)

agent = Agent(
    llm=llm,
    tools=[
        Tool(name=TerminalTool.name),
        Tool(name=FileEditorTool.name),
    ],
)

conversation = Conversation(agent=agent, workspace=os.getcwd())
conversation.send_message("Your task here")
conversation.run()

Happy to help with a PR if this would be useful!

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions