Anthropic::Bedrock::Client
Inherits Anthropic::Client < Reference < Object
Anthropic Messages client that targets Amazon Bedrock Runtime.
Rewrites canonical /v1/messages calls to Bedrock's
/model/{modelId}/invoke (and stream variant) and authenticates with
AWS SigV4 (or an optional Bedrock bearer token).
client = Anthropic::Bedrock::Client.new(
aws_profile: "anthropic-cr-bedrock",
aws_region: "us-east-1",
)
message = client.messages.create(
model: "us.anthropic.claude-haiku-4-5-20251001-v1:0",
max_tokens: 256,
messages: [{role: "user", content: "Hello from Bedrock!"}],
)
puts message.text
Prefer inference profile model IDs (us.anthropic.* / global.anthropic.*)
for current Claude models — bare anthropic.* on-demand IDs often fail.
Not supported on Bedrock yet (matches official SDKs): Message Batches, token counting, and the Models list endpoint.
Constants
Constructors
Create a Bedrock client.
Pass AWS credentials explicitly, via aws_profile, or rely on the
resolver chain (env → shared credentials → aws login cache →
IAM Identity Center SSO → IMDS). Alternatively pass api_key /
set AWS_BEARER_TOKEN_BEDROCK for bearer-token auth (mutually exclusive
with AWS credentials).
Instance methods
Streaming against Bedrock uses invoke-with-response-stream and returns
AWS Event Stream framing. This rewrites the path, SigV4-signs, and
transcodes application/vnd.amazon.eventstream bodies into SSE so
MessageStream / messages.stream work unchanged.