Class: Anthropic::Helpers::Bedrock::MantleClient
- Inherits:
-
Client
- Object
- Internal::Transport::BaseClient
- Client
- Anthropic::Helpers::Bedrock::MantleClient
- Includes:
- AWSAuth
- Defined in:
- lib/anthropic/helpers/bedrock/mantle_client.rb
Overview
Client for the Anthropic Bedrock Mantle API. Only the Messages API (/v1/messages) and its subpaths are supported.
Auth is resolved by the same precedence as the AWS gateway client, with Mantle-specific environment variables that fall back to the AWS equivalents:
1. `api_key` constructor arg → API key mode (x-api-key header, no SigV4)
2. `aws_access_key` + `aws_secret_access_key` args → SigV4 with explicit credentials
3. `aws_profile` arg → SigV4 with named AWS profile
4. `AWS_BEARER_TOKEN_BEDROCK` env (then `ANTHROPIC_AWS_API_KEY`) → API key mode
5. Default AWS credential chain → SigV4
Defined Under Namespace
Classes: MantleBeta
Constant Summary
Constants inherited from Client
Client::DEFAULT_INITIAL_RETRY_DELAY, Client::DEFAULT_MAX_RETRIES, Client::DEFAULT_MAX_RETRY_DELAY, Client::DEFAULT_TIMEOUT_IN_SECONDS, Client::MODEL_NONSTREAMING_TOKENS
Constants inherited from Internal::Transport::BaseClient
Internal::Transport::BaseClient::MAX_REDIRECTS, Internal::Transport::BaseClient::PLATFORM_HEADERS
Instance Attribute Summary collapse
- #aws_region ⇒ String? readonly
- #beta ⇒ Anthropic::Helpers::Bedrock::MantleClient::MantleBeta readonly
- #messages ⇒ Anthropic::Resources::Messages readonly
Attributes inherited from Client
Attributes inherited from Internal::Transport::BaseClient
#base_url, #headers, #idempotency_header, #initial_retry_delay, #max_retries, #max_retry_delay, #requester, #timeout
Instance Method Summary collapse
-
#completions ⇒ Object
Completions are not supported on Bedrock Mantle.
-
#initialize(api_key: nil, aws_access_key: nil, aws_secret_access_key: nil, aws_session_token: nil, aws_profile: nil, aws_region: ENV["AWS_REGION"] || ENV["AWS_DEFAULT_REGION"], skip_auth: false, base_url: ENV["ANTHROPIC_BEDROCK_MANTLE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ MantleClient
constructor
Creates and returns a new client for interacting with Anthropic models via Bedrock Mantle.
-
#models ⇒ Object
Models listing is not supported on Bedrock Mantle.
Methods inherited from Client
#calculate_nonstreaming_timeout
Methods inherited from Internal::Transport::BaseClient
follow_redirect, #inspect, reap_connection!, #request, #send_request, should_retry?, validate!
Methods included from Internal::Util::SorbetRuntimeSupport
#const_missing, #define_sorbet_constant!, #sorbet_constant_defined?, #to_sorbet_type, to_sorbet_type
Constructor Details
#initialize(api_key: nil, aws_access_key: nil, aws_secret_access_key: nil, aws_session_token: nil, aws_profile: nil, aws_region: ENV["AWS_REGION"] || ENV["AWS_DEFAULT_REGION"], skip_auth: false, base_url: ENV["ANTHROPIC_BEDROCK_MANTLE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY) ⇒ MantleClient
Creates and returns a new client for interacting with Anthropic models via Bedrock Mantle. Only the Messages API (/v1/messages) is supported.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/anthropic/helpers/bedrock/mantle_client.rb', line 60 def initialize( api_key: nil, aws_access_key: nil, aws_secret_access_key: nil, aws_session_token: nil, aws_profile: nil, aws_region: ENV["AWS_REGION"] || ENV["AWS_DEFAULT_REGION"], skip_auth: false, base_url: ENV["ANTHROPIC_BEDROCK_MANTLE_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) effective_api_key, resolved_base_url = setup_aws_auth( api_key: api_key, aws_access_key: aws_access_key, aws_secret_access_key: aws_secret_access_key, aws_session_token: aws_session_token, aws_profile: aws_profile, aws_region: aws_region, skip_auth: skip_auth, base_url: base_url, service_name: "bedrock-mantle", env_api_key: "AWS_BEARER_TOKEN_BEDROCK", env_api_key_fallback: "ANTHROPIC_AWS_API_KEY", derive_base_url: ->(region) { "https://bedrock-mantle.#{region}.api.aws/anthropic" }, use_bearer_auth: true ) super( api_key: effective_api_key, base_url: resolved_base_url, max_retries: max_retries, timeout: timeout, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay ) # Only initialize supported resources @messages = Anthropic::Resources::Messages.new(client: self) @beta = MantleBeta.new(client: self) end |
Instance Attribute Details
#aws_region ⇒ String? (readonly)
21 22 23 |
# File 'lib/anthropic/helpers/bedrock/mantle_client.rb', line 21 def aws_region @aws_region end |
#beta ⇒ Anthropic::Helpers::Bedrock::MantleClient::MantleBeta (readonly)
27 28 29 |
# File 'lib/anthropic/helpers/bedrock/mantle_client.rb', line 27 def beta @beta end |
#messages ⇒ Anthropic::Resources::Messages (readonly)
24 25 26 |
# File 'lib/anthropic/helpers/bedrock/mantle_client.rb', line 24 def @messages end |
Instance Method Details
#completions ⇒ Object
Completions are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported.
105 106 107 |
# File 'lib/anthropic/helpers/bedrock/mantle_client.rb', line 105 def completions raise NotImplementedError, "Completions are not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported." end |
#models ⇒ Object
Models listing is not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported.
110 111 112 |
# File 'lib/anthropic/helpers/bedrock/mantle_client.rb', line 110 def models raise NotImplementedError, "Models listing is not supported on Bedrock Mantle. Only Messages (/v1/messages) is supported." end |