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

@alok1910/ai-router

v0.8.3

Published

Universal AI memory and credit router — automatic failover across multiple AI providers with persistent memory

Readme

@alok1910/ai-router

CI npm version License: MIT Node.js

Universal AI memory and credit router.

Stop re-explaining yourself every time you switch AI tools. ai-router remembers your preferences, keeps your conversation history, and automatically switches to the next provider when one runs out — all from your terminal with natural scroll and inline commands.


Install

npm install -g @alok1910/ai-router

Requires Node.js 22 or higher.


Quick Start

# 1. Configure providers and preferences
ai-router setup

# 2. Start chatting
ai-router chat

What It Looks Like

  ╔════════════════════════════════════════╗
  ║ AI Router v0.7.0                       ║
  ║ Universal AI Memory & Router           ║
  ╚════════════════════════════════════════╝

  Type a message to chat  ·  /help for commands

  Providers  ● Groq  ·  ● Gemini Flash

  You: explain how the router works

  ◆ Groq
  ────────────────────────────────────────
  The router tries each provider in your
  configured sequence. If one hits a rate
  limit or your personal cap, it switches
  automatically to the next one...
  ────────────────────────────────────────

  You: /cap
  Token Caps

  Groq
  ████████░░░░░░░░░░░░ 40%
  4,000 / 10,000 tokens today

  Gemini Flash
  ██████████████████░░ 90%
  2,700 / 3,000 tokens today

  You: /cap set groq 15000
  ✓ Groq cap set to 15,000 tokens/day

Slash Commands Inside Chat

All commands work inline — no need to exit and re-enter.

| Command | What it does | |---|---| | /help | Show all available commands | | /cap | Show token usage and caps with progress bars | | /cap set <provider> <n> | Set daily token cap | | /cap remove <provider> | Remove a cap | | /memory | Show stored preferences | | /memory set <key> <value> | Update a preference | | /memory delete <key> | Remove a preference | | /status | Show provider states and last errors | | /providers | Same as /status | | /sequence | Show priority sequences | | /history | Show recent conversation history | | /index [path] | Re-index project for code context | | /clear | Clear the screen | | /new | Start a fresh session | | /exit or /quit | Quit ai-router |


Commands

ai-router chat

Start a conversation. Natural terminal scroll — use your trackpad or mouse wheel to scroll through history.

ai-router chat
ai-router chat --project ./my-project   # with code context

ai-router setup

Guided onboarding. Configure your name, language, tone, and add providers.

ai-router setup

ai-router provider

Add, list, remove, and test providers. No code changes ever needed.

ai-router provider add        # search by name, paste key, done
ai-router provider list       # show all configured providers
ai-router provider remove     # remove a provider
ai-router provider test       # verify a provider key works
ai-router provider update     # update a key or model name

Adding any provider:

ai-router provider add

? Search for a provider: groq
  ● Groq — free tier, fast inference

? Groq API key: **********************
✓ Groq connected and saved

Adding Ollama (local, no API key needed):

ai-router provider add
# Search: ollama
# Enter which model you pulled: llama3

ai-router cap

Set your own daily token limit per provider — below the real API limit.

ai-router cap set Groq 10000
ai-router cap show
ai-router cap remove "Gemini Flash"

ai-router sequence

Set provider priority order per context type.

ai-router sequence set coding "Gemini Flash" Groq
ai-router sequence set general Groq "Gemini Flash"
ai-router sequence show
ai-router sequence remove coding

ai-router index

Index a project folder for code-aware AI responses.

ai-router index ./my-project
ai-router index .

Uses graphify if Python 3.10+ is available. Falls back to built-in compressor otherwise.

ai-router memory

Store preferences that persist across every session and provider.

ai-router memory show
ai-router memory set language Hindi
ai-router memory set tone casual
ai-router memory set expertise intermediate
ai-router memory delete language

ai-router history

Show recent conversation history.

ai-router history

Supported Providers

| Provider | Free API | Notes | |---|---|---| | Gemini Flash | ✅ Yes | Default first provider | | Groq | ✅ Yes | Default second provider | | Claude (Anthropic) | ❌ Paid | Add with: provider add | | OpenAI GPT | ❌ Paid | Add with: provider add | | Mistral | ❌ Paid | Add with: provider add | | Perplexity | ❌ Paid | Add with: provider add | | Ollama (local) | ✅ Free | Runs on your machine | | LM Studio (local) | ✅ Free | Runs on your machine | | Any custom LLM | Varies | Any HTTP endpoint works |

Free API keys:


How Failover Works

You send a message
        ↓
Router tries first provider in your sequence
        ↓
Provider hits rate limit or your personal cap
        ↓
Router switches to next provider automatically
        ↓
Full conversation context carries over
        ↓
You see which provider responded in [brackets]

Type /status at any time to see exactly what each provider is doing and why.


Memory

Stored permanently at ~/.ai-router/memory.db. Injected into every prompt sent to any provider. Survives closing and reopening the tool.

ai-router memory set language Hindi
# Every AI responds in Hindi from now on
# Works across Groq, Gemini, Claude — any provider you configure

Code Context

Index your project once and every code question gets compressed context automatically:

ai-router index ./my-project
ai-router chat --project ./my-project

# Now ask: what files handle routing?
# AI knows your actual project structure

Where Your Data Lives

Everything stays on your machine at ~/.ai-router/:

~/.ai-router/
  config.json     providers, sequences, caps
  .env            your API keys
  memory.db       conversation history and preferences
  graphs/         project indexes from ai-router index
  logs/           debug logs
  venv/           Python environment for graphify

Nothing is sent anywhere except API calls to your configured providers.


Architecture

┌─────────────────────────────────────────────────┐
│              ai-router chat                      │
│  Natural scroll · Inline /commands · No exit     │
└────────────────────┬────────────────────────────┘
                     │
┌────────────────────▼────────────────────────────┐
│               src/router.js                      │
│   Reads config → sequence → enforces caps        │
│   Handles failover automatically                 │
└────┬──────────────┬──────────────┬──────────────┘
     │              │              │
┌────▼─────────┐ ┌──▼────────────┐ ┌▼─────────────┐
│ google.js    │ │openai-compat  │ │ anthropic.js  │
│ All Gemini   │ │Groq,GPT,Ollama│ │ All Claude    │
└──────────────┘ └───────────────┘ └──────────────┘
                     │
┌────────────────────▼────────────────────────────┐
│           ~/.ai-router/                          │
│   config.json · .env · memory.db · graphs/       │
└─────────────────────────────────────────────────┘

License

MIT — free to use, modify, and distribute.