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

abc-xyz-ai

v0.1.0

Published

Unified TypeScript library for multiple LLM providers

Readme

AISuite

AISuite is a unified TypeScript library that provides a single, consistent interface for interacting with multiple Large Language Model (LLM) providers. The library uses OpenAI's API format as the standard interface while supporting OpenAI and Anthropic Claude.

Features

  • 🔄 Unified API: Single interface compatible with OpenAI's API structure
  • 🤖 Multi-Provider Support: Currently supports OpenAI and Anthropic
  • 🎯 Provider Selection: Use provider:model format (e.g., openai:gpt-4o, anthropic:claude-3-haiku-20240307)
  • 🛠️ Tool Calling: Transparent tool/function calling across all providers
  • 🚀 Streaming: Real-time streaming responses with consistent API
  • 🔒 Type Safety: Full TypeScript support with comprehensive type definitions
  • Error Handling: Unified error handling across providers

Installation

npm install aisuite

Quick Start

import { Client } from 'aisuite';

const client = new Client({
  openai: { apiKey: process.env.OPENAI_API_KEY },
  anthropic: { apiKey: process.env.ANTHROPIC_API_KEY },
});

// Use any provider with identical interface
const response = await client.chat.completions.create({
  model: 'openai:gpt-4o',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'Hello!' }
  ],
});

console.log(response.choices[0].message.content);

Usage Examples

Basic Chat Completion

// OpenAI
const openaiResponse = await client.chat.completions.create({
  model: 'openai:gpt-4o',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is TypeScript?' }
  ],
  temperature: 0.7,
  max_tokens: 1000,
});

// Anthropic - exact same interface
const anthropicResponse = await client.chat.completions.create({
  model: 'anthropic:claude-3-haiku-20240307',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is TypeScript?' }
  ],
  temperature: 0.7,
  max_tokens: 1000,
});

Tool/Function Calling

const tools = [
  {
    type: 'function' as const,
    function: {
      name: 'get_weather',
      description: 'Get current weather for a location',
      parameters: {
        type: 'object',
        properties: {
          location: { type: 'string', description: 'City name' }
        },
        required: ['location']
      }
    }
  }
];

// Works identically across all providers
const response = await client.chat.completions.create({
  model: 'anthropic:claude-3-haiku-20240307',
  messages: [{ role: 'user', content: 'What\'s the weather in NYC?' }],
  tools,
  tool_choice: 'auto'
});

if (response.choices[0].message.tool_calls) {
  console.log('Tool calls:', response.choices[0].message.tool_calls);
}

Streaming Responses

const stream = await client.chat.completions.create({
  model: 'openai:gpt-4o',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true
});

// TypeScript: cast to AsyncIterable<ChatCompletionChunk>
for await (const chunk of stream as AsyncIterable<ChatCompletionChunk>) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

Streaming with Abort Controller

const controller = new AbortController();

// Abort after 5 seconds
setTimeout(() => controller.abort(), 5000);

const stream = await client.chat.completions.create({
  model: 'anthropic:claude-3-haiku-20240307',
  messages: [{ role: 'user', content: 'Write a long story' }],
  stream: true
}, { signal: controller.signal });

try {
  for await (const chunk of stream as AsyncIterable<ChatCompletionChunk>) {
    process.stdout.write(chunk.choices[0]?.delta?.content || '');
  }
} catch (error) {
  if (error.name === 'AbortError') {
    console.log('Stream aborted');
  }
}

Error Handling

import { AISuiteError, ProviderNotConfiguredError } from 'aisuite';

try {
  const response = await client.chat.completions.create({
    model: 'invalid:model',
    messages: [{ role: 'user', content: 'Hello' }]
  });
} catch (error) {
  if (error instanceof ProviderNotConfiguredError) {
    console.error('Provider not configured:', error.message);
  } else if (error instanceof AISuiteError) {
    console.error('AISuite error:', error.message, error.provider);
  } else {
    console.error('Unknown error:', error);
  }
}

API Reference

Client Configuration

const client = new Client({
  openai?: {
    apiKey: string;
    baseURL?: string;
    organization?: string;
  },
  anthropic?: {
    apiKey: string;
    baseURL?: string;
  }
});

Chat Completion Request

All providers use the standard OpenAI chat completion format:

interface ChatCompletionRequest {
  model: string;              // "provider:model" format
  messages: ChatMessage[];
  tools?: Tool[];
  tool_choice?: ToolChoice;
  temperature?: number;
  max_tokens?: number;
  top_p?: number;
  frequency_penalty?: number;
  presence_penalty?: number;
  stop?: string | string[];
  stream?: boolean;           // Not yet supported
  user?: string;
}

Helper Methods

// List configured providers
client.listProviders(); // ['openai', 'anthropic']

// Check if a provider is configured
client.isProviderConfigured('openai'); // true

Current Limitations

  • Only OpenAI and Anthropic providers are currently supported (Gemini, Mistral, and Bedrock coming soon)
  • Tool calling requires handling tool responses manually
  • Streaming tool calls require manual accumulation of arguments

Development

# Install dependencies
npm install

# Build the project
npm run build

# Run tests
npm test

# Run examples
cd examples
npm install

#Run basic usage example only:
npm run example:basic
# Run tool calling example only:
npm run example:tools
# Run the full test suite:
npm run test:examples