anthropic 1.29.0 → 1.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/anthropic/bedrock_mantle.rb +5 -0
- data/lib/anthropic/helpers/aws_auth.rb +15 -13
- data/lib/anthropic/helpers/bedrock/mantle_client.rb +144 -0
- data/lib/anthropic/version.rb +1 -1
- data/lib/anthropic.rb +2 -0
- data/rbi/anthropic/bedrock_mantle.rbi +5 -0
- data/rbi/anthropic/helpers/bedrock/mantle_client.rbi +65 -0
- metadata +5 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5c319af9296b5376b7e999da1ce9563eb2b9d57e964515787960c466823dc2d0
|
|
4
|
+
data.tar.gz: 499a2e9960fd6ba4ba1f8c9346c96d1cf178a981585cea2221a07471eb80a964
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbb5565e655c1d1f493f170dd4e67786903ba6c61ef77cc6c673078ce8308431087d38f5c094519031715993521e5960d47a3530d2284ad36d737483a479878b
|
|
7
|
+
data.tar.gz: 0ca0deffd146b0a417f915f5e51abdb5276399d3591c829477be11432ef1f5fcc48fbc97128aecfdf300486693f5dde1dd7b2a59a81eca2bcb2811fae783f1e7
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.30.0 (2026-04-07)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [v1.29.0...v1.30.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.29.0...v1.30.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **bedrock:** Create Bedrock Mantle client ([#874](https://github.com/anthropics/anthropic-sdk-ruby/issues/874)) ([627135f](https://github.com/anthropics/anthropic-sdk-ruby/commit/627135fbcf4fd02ed1370c3d209be7c23736f3d8))
|
|
10
|
+
|
|
3
11
|
## 1.29.0 (2026-04-07)
|
|
4
12
|
|
|
5
13
|
Full Changelog: [v1.28.0...v1.29.0](https://github.com/anthropics/anthropic-sdk-ruby/compare/v1.28.0...v1.29.0)
|
data/README.md
CHANGED
|
@@ -32,14 +32,14 @@ module Anthropic
|
|
|
32
32
|
aws_session_token:,
|
|
33
33
|
aws_profile:,
|
|
34
34
|
aws_region:,
|
|
35
|
-
workspace_id:,
|
|
36
35
|
skip_auth:,
|
|
37
36
|
base_url:,
|
|
38
37
|
service_name:,
|
|
39
38
|
env_api_key:,
|
|
40
|
-
env_workspace_id:,
|
|
41
39
|
derive_base_url:,
|
|
40
|
+
workspace_id: nil,
|
|
42
41
|
env_api_key_fallback: nil,
|
|
42
|
+
env_workspace_id: nil,
|
|
43
43
|
env_workspace_id_fallback: nil
|
|
44
44
|
)
|
|
45
45
|
begin
|
|
@@ -101,17 +101,19 @@ module Anthropic
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
# Workspace ID: constructor > primary env > fallback env
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
resolved_workspace_id
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
if env_workspace_id
|
|
105
|
+
resolved_workspace_id = workspace_id
|
|
106
|
+
if resolved_workspace_id.to_s.empty?
|
|
107
|
+
resolved_workspace_id = env_lookup(env_workspace_id, env_workspace_id_fallback)
|
|
108
|
+
end
|
|
109
|
+
@workspace_id = resolved_workspace_id.to_s.empty? ? nil : resolved_workspace_id.to_s
|
|
110
|
+
|
|
111
|
+
unless @skip_auth
|
|
112
|
+
if @workspace_id.nil?
|
|
113
|
+
# rubocop:disable Layout/LineLength
|
|
114
|
+
raise ArgumentError.new("No workspace ID found. Set the `workspace_id` argument or the `#{env_workspace_id}` environment variable.")
|
|
115
|
+
# rubocop:enable Layout/LineLength
|
|
116
|
+
end
|
|
115
117
|
end
|
|
116
118
|
end
|
|
117
119
|
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Helpers
|
|
5
|
+
module Bedrock
|
|
6
|
+
# Client for the Anthropic Bedrock Mantle API. Only the Messages API (/v1/messages)
|
|
7
|
+
# and its subpaths are supported.
|
|
8
|
+
#
|
|
9
|
+
# Auth is resolved by the same precedence as the AWS gateway client, with
|
|
10
|
+
# Mantle-specific environment variables that fall back to the AWS equivalents:
|
|
11
|
+
#
|
|
12
|
+
# 1. `api_key` constructor arg → API key mode (x-api-key header, no SigV4)
|
|
13
|
+
# 2. `aws_access_key` + `aws_secret_access_key` args → SigV4 with explicit credentials
|
|
14
|
+
# 3. `aws_profile` arg → SigV4 with named AWS profile
|
|
15
|
+
# 4. `AWS_BEARER_TOKEN_BEDROCK` env (then `ANTHROPIC_AWS_API_KEY`) → API key mode
|
|
16
|
+
# 5. Default AWS credential chain → SigV4
|
|
17
|
+
class MantleClient < Anthropic::Client
|
|
18
|
+
include Anthropic::Helpers::AWSAuth
|
|
19
|
+
|
|
20
|
+
# @return [String, nil]
|
|
21
|
+
attr_reader :aws_region
|
|
22
|
+
|
|
23
|
+
# @return [Anthropic::Resources::Messages]
|
|
24
|
+
attr_reader :messages
|
|
25
|
+
|
|
26
|
+
# @return [Anthropic::Helpers::Bedrock::MantleClient::MantleBeta]
|
|
27
|
+
attr_reader :beta
|
|
28
|
+
|
|
29
|
+
# Creates and returns a new client for interacting with Anthropic models via Bedrock Mantle.
|
|
30
|
+
# Only the Messages API (/v1/messages) is supported.
|
|
31
|
+
#
|
|
32
|
+
# @param api_key [String, nil] Anthropic API key (bypasses SigV4, uses x-api-key header)
|
|
33
|
+
#
|
|
34
|
+
# @param aws_access_key [String, nil] AWS access key ID for SigV4 signing
|
|
35
|
+
#
|
|
36
|
+
# @param aws_secret_access_key [String, nil] AWS secret access key for SigV4 signing
|
|
37
|
+
#
|
|
38
|
+
# @param aws_session_token [String, nil] Optional AWS session token for temporary credentials
|
|
39
|
+
#
|
|
40
|
+
# @param aws_profile [String, nil] AWS profile name (uses SigV4 with named profile)
|
|
41
|
+
#
|
|
42
|
+
# @param aws_region [String, nil] AWS region for the base URL and SigV4 signing.
|
|
43
|
+
# Defaults to `ENV["AWS_REGION"]`, then `ENV["AWS_DEFAULT_REGION"]`. Required in SigV4 mode.
|
|
44
|
+
#
|
|
45
|
+
# @param skip_auth [Boolean] When true, skip all auth.
|
|
46
|
+
# Note: the base SDK may still send an X-Api-Key header if ANTHROPIC_API_KEY is set.
|
|
47
|
+
#
|
|
48
|
+
# @param base_url [String, nil] Override the default base URL for the API.
|
|
49
|
+
# Defaults to `ENV["ANTHROPIC_BEDROCK_MANTLE_BASE_URL"]`, then
|
|
50
|
+
# `https://bedrock-mantle.{region}.api.aws/anthropic`.
|
|
51
|
+
#
|
|
52
|
+
# @param max_retries [Integer] Max number of retries to attempt after a failed retryable request.
|
|
53
|
+
#
|
|
54
|
+
# @param timeout [Float]
|
|
55
|
+
#
|
|
56
|
+
# @param initial_retry_delay [Float]
|
|
57
|
+
#
|
|
58
|
+
# @param max_retry_delay [Float]
|
|
59
|
+
#
|
|
60
|
+
def initialize(
|
|
61
|
+
api_key: nil,
|
|
62
|
+
aws_access_key: nil,
|
|
63
|
+
aws_secret_access_key: nil,
|
|
64
|
+
aws_session_token: nil,
|
|
65
|
+
aws_profile: nil,
|
|
66
|
+
aws_region: ENV["AWS_REGION"] || ENV["AWS_DEFAULT_REGION"],
|
|
67
|
+
skip_auth: false,
|
|
68
|
+
base_url: ENV["ANTHROPIC_BEDROCK_MANTLE_BASE_URL"],
|
|
69
|
+
max_retries: self.class::DEFAULT_MAX_RETRIES,
|
|
70
|
+
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
|
|
71
|
+
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
|
|
72
|
+
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
|
|
73
|
+
)
|
|
74
|
+
effective_api_key, resolved_base_url = setup_aws_auth(
|
|
75
|
+
api_key: api_key,
|
|
76
|
+
aws_access_key: aws_access_key,
|
|
77
|
+
aws_secret_access_key: aws_secret_access_key,
|
|
78
|
+
aws_session_token: aws_session_token,
|
|
79
|
+
aws_profile: aws_profile,
|
|
80
|
+
aws_region: aws_region,
|
|
81
|
+
skip_auth: skip_auth,
|
|
82
|
+
base_url: base_url,
|
|
83
|
+
service_name: "bedrock-mantle",
|
|
84
|
+
env_api_key: "AWS_BEARER_TOKEN_BEDROCK",
|
|
85
|
+
env_api_key_fallback: "ANTHROPIC_AWS_API_KEY",
|
|
86
|
+
derive_base_url: ->(region) { "https://bedrock-mantle.#{region}.api.aws/anthropic" }
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
super(
|
|
90
|
+
api_key: effective_api_key,
|
|
91
|
+
base_url: resolved_base_url,
|
|
92
|
+
max_retries: max_retries,
|
|
93
|
+
timeout: timeout,
|
|
94
|
+
initial_retry_delay: initial_retry_delay,
|
|
95
|
+
max_retry_delay: max_retry_delay
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Only initialize supported resources
|
|
99
|
+
@messages = Anthropic::Resources::Messages.new(client: self)
|
|
100
|
+
@beta = MantleBeta.new(client: self)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Completions are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported.
|
|
104
|
+
def completions
|
|
105
|
+
raise NotImplementedError, "Completions are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported."
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Models listing is not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported.
|
|
109
|
+
def models
|
|
110
|
+
raise NotImplementedError, "Models listing is not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported."
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# @api private
|
|
114
|
+
private def transform_request(request)
|
|
115
|
+
aws_auth_transform_request(request)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Restricted Beta service that only exposes messages. Other beta resources
|
|
119
|
+
# (models, files, skills) are not supported on Bedrock Mantle.
|
|
120
|
+
class MantleBeta
|
|
121
|
+
# @return [Anthropic::Resources::Beta::Messages]
|
|
122
|
+
attr_reader :messages
|
|
123
|
+
|
|
124
|
+
# @api private
|
|
125
|
+
def initialize(client:)
|
|
126
|
+
@messages = Anthropic::Resources::Beta::Messages.new(client: client)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def models
|
|
130
|
+
raise NotImplementedError, "Beta models are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported."
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def files
|
|
134
|
+
raise NotImplementedError, "Beta files are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported."
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def skills
|
|
138
|
+
raise NotImplementedError, "Beta skills are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported."
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
data/lib/anthropic/version.rb
CHANGED
data/lib/anthropic.rb
CHANGED
|
@@ -56,9 +56,11 @@ require_relative "anthropic/client"
|
|
|
56
56
|
require_relative "anthropic/helpers/aws_auth"
|
|
57
57
|
require_relative "anthropic/helpers/aws/client"
|
|
58
58
|
require_relative "anthropic/helpers/bedrock/client"
|
|
59
|
+
require_relative "anthropic/helpers/bedrock/mantle_client"
|
|
59
60
|
require_relative "anthropic/helpers/vertex/client"
|
|
60
61
|
require_relative "anthropic/aws"
|
|
61
62
|
require_relative "anthropic/bedrock"
|
|
63
|
+
require_relative "anthropic/bedrock_mantle"
|
|
62
64
|
require_relative "anthropic/vertex"
|
|
63
65
|
require_relative "anthropic/helpers/input_schema"
|
|
64
66
|
require_relative "anthropic/helpers/input_schema/supported_schemas"
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# typed: strong
|
|
2
|
+
|
|
3
|
+
module Anthropic
|
|
4
|
+
module Helpers
|
|
5
|
+
module Bedrock
|
|
6
|
+
class MantleClient < Anthropic::Client
|
|
7
|
+
sig { returns(T.nilable(String)) }
|
|
8
|
+
attr_reader :aws_region
|
|
9
|
+
|
|
10
|
+
sig { returns(Anthropic::Resources::Messages) }
|
|
11
|
+
attr_reader :messages
|
|
12
|
+
|
|
13
|
+
sig { returns(Anthropic::Resources::Beta) }
|
|
14
|
+
attr_reader :beta
|
|
15
|
+
|
|
16
|
+
sig do
|
|
17
|
+
params(
|
|
18
|
+
api_key: T.nilable(String),
|
|
19
|
+
aws_access_key: T.nilable(String),
|
|
20
|
+
aws_secret_access_key: T.nilable(String),
|
|
21
|
+
aws_session_token: T.nilable(String),
|
|
22
|
+
aws_profile: T.nilable(String),
|
|
23
|
+
aws_region: T.nilable(String),
|
|
24
|
+
skip_auth: T::Boolean,
|
|
25
|
+
base_url: T.nilable(String),
|
|
26
|
+
max_retries: Integer,
|
|
27
|
+
timeout: Float,
|
|
28
|
+
initial_retry_delay: Float,
|
|
29
|
+
max_retry_delay: Float
|
|
30
|
+
).returns(T.attached_class)
|
|
31
|
+
end
|
|
32
|
+
def self.new(
|
|
33
|
+
api_key: nil,
|
|
34
|
+
aws_access_key: nil,
|
|
35
|
+
aws_secret_access_key: nil,
|
|
36
|
+
aws_session_token: nil,
|
|
37
|
+
aws_profile: nil,
|
|
38
|
+
aws_region: nil,
|
|
39
|
+
skip_auth: false,
|
|
40
|
+
base_url: nil,
|
|
41
|
+
max_retries: Anthropic::Client::DEFAULT_MAX_RETRIES,
|
|
42
|
+
timeout: Anthropic::Client::DEFAULT_TIMEOUT_IN_SECONDS,
|
|
43
|
+
initial_retry_delay: Anthropic::Client::DEFAULT_INITIAL_RETRY_DELAY,
|
|
44
|
+
max_retry_delay: Anthropic::Client::DEFAULT_MAX_RETRY_DELAY
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
sig { returns(T.noreturn) }
|
|
49
|
+
def completions
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
sig { returns(T.noreturn) }
|
|
53
|
+
def models
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
sig do
|
|
57
|
+
params(request: Anthropic::Internal::AnyHash)
|
|
58
|
+
.returns(Anthropic::Internal::AnyHash)
|
|
59
|
+
end
|
|
60
|
+
private def transform_request(request)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: anthropic
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.30.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Anthropic
|
|
@@ -52,12 +52,14 @@ files:
|
|
|
52
52
|
- lib/anthropic.rb
|
|
53
53
|
- lib/anthropic/aws.rb
|
|
54
54
|
- lib/anthropic/bedrock.rb
|
|
55
|
+
- lib/anthropic/bedrock_mantle.rb
|
|
55
56
|
- lib/anthropic/client.rb
|
|
56
57
|
- lib/anthropic/errors.rb
|
|
57
58
|
- lib/anthropic/file_part.rb
|
|
58
59
|
- lib/anthropic/helpers/aws/client.rb
|
|
59
60
|
- lib/anthropic/helpers/aws_auth.rb
|
|
60
61
|
- lib/anthropic/helpers/bedrock/client.rb
|
|
62
|
+
- lib/anthropic/helpers/bedrock/mantle_client.rb
|
|
61
63
|
- lib/anthropic/helpers/input_schema.rb
|
|
62
64
|
- lib/anthropic/helpers/input_schema/array_of.rb
|
|
63
65
|
- lib/anthropic/helpers/input_schema/base_model.rb
|
|
@@ -574,11 +576,13 @@ files:
|
|
|
574
576
|
- manifest.yaml
|
|
575
577
|
- rbi/anthropic/aws.rbi
|
|
576
578
|
- rbi/anthropic/bedrock.rbi
|
|
579
|
+
- rbi/anthropic/bedrock_mantle.rbi
|
|
577
580
|
- rbi/anthropic/client.rbi
|
|
578
581
|
- rbi/anthropic/errors.rbi
|
|
579
582
|
- rbi/anthropic/file_part.rbi
|
|
580
583
|
- rbi/anthropic/helpers/aws/client.rbi
|
|
581
584
|
- rbi/anthropic/helpers/bedrock/client.rbi
|
|
585
|
+
- rbi/anthropic/helpers/bedrock/mantle_client.rbi
|
|
582
586
|
- rbi/anthropic/helpers/input_schema.rbi
|
|
583
587
|
- rbi/anthropic/helpers/input_schema/array_of.rbi
|
|
584
588
|
- rbi/anthropic/helpers/input_schema/base_model.rbi
|