Amazon Bedrock SDK
Purpose and Scope
The Bedrock package is the TypeScript SDK entrypoint for calling Claude through Amazon Bedrock rather than the direct Anthropic API. It is published as a separate package, named @anthropic-ai/bedrock-sdk, and its README frames it as convenient access to the Claude API via AWS Bedrock. In practice, this means application code keeps the familiar Claude Messages request shape, while client construction and request signing are adapted to AWS credentials, AWS regions, Bedrock runtime URLs, and Bedrock streaming transport details. Sources: packages/bedrock-sdk/README.md, packages/bedrock-sdk/package.json, packages/bedrock-sdk/src/client.ts
Use this package when the deployment requirement is to stay inside AWS account boundaries, use Bedrock model access, or rely on AWS credential management. The official Claude Bedrock documentation distinguishes modern Bedrock Messages API access from the legacy Bedrock InvokeModel and Converse APIs. This package’s tests and client code show Bedrock runtime model invocation behavior, including /model/.../invoke URL construction and AWS event-stream conversion, so readers should align model identifiers and endpoint expectations with the Bedrock integration they are targeting. Sources: packages/bedrock-sdk/tests/client.test.ts, packages/bedrock-sdk/tests/streaming.test.ts
Relevant Source Files
packages/bedrock-sdk/README.md- Installation, basic usage, custom credential provider example, runtime support, and the relationship to the main Claude TypeScript SDK.packages/bedrock-sdk/package.json- Published package name, version, entrypoints, scripts, exports, and AWS/Smithy dependencies used by the Bedrock adapter.packages/bedrock-sdk/src/index.ts- Public entrypoint exporting the Bedrock client, default export, and Mantle-related exports.packages/bedrock-sdk/src/client.ts- MainAnthropicBedrockclient class, Bedrock-specific client options, defaults, credential settings, and model endpoint handling.packages/bedrock-sdk/tests/client.test.ts- Integration-style tests for model-name and model-ARN URL construction, plus bearer-token authentication behavior.packages/bedrock-sdk/tests/streaming.test.ts- Tests for converting AWS event-stream frames into Server-Sent Events consumed by the core SDK streaming layer.
Installation and Basic Usage
Install the Bedrock package directly rather than installing only the main SDK package. The package metadata marks it public, CommonJS-typed with generated distribution entrypoints, and dependent on the main SDK via the repository build output. Its runtime dependencies include AWS Bedrock Runtime, AWS credential providers, Smithy signing, Smithy fetch handling, Smithy event-stream serialization, SHA-256 support, and base64 utilities. Those dependencies are the adapter layer that lets the shared Claude SDK resources run over AWS-authenticated Bedrock requests. Sources: packages/bedrock-sdk/package.json
npm install @anthropic-ai/bedrock-sdkThe README example imports AnthropicBedrock, constructs a client with no explicit credentials, and calls client.messages.create with a Bedrock model identifier such as anthropic.claude-3-5-sonnet-20241022-v2:0. The no-argument constructor path is intentional: in a Node environment, AWS credentials are expected to come from mechanisms recognized by the AWS SDK, such as a shared credentials file or AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables. The message request itself remains recognizable to Claude SDK users: provide a model, user messages, and a token limit, then inspect the returned message. Sources: packages/bedrock-sdk/README.md
import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
const client = new AnthropicBedrock();
const message = await client.messages.create({
model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
messages: [{ role: 'user', content: 'Hello!' }],
max_tokens: 1024,
});
console.log(message);Core Primitives
The central primitive is AnthropicBedrock, exported both as a named class and as the default package export. The package entrypoint also re-exports BaseAnthropic from the main SDK client layer and exposes AnthropicBedrockMantle plus BedrockMantleClientOptions for Mantle-related Bedrock usage. Most application code should start with AnthropicBedrock, because it preserves the generated resource shape from the main TypeScript SDK while changing authentication, base URL selection, and transport behavior for Amazon Bedrock. Sources: packages/bedrock-sdk/src/index.ts, packages/bedrock-sdk/src/client.ts
The supported client options extend the main SDK client options, but remove direct Anthropic apiKey and authToken semantics and replace them with Bedrock-aware authentication choices. The apiKey option is documented as defaulting to AWS_BEARER_TOKEN_BEDROCK, which supports Bedrock bearer-token authentication. Static AWS credentials can be supplied as awsAccessKey, awsSecretKey, and optional awsSessionToken; otherwise the client can rely on the AWS credential provider chain. awsRegion defaults from AWS_REGION, and the constructor documentation describes the default base URL as a Bedrock Runtime URL derived from that region. Sources: packages/bedrock-sdk/src/client.ts
Authentication and Configuration
For typical Node.js server deployments, prefer the default AWS credential provider chain. That keeps credential rotation and local development behavior consistent with other AWS SDK code, and it matches the README guidance that shared AWS credentials or AWS access key environment variables are recognized. If both static keys are provided, the constructor overloads accept them together with an optional session token. Passing only one half of the static key pair is still represented in overloads but marked deprecated, which signals that new integrations should either provide both keys or provide neither and rely on the provider chain. Sources: packages/bedrock-sdk/README.md, packages/bedrock-sdk/src/client.ts
For non-Node environments, the README shows a providerChainResolver option. That hook returns an AWS credential identity provider and is specifically called out for environments such as Vercel Edge Runtime, where the normal AWS SDK default provider chain may not be available. This is different from setting a single request credential value: the resolver supplies the provider function that the Bedrock auth layer can call when signing requests. The same constructor can also set awsRegion, override baseURL, adjust timeout behavior inherited from the core client, or use skipAuth in controlled testing scenarios. Sources: packages/bedrock-sdk/README.md, packages/bedrock-sdk/src/client.ts
const client = new AnthropicBedrock({
awsRegion: 'us-east-1',
providerChainResolver: async () => async () => ({
accessKeyId: 'your-aws-access-key-id',
secretAccessKey: 'your-aws-secret-access-key',
sessionToken: 'your-aws-session-token',
}),
});Bedrock Request Mapping
The Bedrock client adapts generated Claude resource calls into Bedrock model invocation URLs. The client code defines model endpoints for completions, messages, and beta messages, and the tests verify the path produced for a normal Bedrock model name. A messages.create call with model anthropic.claude-3-5-sonnet-20241022-v2:0 becomes a Bedrock runtime URL ending in /model/anthropic.claude-3-5-sonnet-20241022-v2:0/invoke when the test base URL is http://localhost:4010. That mapping is important when debugging IAM permissions, endpoint policies, proxies, or recorded HTTP tests. Sources: packages/bedrock-sdk/src/client.ts, packages/bedrock-sdk/tests/client.test.ts
Model ARNs require extra care because ARNs can contain slashes inside an inference profile path. The client test constructs an ARN containing inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0 and asserts that the slash is percent-encoded in the URL path as %2F. This is a concrete edge case for production Bedrock deployments that use inference profiles rather than simple model names. If a proxy, log sanitizer, or custom base URL rewrites the path, preserve that encoding so the Bedrock runtime receives the intended model identifier. Sources: packages/bedrock-sdk/tests/client.test.ts
Streaming Behavior
Bedrock streaming responses arrive as AWS event-stream frames, while the shared Anthropic TypeScript SDK streaming layer consumes Server-Sent Events. The Bedrock package bridges that difference through eventStreamToSSEResponse. The streaming tests build event-stream frames, encode chunk payloads, convert the Bedrock response, and assert that message payloads become SSE frames named by their payload type, such as message_start and message_stop. This lets higher-level SDK code iterate streaming message events using the same conceptual flow as direct Claude API streaming. Sources: packages/bedrock-sdk/tests/streaming.test.ts
The streaming tests also document failure and tolerance behavior. A chunk containing an Anthropic error payload is surfaced as an APIError, with the error type preserved, rather than being reported as an unexpected stream-order failure. Chunk frames without a usable type are dropped instead of failing the entire stream. Those behaviors matter for robust streaming clients: handle SDK stream iteration errors, do not assume every low-level Bedrock frame becomes an application event, and keep cancellation or retry logic at the request boundary rather than inside the event-frame conversion. Sources: packages/bedrock-sdk/tests/streaming.test.ts
Runtime and Package Reference
The Bedrock README lists TypeScript support beginning at version 4.5 and runtime support for Node.js 18 LTS or later, Deno using an npm import, Bun 1.0 or later, Cloudflare Workers, Vercel Edge Runtime, Jest with the node environment, and Nitro. React Native is explicitly not supported. This differs from the root SDK README, which targets a newer TypeScript baseline and Node.js 20 or later for the main package; therefore, when documenting or testing a Bedrock integration, use the Bedrock package’s README as the runtime authority. Sources: packages/bedrock-sdk/README.md
| Item | Bedrock package contract |
|---|---|
| Package | @anthropic-ai/bedrock-sdk |
| Main client | AnthropicBedrock |
| Default export | AnthropicBedrock from ./client |
| Important options | apiKey, awsAccessKey, awsSecretKey, awsSessionToken, awsRegion, skipAuth, providerChainResolver, baseURL, timeout |
| Default bearer token source | AWS_BEARER_TOKEN_BEDROCK |
| Default region source | AWS_REGION, with constructor docs indicating us-east-1 fallback |
| Default base URL pattern | https://bedrock-runtime.${region}.amazonaws.com |
| Streaming bridge | AWS event-stream response to SSE response |
Next Steps
Start by confirming Bedrock model access and AWS credentials outside the SDK, then run the README’s messages.create example with the exact Bedrock model name or inference-profile ARN you plan to use. If the request reaches the wrong endpoint, compare the observed URL with the URL-construction behavior documented in the tests. If streaming behaves differently from direct Claude API streaming, remember that this package transcodes AWS event-stream frames into SSE before the shared SDK stream parser consumes them. For broader SDK behavior, read the core Messages, streaming, authentication, and provider-package pages next. Sources: packages/bedrock-sdk/README.md, packages/bedrock-sdk/tests/client.test.ts, packages/bedrock-sdk/tests/streaming.test.ts