npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

claude-bedrock-client

v1.0.0

Published

Invoke Anthropic Claude models through AWS Bedrock — simple, credential-free wrapper around @anthropic-ai/bedrock-sdk

Readme

claude-bedrock-client

Invoke Anthropic Claude models through AWS Bedrock with a simple, clean API. Built on top of @anthropic-ai/bedrock-sdk.

Installation

npm install claude-bedrock-client

AWS Credential Setup

This package reads credentials from environment variables or your ~/.aws/credentials file — no credentials are ever hardcoded.

Option 1 — Environment variables

export AWS_ACCESS_KEY_ID=your-access-key
export AWS_SECRET_ACCESS_KEY=your-secret-key
export AWS_REGION=us-east-1

Or in a .env file (add .env to your .gitignore):

AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_REGION=us-east-1

Option 2 — AWS credentials file

Configure credentials with the AWS CLI:

aws configure

This writes to ~/.aws/credentials and is picked up automatically.

IAM permissions required

Your IAM user or role needs:

{
  "Effect": "Allow",
  "Action": ["bedrock:InvokeModel", "bedrock:InvokeModelWithResponseStream"],
  "Resource": "arn:aws:bedrock:*::foundation-model/anthropic.*"
}

Make sure Claude model access is enabled in the AWS Bedrock console for your region.

Usage

Basic chat

const { invokeClaude } = require('claude-bedrock-client');

const response = await invokeClaude([
  { role: 'user', content: 'What is the capital of France?' }
]);

for (const block of response.content) {
  if (block.type === 'text') console.log(block.text);
}
// → Paris is the capital of France.

Multi-turn conversation

const { invokeClaude } = require('claude-bedrock-client');

const response = await invokeClaude(
  [
    { role: 'user',      content: 'My name is Ankit.' },
    { role: 'assistant', content: 'Hello Ankit! Nice to meet you.' },
    { role: 'user',      content: "What's my name?" },
  ],
  {
    system: 'You are a helpful assistant.',
    maxTokens: 256,
  }
);

Streaming

const { streamClaude } = require('claude-bedrock-client');

const finalMessage = await streamClaude(
  [{ role: 'user', content: 'Write a haiku about the ocean.' }],
  {
    onChunk: (text) => process.stdout.write(text),
  }
);

console.log(`\nTokens — in: ${finalMessage.usage.input_tokens}, out: ${finalMessage.usage.output_tokens}`);

Custom model / region

const { invokeClaude } = require('claude-bedrock-client');

const response = await invokeClaude(
  [{ role: 'user', content: 'Hello' }],
  {
    model: 'us.anthropic.claude-haiku-4-5',
    maxTokens: 512,
    region: 'us-west-2',
  }
);

Low-level client access

const { createClient } = require('claude-bedrock-client');

const client = createClient({ region: 'eu-central-1' });
// client is a fully configured AnthropicBedrock instance
const response = await client.messages.create({ ... });

API

invokeClaude(messages, options?)

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | messages | Array<{role, content}> | required | Conversation turns | | options.model | string | us.anthropic.claude-sonnet-4-6 | Bedrock model ID | | options.maxTokens | number | 1024 | Max output tokens | | options.system | string | — | System prompt | | options.region | string | AWS_REGION env / us-east-1 | AWS region | | options.accessKey | string | AWS_ACCESS_KEY_ID env | AWS access key | | options.secretKey | string | AWS_SECRET_ACCESS_KEY env | AWS secret key |

Returns: Promise<BedrockResponse>

streamClaude(messages, options?)

Same options as invokeClaude, plus:

| Parameter | Type | Default | Description | |-----------|------|---------|-------------| | options.maxTokens | number | 512 | Max output tokens | | options.onChunk | Function | — | Called with each text chunk |

Returns: Promise<FinalMessage> (includes usage stats)

createClient(options?)

Returns a raw AnthropicBedrock client for advanced usage.

Constants

const { DEFAULT_MODEL, DEFAULT_REGION } = require('claude-bedrock-client');
// DEFAULT_MODEL  → 'us.anthropic.claude-sonnet-4-6'
// DEFAULT_REGION → 'us-east-1'

Running the example

# Copy and fill in your credentials
cp .env.example .env  # edit .env with your AWS keys

node example/index.js

License

MIT