Add Amazon Bedrock support for Claude models#66
Add Amazon Bedrock support for Claude models#66gbaydin wants to merge 2 commits intohuggingface:mainfrom
Conversation
Route `bedrock/<model>` model IDs through LiteLLM's Bedrock adapter with the same thinking/effort params as the `anthropic/` path. LiteLLM handles AWS auth (access keys or bearer token for SSO). Also adds boto3 as a core dependency (required by LiteLLM's Bedrock adapter). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ption) The retry loop previously only wrapped the acompletion() call. Transient errors during stream iteration (async for chunk in response) crashed the agent. Now the entire streaming path is inside the retry loop — on a mid-stream failure, partial content is discarded and the call retries. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@claude please review this PR. Focus on correctness, security, LiteLLM/Bedrock routing impact, and whether it's safe to merge against current main. Keep it concise and prefer inline comments where it matters. |
|
Claude finished @akseljoonas's task in 2m 38s —— View job PR Review: Add Amazon Bedrock Support
Verdict: LGTM with two items to address. The core routing logic is correct and the mid-stream retry fix is a genuine improvement. Two issues worth resolving before merge, one moderate and one minor. Commit 1 —
|
| Item | Severity | Notes |
|---|---|---|
boto3 as core dep |
Moderate | ~30 MB penalty for all users; should be optional extra |
Cross-region profile ID → 200k fallback in _get_max_tokens_safe |
Minor | Premature compaction for Opus users with us. prefix |
| Mid-stream retry fix | ✅ | Genuine bug fix, correct implementation |
| Bedrock effort/thinking routing | ✅ | Correct; cascade covers degradation |
| Existing paths unchanged | ✅ | Verified by inspection |
Summary
bedrock/<model>model IDs through LiteLLM's Bedrock adapter with the same thinking/effort params as theanthropic/path (same Claude models, same API shape)boto3as a core dependency (required by LiteLLM's Bedrock adapter)Usage
Test plan
_resolve_llm_paramsreturns correct params forbedrock/prefixis_valid_model_idacceptsbedrock/model IDs_get_max_tokens_safereturns 1M forbedrock/anthropic.claude-opus-4-6-v1anthropic/,openai/, and HF router paths are unchanged/model bedrock/us.anthropic.claude-opus-4-6-v1end-to-end with live AWS credentials🤖 Generated with Claude Code