class

Anthropic::AWS::Client

Inherits Anthropic::Client < Reference < Object

Anthropic models via the AWS gateway — the full first-party API served through aws-external-anthropic.

Unlike Anthropic::Bedrock::Client (Bedrock Runtime invoke API), requests pass through unchanged: standard /v1/* paths, standard model names, the complete API surface.

Credentials resolve in priority order:

  1. api_key (or ANTHROPIC_AWS_API_KEY) → API-key mode (x-api-key header, no SigV4),
  2. explicit aws_access_key/aws_secret_key/aws_session_token/aws_profile,
  3. the default AWS chain (env → shared config → SSO/login cache → IMDS) via Bedrock::CredentialsResolver.
client = Anthropic::AWS::Client.new(aws_region: "us-east-1")

message = client.messages.create(
  model: Anthropic::Model::CLAUDE_SONNET_5,
  max_tokens: 256,
  messages: [{role: "user", content: "Hello from AWS!"}],
)

Constants

SERVICE = "aws-external-anthropic"

Constructors

new(api_key : String | Nil = nil, aws_access_key : String | Nil = nil, aws_secret_key : String | Nil = nil, aws_session_token : String | Nil = nil, aws_profile : String | Nil = nil, aws_region : String | Nil = nil, workspace_id : String | Nil = nil, skip_auth : Bool = false, base_url : String | Nil = nil, timeout : Time::Span = 600.seconds, max_retries : Int32 = DEFAULT_MAX_RETRIES, initial_retry_delay : Float64 = DEFAULT_INITIAL_DELAY, max_retry_delay : Float64 = DEFAULT_MAX_DELAY, default_headers : Hash(String, String) = {} of String => String, middleware : Array = [] of Middleware)
Source

Class methods

default_base_url(region : String | Nil) : String
Source
resolve_auth(api_key : String | Nil, env_api_key : String | Nil, aws_access_key : String | Nil, aws_secret_key : String | Nil, aws_session_token : String | Nil, aws_profile : String | Nil, aws_region : String | Nil, skip_auth : Bool) : Tuple(String | Nil, Bedrock::Credentials | Nil, String | Nil)

Resolve the auth mode: API key, SigV4 credentials, or nothing when skip_auth is set. Returns {gateway_key, credentials, region}. An explicit api_key always wins (API-key mode); the ANTHROPIC_AWS_API_KEY env key applies only without platform args. Internal constructor helper; not part of the public API.

Source

Instance methods

api_key_mode?

Whether requests are API-key authenticated (vs SigV4).

Source
aws_region
Source
post_stream(path : String, body, extra_headers : Hash(String, String) | Nil = nil, &)
Source
skip_auth?
Source
workspace_id
Source