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

@natiwo/bedrock

v0.1.0

Published

AWS Bedrock client for AI model integration with Claude, Llama, Titan and more

Readme

@natiwo/bedrock

Generic AWS Bedrock client for AI model integration supporting Claude, Llama, Titan, and more.

Features

  • Multi-Model Support: Claude, Llama, Titan, Jamba, Command, Mistral
  • Streaming: Real-time response streaming
  • Type-Safe: Full TypeScript support with strict typing
  • Tool Calling: Function calling for supported models (Claude 3+)
  • Vision: Image input support for capable models
  • Cost Estimation: Built-in pricing calculator
  • Error Handling: Comprehensive error types
  • Zero Dependencies: Only requires AWS SDK

Installation

pnpm add @natiwo/bedrock @aws-sdk/client-bedrock-runtime

Quick Start

import { BedrockClient } from '@natiwo/bedrock';

const client = new BedrockClient({
  region: 'us-east-2',
  profile: 'default', // or use credentials
});

const response = await client.invoke({
  model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
  messages: [
    {
      role: 'user',
      content: 'Explain quantum computing in simple terms',
    },
  ],
  maxTokens: 1024,
  temperature: 0.7,
});

console.log(response.content[0].text);
console.log(`Cost: $${estimateCost(response.model, response.usage)}`);

Streaming

const stream = client.invokeStream({
  model: 'anthropic.claude-3-5-haiku-20241022-v1:0',
  messages: [{ role: 'user', content: 'Write a poem about code' }],
});

for await (const chunk of stream) {
  if (chunk.type === 'content_block_delta' && chunk.delta?.text) {
    process.stdout.write(chunk.delta.text);
  }
}

Tool Calling (Function Calling)

const response = await client.invoke({
  model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
  messages: [
    {
      role: 'user',
      content: 'What is the weather in San Francisco?',
    },
  ],
  tools: [
    {
      name: 'get_weather',
      description: 'Get current weather for a location',
      input_schema: {
        type: 'object',
        properties: {
          location: { type: 'string', description: 'City name' },
          unit: { type: 'string', enum: ['celsius', 'fahrenheit'] },
        },
        required: ['location'],
      },
    },
  ],
});

if (response.stopReason === 'tool_use') {
  const toolUse = response.content.find((c) => c.type === 'tool_use');
  console.log(`Calling tool: ${toolUse.name}`, toolUse.input);
}

Supported Models

Anthropic Claude

  • anthropic.claude-3-5-sonnet-20241022-v2:0 (recommended - balanced)
  • anthropic.claude-3-5-haiku-20241022-v1:0 (fast & cheap)
  • anthropic.claude-3-opus-20240229-v1:0 (most powerful)

Meta Llama

  • meta.llama3-1-70b-instruct-v1:0
  • meta.llama3-2-3b-instruct-v1:0

Amazon Titan

  • amazon.titan-text-premier-v1:0
  • amazon.titan-text-express-v1

Others

  • AI21 Jamba
  • Cohere Command
  • Mistral AI

Utilities

import {
  estimateCost,
  getRecommendedModel,
  supportsTools,
  supportsVision,
  getMaxContextTokens,
} from '@natiwo/bedrock';

// Get recommended model for use case
const model = getRecommendedModel('balanced'); // 'fast' | 'balanced' | 'powerful'

// Check capabilities
if (supportsTools(model)) {
  console.log('Model supports function calling');
}

if (supportsVision(model)) {
  console.log('Model supports image inputs');
}

// Get limits
console.log(`Max context: ${getMaxContextTokens(model)} tokens`);

Configuration

Using AWS Profile

const client = new BedrockClient({
  region: 'us-east-2',
  profile: 'my-profile',
});

Using Credentials

const client = new BedrockClient({
  region: 'us-east-2',
  credentials: {
    accessKeyId: process.env.AWS_ACCESS_KEY_ID,
    secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
  },
});

Environment Variables

AWS_REGION=us-east-2
AWS_PROFILE=default

Error Handling

import { BedrockError } from '@natiwo/bedrock';

try {
  const response = await client.invoke({ ... });
} catch (error) {
  if (error instanceof BedrockError) {
    console.error(`Bedrock Error: ${error.message}`);
    console.error(`Status: ${error.statusCode}`);
    console.error(`Request ID: ${error.requestId}`);
  }
}

Cost Estimation

import { estimateCost } from '@natiwo/bedrock';

const response = await client.invoke({ ... });
const cost = estimateCost(response.model, response.usage);

console.log(`Input tokens: ${response.usage.inputTokens}`);
console.log(`Output tokens: ${response.usage.outputTokens}`);
console.log(`Estimated cost: $${cost.toFixed(6)}`);

License

MIT © Claudiomar Emanuel Estevam

Author

Claudiomar Emanuel Estevam