Anthropic Bedrock TypeScript API Library

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 --save @anthropic-ai/bedrock-sdk
yarn add @anthropic-ai/bedrock-sdk
Usage
import Anthropic from '@anthropic-ai/sdk';
import { AnthropicBedrock } from '@anthropic-ai/bedrock-sdk';
const anthropic = new AnthropicBedrock();
async function main() {
const completion = await anthropic.completions.create({
model: 'anthropic.claude-instant-v1',
prompt: `${Anthropic.HUMAN_PROMPT} how does a court case get to the Supreme Court? ${Anthropic.AI_PROMPT}`,
stop_sequences: [Anthropic.HUMAN_PROMPT],
max_tokens_to_sample: 800,
temperature: 0.5,
top_k: 250,
top_p: 0.5,
});
console.log(completion);
}
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.