`AnthropicBedrock` 2.x sends `anthropic_version: 2026-10-21`, which Bedrock rejects for Claude Sonnet 4.5, Opus 4.5 and Opus 4.6
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 70/100
Hướng nghiên cứu
Bắt đầu tại src/anthropic/lib/bedrock/_client.py và kiểm tra cách ứng dụng khách Bedrock đặt giá trị mặc định cho anthropic_version; issue có các dòng đã thay đổi và một cách tái hiện lỗi. Thêm hoặc tìm các bài kiểm thử cho phần thân yêu cầu Bedrock, bao gồm cả các mô hình Claude cũ và mới. Hoàn thành khi các yêu cầu sử dụng phiên bản được các mô hình bị ảnh hưởng chấp nhận, đồng thời giữ nguyên hành vi ghi đè đã được tài liệu hóa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Since 2.0.0, the Bedrock client's default request body anthropic_version is the Messages API version 2026-10-21 instead of bedrock-2023-05-31:
# src/anthropic/lib/bedrock/_client.py
-DEFAULT_VERSION = "bedrock-2023-05-31"
- options.json_data.setdefault("anthropic_version", DEFAULT_VERSION)
+ options.json_data.setdefault("anthropic_version", ANTHROPIC_API_VERSION)
Bedrock rejects that value for some Claude models that are still available there:
anthropic.BadRequestError: Error code: 400 - {'message': 'Invalid API version: 2026-10-21'}
The same code works on 1.17.0. Newer models (Claude Opus 4.8, Sonnet 4.6, Haiku 4.5 and the Claude 5 family) accept the new value, so only the older models break. The 2.0.0 changelog doesn't mention any change to Bedrock (or Vertex) request versioning.
Reproduction
# pip install "anthropic[bedrock]==2.1.0"
# auth: AWS_BEARER_TOKEN_BEDROCK or the usual AWS credential chain
import anthropic
client = anthropic.AnthropicBedrock(aws_region="us-east-1")
for model in [
"us.anthropic.claude-sonnet-4-5-20250929-v1:0",
"global.anthropic.claude-opus-4-5-20251101-v1:0",
"us.anthropic.claude-opus-4-6-v1",
"us.anthropic.claude-opus-5-5", # works, for comparison
]:
for extra_body in (None, {"anthropic_version": "bedrock-2023-05-31"}):
try:
client.messages.create(
model=model,
max_tokens=16,
messages=[{"role": "user", "content": "Say ok"}],
extra_body=extra_body,
)
result = "ok"
except anthropic.APIStatusError as e:
result = f"{e.status_code} {e.message}"
print(f"{model:48} override={extra_body is not None!s:5} -> {result}")
Output with anthropic==2.1.0:
us.anthropic.claude-sonnet-4-5-20250929-v1:0 override=False -> 400 Error code: 400 - {'message': 'Invalid API version: 2026-10-21'}
us.anthropic.claude-sonnet-4-5-20250929-v1:0 override=True -> ok
global.anthropic.claude-opus-4-5-20251101-v1:0 override=False -> 400 Error code: 400 - {'message': 'Invalid API version: 2026-10-21'}
global.anthropic.claude-opus-4-5-20251101-v1:0 override=True -> ok
us.anthropic.claude-opus-4-6-v1 override=False -> 400 Error code: 400 - {'message': 'Invalid API version: 2026-10-21'}
us.anthropic.claude-opus-4-6-v1 override=True -> ok
us.anthropic.claude-opus-5-5 override=False -> ok
us.anthropic.claude-opus-5-5 override=True -> ok
With anthropic==1.17.0, all eight requests succeed, since the default there is bedrock-2023-05-31.
Expected behavior
The Bedrock client sends a version that every Claude model on Bedrock accepts, as 1.x did, or it picks the version per model.
Workaround
Pass extra_body={"anthropic_version": "bedrock-2023-05-31"}. The client only sets the field when the body doesn't already have one.
Possibly related
2.0.0 made the same change to AnthropicVertex (vertex-2023-10-16 → 2026-10-21). I couldn't verify whether Vertex rejects it for any models.
Environment
- anthropic 2.1.0 (2.0.0 has the same default); works on 1.17.0
- Python 3.13
- Bedrock region us-east-1
- Ngôn ngữ chính
- Python
- Star
- 4k
- Fork
- 892
- Merge trung bình
- 6 phút
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của anthropics/anthropic-sdk-python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 61/100
anthropics/anthropic-sdk-python#2029 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Fix test collection and execution errors on Windows (geteuid, FileStore skip, bedrock tempfile lock)Có thể đã có người làm @prasad2512 đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
anthropics/anthropic-sdk-python#2027 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Three symlink tests in test_agent_toolset.py are missing the needs_symlinks markerCó thể đã có người làm @okxint đã nhận 48 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
anthropics/anthropic-sdk-python#1915 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Messages.parse (and AsyncMessages.parse) don't take cache_control?Có thể đã có người làm @Alphaxiaoteng đã nhận 52 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
anthropics/anthropic-sdk-python#1907 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Windows: os.fchmod in credential write-back bricks the OAuth refresh tokenCó thể đã có người làm @OllieinCanada đã nhận 64 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
anthropics/anthropic-sdk-python#1868 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của anthropics/anthropic-sdk-python
Issue tương tự
-
Project submission:Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 72/100
slavakurilyak/awesome-ai-agents#845 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directoryCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởdifficulty:2 enhancement good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
MakazhanAlpamys/Soup#2178 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-valuesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
scverse/rapids-singlecell#854 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGLCó thể đã có người làm @ninglinLiu đã nhận hôm nay. Đang mởarea:frontend backend:slang bug direction:input
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
random_elements(unique=True) on an OrderedDict: ZeroDivisionError once only zero weights remain, AssertionError with use_weighting=FalseCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 13 ngày