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

@anygpt/router

v0.6.1

Published

Core router for AnyGPT - routes requests to multiple AI providers

Readme

AnyGPT Router

⚠️ WORK IN PROGRESS: This package is under active development. APIs and routing mechanisms may change significantly. Use at your own risk in production environments.

A secure, enterprise-ready router for AI providers with flexible configuration and MCP protocol support.

🎯 Overview

The AnyGPT Router provides a unified interface to AI providers with:

  • 🔧 Flexible configuration - Provider-based configuration system
  • 🔒 Enterprise security - Secure credential management and proxy support
  • 🎭 Provider abstraction - Consistent API across different AI providers
  • 📊 MCP compliance - Seamless integration with MCP clients
  • 🧪 Test-driven - Comprehensive test coverage
  • ⚡ TypeScript-first - Full type safety and IntelliSense

🚀 Quick Start

Installation

npm install @anygpt/router

Basic Usage

import { GenAIRouter } from '@anygpt/router';
import { OpenAIConnectorFactory } from '@anygpt/openai';

// Create router and register connector factory
const router = new GenAIRouter();
router.registerConnector(new OpenAIConnectorFactory());

// Create connector instance
const connector = router.createConnector('openai', {
  apiKey: process.env.OPENAI_API_KEY,
  baseURL: 'https://api.openai.com/v1',
});

// Make request
const response = await connector.chatCompletion({
  messages: [{ role: 'user', content: 'Hello!' }],
  model: 'gpt-4o',
});

Configuration-Driven Approach

import { defineConfig, createRouter } from '@anygpt/router';

// Define configuration
const config = defineConfig({
  providers: {
    openai: {
      type: 'openai',
      apiKey: process.env.OPENAI_API_KEY,
      baseURL: 'https://api.company.com/openai/v1',
    },
  },
});

// Create router with config
const router = createRouter(config);

Documentation

| Document | Description | | ---------------------------------------------- | --------------------------------------------------------------- | | Configuration Guide | Provider configuration system, environment setup, customization | | API Reference | Complete API documentation, types, and examples | | Architecture | System design, patterns, and extension points | | Connector Usage | Provider-specific usage and best practices | | Logging Guide | Logger integration, custom loggers, and best practices |

Supported Providers

| Provider | Models | Features | | ------------- | -------------------------- | ----------------------------------------- | | OpenAI | GPT-4o, GPT-4, GPT-3.5, o1 | Chat completion, function calling, vision | | Anthropic | Claude Sonnet, Opus, Haiku | Native API, function calling | | Mock | test-model | Development and testing |

Configuration Examples

Environment-Based

export OPENAI_API_KEY=sk-your-key
export ANYGPT_LOG_LEVEL=info

Company Proxy

import { defineConfig } from '@anygpt/router';

const config = defineConfig({
  providers: {
    openai: {
      type: 'openai',
      apiKey: process.env.OPENAI_API_KEY,
      baseURL: 'https://api.company.com/openai/v1',
      headers: { 'X-Company-ID': 'engineering' },
    },
  },
});

Azure OpenAI

import { defineConfig } from '@anygpt/router';

const config = defineConfig({
  providers: {
    azure: {
      type: 'openai',
      apiKey: process.env.AZURE_OPENAI_API_KEY,
      baseURL: 'https://resource.openai.azure.com/openai/deployments/gpt-4o',
      headers: { 'api-version': '2024-02-15-preview' },
    },
  },
});

Architecture

MCP Client → @anygpt/mcp → @anygpt/router → AI Provider APIs
  • Router Layer (this package): Provider abstraction, routing, security
  • MCP Layer (separate package): MCP protocol implementation
  • Connector Pattern: Extensible provider implementations
  • Configuration System: Flexible provider-based configuration

Development

Setup

npm install
npm test          # Run tests
npm run build     # Build package

Testing

  • Comprehensive test coverage for all functionality
  • Mock connector for development and testing
  • Type-safe test utilities and fixtures

Project Structure

src/
├── types/           # Core type definitions
├── connectors/      # Provider implementations
│   ├── base/        # Base connector interface
│   ├── openai/      # OpenAI connector implementation
│   └── registry.ts  # Connector registry
├── lib/             # Core router implementation
└── config.ts        # Configuration system

Key Features

Flexible Configuration

  • Provider-based configuration system
  • Easy customization and extension
  • Environment variable support
  • Company-specific configurations

Enterprise-Ready

  • Secure credential management
  • Proxy and custom header support
  • Comprehensive error handling
  • Production-tested patterns

Developer Experience

  • Full TypeScript support
  • Comprehensive documentation
  • Test-driven development
  • Clear error messages

🔮 Roadmap

  • Additional Providers: Anthropic, Google, local models, custom endpoints
  • Advanced Features: Request middleware, multi-provider fallback
  • Monitoring: Metrics, logging, cost tracking
  • Enhanced MCP Integration: Advanced MCP server features

License

MIT - See LICENSE for details.


Built with ❤️ for the MCP ecosystem | Documentation | API Reference | Architecture