Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@anthropic-ai/bedrock-sdk

anthropics253.1kMIT0.22.2TypeScript support: included

The official TypeScript library for the Anthropic Bedrock API

readme

Anthropic Bedrock TypeScript API Library

NPM version

This library provides convenient access to the Anthropic Bedrock API.

For the non-Bedrock Anthropic API at api.anthropic.com, see @anthropic-ai/sdk.

Installation

npm install @anthropic-ai/bedrock-sdk

Usage

import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';

// Note: this assumes you have configured AWS credentials in a way
// that the AWS Node SDK will recognise, typicaly a shared `~/.aws/credentials`
// file or `AWS_ACCESS_KEY_ID` & `AWS_SECRET_ACCESS_KEY` environment variables.
//
// https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html
const client = new AnthropicBedrock();

async function main() {
  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);
}

main();

For more details on how to use the SDK, see the README.md for the main Anthropic SDK which this library extends.

Requirements

TypeScript >= 4.5 is supported.

The following runtimes are supported:

  • Node.js 18 LTS or later (non-EOL) versions.
  • Deno v1.28.0 or higher, using import { AnthropicBedrock } from "npm:@anthropic-ai/bedrock-sdk".
  • Bun 1.0 or later.
  • Cloudflare Workers.
  • Vercel Edge Runtime.
  • Jest 28 or greater with the "node" environment ("jsdom" is not supported at this time).
  • Nitro v2.6 or greater.

Note that React Native is not supported at this time.

If you are interested in other runtime environments, please open or upvote an issue on GitHub.

changelog

Changelog

0.22.2 (2025-06-24)

Full Changelog: bedrock-sdk-v0.22.1...bedrock-sdk-v0.22.2

0.22.1 (2025-05-22)

Full Changelog: bedrock-sdk-v0.22.0...bedrock-sdk-v0.22.1

Chores

0.22.0 (2025-05-15)

Full Changelog: bedrock-sdk-v0.21.2...bedrock-sdk-v0.22.0

Features

  • bedrock: support skipAuth on Bedrock client to bypass local auth requirements (b661c5f)

Bug Fixes

  • bedrock: support model names with slashes (cb5fa8a)

0.21.2 (2025-05-09)

Full Changelog: bedrock-sdk-v0.21.1...bedrock-sdk-v0.21.2

Bug Fixes

  • client: always overwrite when merging headers (657912a)

0.21.1 (2025-05-09)

Full Changelog: bedrock-sdk-v0.21.0...bedrock-sdk-v0.21.1

Chores

0.21.0 (2025-05-09)

Full Changelog: bedrock-sdk-v0.20.0...bedrock-sdk-v0.21.0

Features

  • bedrock: add beta.messages.create() method (faf8484)

Bug Fixes

  • bedrock,vertex: update to new SDK version (cb620bb)
  • bedrock: correct messages beta handling (f34d67a)
  • bedrock: don't mutate request body inputs (4523ca9)
  • bedrock: update streaming util import (01d03bf)
  • streaming: handle more AbortError cases (521d6cd)
  • vertex,bedrock: correct build script (df895a7)

Chores

  • bedrock,vertex: remove unsupported countTokens method (#597) (6f6db16)
  • bedrock: add skipAuth option to allow users to let authorization be handled elsewhere (ee58772)
  • bedrock: bump @aws-sdk dependencies (ff925db)
  • bedrock: bump @aws-sdk dependencies (9891107)
  • bedrock: bump @aws-sdk/credential-providers (9f611d6)
  • bedrock: bump @aws-sdk/credential-providers (491646e)
  • bedrock: bump dependency on @anthropic-ai/sdk (2d0d4b6)
  • bedrock: remove unsupported methods (8bb04ed)
  • internal: migrate to eslint v9 (1141664)

Documentation

  • use latest sonnet in example snippets (#625) (a965791)

0.20.0 (2025-05-09)

Full Changelog: bedrock-sdk-v0.12.6...bedrock-sdk-v0.12.7

Bug Fixes

  • bedrock,vertex: update to new SDK version (cb620bb)
  • vertex,bedrock: correct build script (df895a7)

Chores

  • bedrock: add skipAuth option to allow users to let authorization be handled elsewhere (ee58772)
  • bedrock: bump @aws-sdk dependencies (ff925db)
  • bedrock: bump @aws-sdk/credential-providers (9f611d6)

0.12.6 (2025-04-28)

Full Changelog: bedrock-sdk-v0.12.5...bedrock-sdk-v0.12.6

Chores

0.12.5 (2025-04-25)

Full Changelog: bedrock-sdk-v0.12.4...bedrock-sdk-v0.12.5

Chores

  • bedrock: bump @aws-sdk/credential-providers (a4d88d7)

0.12.4 (2025-01-23)

Full Changelog: bedrock-sdk-v0.12.3...bedrock-sdk-v0.12.4

Bug Fixes

  • bedrock: update streaming util import (255c059)

0.12.3 (2025-01-23)

Full Changelog: bedrock-sdk-v0.12.2...bedrock-sdk-v0.12.3

Chores

  • bedrock: bump dependency on @anthropic-ai/sdk (8745ca2)

0.12.2 (2025-01-21)

Full Changelog: bedrock-sdk-v0.12.1...bedrock-sdk-v0.12.2

Chores

0.12.1 (2024-12-20)

Full Changelog: bedrock-sdk-v0.12.0...bedrock-sdk-v0.12.1

Chores

0.12.0 (2024-12-17)

Full Changelog: bedrock-sdk-v0.11.2...bedrock-sdk-v0.12.0

Features

Chores

  • bedrock,vertex: remove unsupported countTokens method (#597) (17b7da5)
  • bedrock: remove unsupported methods (6458dc1)

Documentation

  • use latest sonnet in example snippets (#625) (f70882b)

0.11.2 (2024-11-05)

Full Changelog: bedrock-sdk-v0.11.1...bedrock-sdk-v0.11.2

Bug Fixes

  • bedrock: don't mutate request body inputs (f83b535)

0.11.1 (2024-10-23)

Full Changelog: bedrock-sdk-v0.11.0...bedrock-sdk-v0.11.1

Bug Fixes

  • bedrock: correct messages beta handling (9b57586)

0.11.0 (2024-10-22)

Full Changelog: bedrock-sdk-v0.10.4...bedrock-sdk-v0.11.0

Features

  • bedrock: add beta.messages.create() method (6317592)

0.10.4 (2024-10-08)

Full Changelog: bedrock-sdk-v0.10.3...bedrock-sdk-v0.10.4

Refactors

0.10.3 (2024-10-04)

Full Changelog: bedrock-sdk-v0.10.2...bedrock-sdk-v0.10.3

Chores

  • better object fallback behaviour for casting errors (#526) (4ffb2e4)

0.10.2 (2024-07-29)

Full Changelog: bedrock-sdk-v0.10.1...bedrock-sdk-v0.10.2

Chores

  • bedrock: use chunk for internal SSE parsing instead of completion (#472) (0f6190a)
  • docs: rename anthropic const to client (#471) (e1a7f9f)
  • internal: remove old reference to check-test-server (8dc9afc)

0.10.1 (2024-06-25)

Full Changelog: bedrock-sdk-v0.10.0...bedrock-sdk-v0.10.1

Chores

0.10.0 (2024-05-30)

Full Changelog: bedrock-sdk-v0.9.8...bedrock-sdk-v0.10.0

Features

0.9.8 (2024-05-16)

Full Changelog: bedrock-sdk-v0.9.7...bedrock-sdk-v0.9.8

Chores

  • internal: fix generated version numbers (#413) (ea77063)

0.9.7 (2024-05-07)

Full Changelog: bedrock-sdk-v0.9.6...bedrock-sdk-v0.9.7

Chores

0.9.6 (2024-04-09)

Full Changelog: bedrock-sdk-v0.9.5...bedrock-sdk-v0.9.6

Chores

0.9.5 (2024-04-04)

Full Changelog: bedrock-sdk-v0.9.4...bedrock-sdk-v0.9.5

Documentation

0.9.4 (2024-04-04)

Full Changelog: bedrock-sdk-v0.9.3...bedrock-sdk-v0.9.4

Bug Fixes

  • types: correctly mark type as a required property in requests (#371) (a04edd8)

0.9.3 (2024-04-04)

Full Changelog: bedrock-sdk-v0.9.2...bedrock-sdk-v0.9.3

Chores

  • deps: remove unused dependency digest-fetch (#368) (df1df0f)

0.9.2 (2024-03-29)

Full Changelog: bedrock-sdk-v0.9.1...bedrock-sdk-v0.9.2

Documentation

0.9.1 (2024-03-06)

Full Changelog: bedrock-sdk-v0.9.0...bedrock-sdk-v0.9.1

Documentation

  • remove extraneous --save and yarn install instructions (#323) (775ecb9)

0.9.0 (2024-03-04)

Full Changelog: bedrock-sdk-v0.8.0...bedrock-sdk-v0.9.0

Features

0.8.0 (2024-03-04)

Full Changelog: bedrock-sdk-v0.7.1...bedrock-sdk-v0.8.0

Features

  • messages: add support for image inputs (#303) (7663bd6)

0.7.1 (2024-01-31)

Full Changelog: bedrock-sdk-v0.7.0...bedrock-sdk-v0.7.1

Chores

0.7.0 (2024-01-31)

This release restructures the SDK so that it relies on the main @anthropic-ai/sdk instead of duplicating everything.

  • All subpath imports are broken, e.g. import { Completion } from '@anthropic-ai/bedrock-sdk/resources/completions'
  • Types are no longer exported through the default import, e.g. AnthropicBedrock.Completion
    • e.g. AnthropicBedrock.APIError, AnthropicBedrock.HUMAN_PROMPT

However, these are all an straightforward fixes, you just have to replace @anthropic-ai/bedrock-sdk with @anthropic-ai/sdk, e.g.

- import AnthropicBedrock from '@anthropic-ai/bedrock-sdk';
+ import Anthropic from '@anthropic-ai/sdk';

- type Completion = AnthropicBedrock.Completion;
+ type Completion = Anthropic.Completion;

0.6.5 (2024-01-30)

Full Changelog: v0.6.4...v0.6.5

Chores

  • internal: support pre-release versioning (#77) (b96f745)

0.6.4 (2024-01-25)

Full Changelog: v0.6.3...v0.6.4

Chores

  • internal: add internal helpers & improve build scripts (#73) (d12b655)
  • internal: don't re-export streaming type (#76) (92fb967)
  • internal: minor streaming updates (#75) (73bac4c)

0.6.3 (2024-01-19)

Full Changelog: v0.6.2...v0.6.3

Bug Fixes

  • allow body type in RequestOptions to be null (#71) (a04f753)

0.6.2 (2024-01-18)

Full Changelog: v0.6.1...v0.6.2

Bug Fixes

  • ci: ignore stainless-app edits to release PR title (#70) (c3a058c)
  • headers: always send lowercase headers and strip undefined (BREAKING in rare cases) (#60) (9cc4518)
  • types: accept undefined for optional client options (#69) (cf597f6)
  • use default base url if BASE_URL env var is blank (#64) (134bf8f)

Chores

  • add .keep files for examples and custom code directories (#63) (0064f30)
  • internal: debug logging for retries; speculative retry-after-ms support (#68) (e6a95f6)
  • internal: improve type signatures (#62) (6e24bdc)
  • internal: narrow type into stringifyQuery (#65) (443febf)

Documentation

  • fix missing async in readme code sample (#67) (a6d20eb)
  • readme: improve api reference (#66) (f90bbaf)

0.6.1 (2023-12-20)

Full Changelog: v0.6.0...v0.6.1

Chores

Documentation

Refactors

Build System

0.6.0 (2023-12-06)

Full Changelog: v0.5.2...v0.6.0

Features

  • client: support reading the base url from an env variable (#43) (783e9a1)

Bug Fixes

  • bump default request timeout to 10min to match documentation (#47) (16d2d96)

0.5.2 (2023-11-28)

Full Changelog: v0.5.1...v0.5.2

0.5.1 (2023-11-24)

Full Changelog: v0.5.0...v0.5.1

Chores

  • internal: remove file import and conditionally run prepare (#39) (546295e)

0.5.0 (2023-11-21)

Full Changelog: v0.4.1...v0.5.0

Features

  • allow installing package directly from github (#37) (758b62f)

Chores

0.4.1 (2023-11-14)

Full Changelog: v0.4.0...v0.4.1

Chores

0.4.0 (2023-11-04)

Full Changelog: v0.3.0...v0.4.0

Features

Chores

Documentation

0.3.0 (2023-10-25)

Full Changelog: v0.2.0...v0.3.0

Features

  • client: adjust retry behavior to be exponential backoff (#18) (51d3a6e)

Bug Fixes

0.2.0 (2023-10-19)

Full Changelog: v0.1.2...v0.2.0

Features

  • handle 204 No Content gracefully (#17) (f11420b)

0.1.2 (2023-10-17)

Full Changelog: v0.1.1...v0.1.2

Bug Fixes

  • import web-streams-polyfill without overriding globals (#13) (30db709)

0.1.1 (2023-10-16)

Full Changelog: v0.1.0...v0.1.1

Bug Fixes

  • improve status code in error messages (#9) (aa3f1b0)

Chores

  • add case insensitive get header function (#4) (b7309b1)
  • internal: add debug logs for stream responses (#8) (b8763a7)
  • update comment (#6) (7361f09)

Documentation

  • organisation -> organization (UK to US English) (#11) (5cbea8e)

0.1.0 (2023-10-12)

Full Changelog: v0.0.1...v0.1.0

Features