Typescript
Getting Started

Getting Started

anthropic-bedrock is a typescript library for interacting with Anthropic's models on AWS Bedrock. It makes it really easy to use these models in production.

Installation

Install anthropic-bedrock with your favorite package manager.

npm i anthropic-bedrock

Authentication

This is the preferred way to use this SDK. Learn more about how you can get your access key and secrey key here.

import AnthropicBedrock from "anthropic-bedrock";
 
const anthropic = new AnthropicBedrock({
  access_key: process.env["AWS_ACCESS_KEY"],
  secret_key: process.env["AWS_SECRET_KEY"],
  region: process.env["AWS_REGION"],
});

Done!

You are all ready to use the anthropic-bedrock Typescript SDK!

import AnthropicBedrock from "anthropic-bedrock";
 
const anthropic = new AnthropicBedrock({
  access_key: process.env["AWS_ACCESS_KEY"],
  secret_key: process.env["AWS_SECRET_KEY"],
  region: process.env["AWS_REGION"],
});
 
async function main() {
  const completion = await anthropic.Completion.create({
    model: "anthropic.claude-v2",
    prompt: "In one sentence, what is good about the color blue?",
    max_tokens_to_sample: 300,
  });
 
  console.log(completion["completion"]);
}
 
main();

Continue reading the docs to learn more about this SDK.