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

ai-service-hub

v3.2.1

Published

A service hub for AI services

Downloads

51

Readme

AI Service Hub

npm version License: MIT TypeScript

A unified TypeScript library for interacting with multiple AI services through a single, consistent interface.

Features

  • 🚀 Single API - Access multiple AI services through one consistent interface
  • 🔌 Multiple Providers - Support for OpenAI, Claude, Groq, Gemini, DeepSeek, Perplexity, Ollama, and LM Studio
  • 🖼️ Vision Support - Process images with AI models that support vision capabilities
  • 📊 Embeddings - Generate embeddings for semantic search and similarity applications
  • 🔄 Auto-Detection - Automatically select the appropriate service based on the model
  • 💬 Chat Interfaces - Easy-to-use chat completion APIs with system prompts
  • 📝 Format Flexibility - Support for text and JSON response formats

Installation

npm install ai-service-hub

Updating Model Lists

The repository includes a helper script for refreshing the available models directly from each provider. Set the necessary API keys as environment variables and run:

npm run update-models

This will regenerate the Model*.ts files under src/ with the latest model IDs returned by the providers.

Supported Services

| Service | Chat | Vision | Embeddings | Description | | ---------- | ---- | ------ | ---------- | ------------------------------------ | | OpenAI | ✅ | ✅ | ✅ | GPT-4o, GPT-4.5-Preview, O1, etc. | | Claude | ✅ | ✅ | ❌ | Claude 3.7, 3.5 Sonnet & Haiku, Opus | | Groq | ✅ | ✅ | ✅ | Grok-2, Grok-2-Vision, Grok-Beta | | Gemini | ✅ | ❌ | ✅ | Gemini 2.5, 2.0, 1.5, and Imagen 3.0 | | DeepSeek | ✅ | ❌ | ❌ | DeepSeek Chat, Reasoner | | Perplexity | ✅ | ❌ | ❌ | Sonar models, R1-1776 | | Ollama | ✅ | ✅ | ✅ | Self-hosted open source models | | LM Studio | ✅ | ✅ | ✅ | Self-hosted Hugging Face models |

Current Model Support

OpenAI Models

  • GPT-4.5 Preview
  • GPT-4o Mini
  • GPT-4o
  • GPT-3.5 Turbo
  • GPT-4
  • GPT-4 Turbo
  • GPT-4 Turbo Preview
  • GPT-4 Vision Preview
  • O1
  • O1 Mini
  • O1 Preview
  • O3 Mini
  • ChatGPT-4o Latest
  • ChatGPT-4o Mini

Claude Models

  • Claude 3.7 Sonnet Latest
  • Claude 3.5 Haiku Latest
  • Claude 3.5 Sonnet Latest
  • Claude 3.5 Sonnet (20240620)
  • Claude 3 Opus Latest
  • Claude 3 Sonnet (20240229)
  • Claude 3 Haiku (20240307)

Gemini Models

  • Gemini 2.5 Pro Experimental (03/25)
  • Gemini 2.0 Flash
  • Gemini 2.0 Flash Lite
  • Gemini 1.5 Flash
  • Gemini 1.5 Flash 8B
  • Gemini 1.5 Pro
  • Gemini Embedding Experimental
  • Imagen 3.0 Generate 002

DeepSeek Models

  • DeepSeek Chat
  • DeepSeek Reasoner

Perplexity Models

  • Sonar Deep Research
  • Sonar Reasoning Pro
  • Sonar Reasoning
  • Sonar Pro
  • Sonar
  • R1-1776

Basic Usage

import { GlobalInstance, ModelOpenAi } from 'ai-service-hub';

// Initialize with your API keys
const ai = new GlobalInstance({
  openAiKey: 'your-openai-key',
  claudeKey: 'your-claude-key',
  grokKey: 'your-groq-key',
  // Add other service keys as needed
});

// Basic chat completion
async function getCompletion() {
  const response = await ai.chat({
    prompt: "What's the capital of France?",
    model: ModelOpenAi.gpt4o,
    systemPrompt: "You are a helpful assistant."
  });
  
  console.log(response);
}

Examples

OpenAI Chat

import { OpenAiInstance, ModelOpenAi } from 'ai-service-hub';

const openai = new OpenAiInstance('your-api-key');

const response = await openai.chat(
  "Explain quantum computing in simple terms", 
  "You are a helpful assistant", 
  ModelOpenAi.gpt4o
);

Claude Chat

import { ClaudeInstance, ModelClaude } from 'ai-service-hub';

const claude = new ClaudeInstance('your-api-key');

const response = await claude.chat(
  "Write a short story about a robot learning to paint", 
  "You are a creative writer", 
  ModelClaude.claude37SonnetLatest
);

Vision API (OpenAI)

import { OpenAiInstance, ModelOpenAIVision } from 'ai-service-hub';

const openai = new OpenAiInstance('your-api-key');

// Convert your image to base64 first
const response = await openai.vision(
  "What's in this image?", 
  base64Image, 
  "Describe the image in detail",
  ModelOpenAIVision.gpt4o
);

Embeddings (OpenAI)

import { OpenAiInstance, ModelOpenAiEmbedding } from 'ai-service-hub';

const openai = new OpenAiInstance('your-api-key');

const embedding = await openai.embedding(
  "This is a sample text to embed", 
  ModelOpenAiEmbedding.textEmbedding3Large
);

Using Global Instance

import { GlobalInstance, ModelOpenAi, ModelClaude } from 'ai-service-hub';

const ai = new GlobalInstance({
  openAiKey: 'your-openai-key',
  claudeKey: 'your-claude-key'
});

// OpenAI will be automatically selected based on the model
const openaiResponse = await ai.chat({
  prompt: "Explain how rainbows form",
  model: ModelOpenAi.gpt4o
});

// Claude will be automatically selected based on the model
const claudeResponse = await ai.chat({
  prompt: "Write a poem about autumn",
  model: ModelClaude.claude37SonnetLatest
});

Configuration

Each service requires different configuration parameters:

const globalInstance = new GlobalInstance({
  openAiKey: 'your-openai-key',
  claudeKey: 'your-anthropic-key',
  grokKey: 'your-groq-key',
  geminiKey: 'your-gemini-key',
  deepSeekKey: 'your-deepseek-key',
  perplexityKey: 'your-perplexity-key',
  ollamaUrl: 'http://localhost:11434',
  lmstudioUrl: 'http://localhost:1234'
});

Copy the provided .env.example file to .env and fill in your API keys to run the library locally.

Recent Updates

  • Updated to support newest models including Claude 3.7 Sonnet and Gemini 2.5
  • Added comprehensive model definitions for all providers
  • Added Claude AI integration with chat and vision capabilities
  • Converted all enums to modern TypeScript object literals
  • Added ESLint and Prettier for code quality
  • Enhanced vision capabilities across multiple providers
  • Improved type safety throughout the codebase

License

MIT

Author

Bartłomiej Zimny