Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`AnthropicBedrock` 2.x sends `anthropic_version: 2026-10-21`, which Bedrock rejects for Claude Sonnet 4.5, Opus 4.5 and Opus 4.6

Đang mở Phù hợp với người mới
#2,031 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@charan-rathore đang làm issue này rồi.

Từ ngày 23/10/2026.

  • #2032 của @charan-rathore — đang mở

Đá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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
aws, python
Lĩnh vực
backend, cloud

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

Mở trong Codespaces

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.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của anthropics/anthropic-sdk-python

Tất cả issue của anthropics/anthropic-sdk-python

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.