feat: add AWS Bedrock provider via Anthropic SDK - #9957
Conversation
b9e26aa to
b3754db
Compare
9e1f1d3 to
3b35991
Compare
Add Amazon Bedrock as a first-class provider using the Anthropic SDK's AnthropicBedrock class. Supports both SigV4 (IAM credentials) and bearer token (Bedrock API keys) authentication. Preserves all Claude features: streaming, prompt caching, reasoning, adaptive thinking. Supports Claude Code-compatible env vars: CLAUDE_CODE_USE_BEDROCK=1, AWS_REGION, ANTHROPIC_MODEL, ANTHROPIC_SMALL_FAST_MODEL, AWS_BEARER_TOKEN_BEDROCK, DISABLE_PROMPT_CACHING Also supports config.yaml: provider: bedrock (permanent setting). Changes: - agent/anthropic_adapter.py — build_bedrock_client(), is_bedrock_model_id(), preserve Bedrock ARNs in normalize_model_name() - hermes_cli/auth.py — ProviderConfig + aliases (bedrock, aws-bedrock, aws) - hermes_cli/runtime_provider.py — CLAUDE_CODE_USE_BEDROCK activation, Bedrock credential resolution (SigV4 + bearer auto-detect) - run_agent.py — Bedrock client init, switch_model, prompt caching, DISABLE_PROMPT_CACHING env var - agent/auxiliary_client.py — Bedrock aux model default - hermes_cli/model_normalize.py — pass-through for Bedrock model IDs - cli.py — skip base_url validation for Bedrock - pyproject.toml — boto3 as optional [bedrock] dependency, added to [all] - tests/agent/test_bedrock_provider.py — 48 unit tests
3b35991 to
c0743a6
Compare
|
Nice approach @renlon. Using Fair comparison table. A couple of notes from our side (#7920):
Honestly these two approaches complement each other well. AnthropicBedrock for Claude-heavy users who want full Anthropic feature parity, Converse API for multi-model users who want one provider for everything. Would be great if the maintainers could pick one as the base and cherry-pick the best parts from both. Happy to help consolidate. |
|
Thanks for the thoughtful comparison @JiaDe-Wu — and the work you put into #7920. I agree these two approaches are complementary rather than competing. Happy to coordinate either way: if your updated PR in #7920 already incorporates the AnthropicBedrock path (with prompt caching, thinking budgets, etc.), I'm fine dropping this one. Or we can get this merged first and you rebase #7920 on top to add the Converse API path for non-Claude models. Either way works — up to the repo maintainers to decide the order. |



Summary
Add Amazon Bedrock as an inference provider using the Anthropic SDK's
AnthropicBedrockclass — not the boto3 Converse API. This preserves Claude-specific features that the Converse API loses: streaming, reasoning/thinking with configurable budgets, and adaptive thinking.CLAUDE_CODE_USE_BEDROCK,ANTHROPIC_MODEL, etc.)ListFoundationModels+ListInferenceProfiles(filtered to Anthropic models)boto3added as optional dependency ([bedrock]extra), not a core requirementComparison with existing Bedrock PRs
Two other open Bedrock PRs (#8832 and #7920) both use the boto3 Converse API. This PR uses the Anthropic SDK's
AnthropicBedrockclass, reusing the existinganthropic_messagescode path with zero format conversion.anthropic_messages)User Configuration
Option 1: Environment variables (temporary)
Option 2: Config file (permanent)
~/.hermes/config.yaml:~/.hermes/.env:Option 3: boto3 default credential chain
Works with AWS_PROFILE, SSO, EC2/ECS/Lambda instance roles, and IRSA:
Model slug translation
Common Anthropic/OpenRouter model names are automatically mapped to Bedrock IDs:
anthropic/claude-opus-4.6→us.anthropic.claude-opus-4-6-v1claude-opus-4-5-20251101→us.anthropic.claude-opus-4-5-20251101-v1:0Install
Manual Test Results
Test Plan