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

auragate

v0.2.2

Published

Self-hosted AI Gateway & Smart API Key Rotator for OpenCode, Cursor, and LLMs with RTK Token Saver

Readme

License: MIT Next.js TypeScript Prisma Snyk SAST


📖 Overview

AuraGate is a high-performance, self-hosted AI Gateway Proxy, Smart API Key Rotator, and Token Optimization Engine. Built with Next.js 16, TypeScript, Tailwind CSS, and SQLite (Prisma), AuraGate provides a unified OpenAI-compatible endpoint (/v1) that load-balances requests across multiple LLM providers, automatically handles rate-limiting failovers, reduces token costs, and secures client connections with custom gateway access tokens.

  █████╗ ██╗   ██╗██████╗  █████╗  ██████╗  █████╗ ████████╗███████╗
 ██╔══██╗██║   ██║██╔══██╗██╔══██╗██╔════╝ ██╔══██╗╚══██╔══╝██╔════╝
 ███████║██║   ██║██████╔╝███████║██║  ███╗███████║   ██║   █████╗  
 ██╔══██║██║   ██║██╔══██╗██╔══██║██║   ██║██╔══██║   ██║   ██╔══╝  
 ██║  ██║╚██████╔╝██║  ██║██║  ██║╚██████╔╝██║  ██║   ██║   ███████╗
 ╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝

 ⚡ AuraGate v0.1.0 — Smart AI Gateway & API Key Rotator (OpenCode & LLMs)

 > Server Endpoint : http://localhost:20128/v1
 > Web Dashboard   : http://localhost:20128
 > Status          : Ready to route ✓

🎯 Architecture Diagram

flowchart LR
    subgraph Clients["Clients & AI Editors"]
        OC["OpenCode CLI"]
        CU["Cursor IDE"]
        CL["Cline / Roo-Code"]
        CR["cURL / Custom SDK"]
    end

    subgraph AG["AuraGate Engine (Port 20128)"]
        AUTH["Gateway Token Auth (ar-sk-...)"]
        CSP["Centralized System Prompt Injector"]
        RTK["RTK Token Saver & Sanitizer"]
        ROT["Smart Key Pool Rotator & Cooldown"]
        DB[(SQLite DB)]
    end

    subgraph Providers["LLM Providers"]
        GROQ["Groq API"]
        MIST["Mistral AI"]
        OAI["OpenAI"]
        DS["DeepSeek"]
        GEM["Google Gemini"]
    end

    Clients -->|Bearer Token| AUTH
    AUTH --> CSP
    CSP --> RTK
    RTK --> ROT
    ROT <--> DB
    ROT -->|Auto Failover & Round-Robin| Providers

🌟 Key Features

🔄 1. Smart API Key Pool & Automatic Failover

  • Round-Robin Key Rotation: Distributes requests across active provider keys sorted by priority.
  • Failover Cooldown (429 / 401 / 403 / 5xx): If a key hits a rate limit or authorization error, AuraGate automatically puts it in temporary cooldown (10–30m) and retries the request using the next available candidate key without failing client connections.

✨ 2. Auto-Detect Provider & Live Model Importer

  • Provider Auto-Detection: Automatically detects AI providers from key prefixes (gsk_, sk-or-, sk-, AIzaSy, sk-ant-).
  • Live Model Syncing: Queries provider /models endpoints to automatically import and register active models.

⚡ 3. RTK Token Saver & Prompt Optimizer

  • Whitespace & Linebreak Sanitization: Trims excessive blank lines (\n\n\n+ $\rightarrow$ \n\n) and trailing spaces.
  • System Prompt Deduplication: Merges duplicate consecutive system messages.
  • In-Memory LRU Caching: Caches identical query responses to save 100% tokens on repeated prompts.

🎯 4. Centralized System Prompt Injection

  • Global Rules Engine: Inject global instructions (e.g. "Always respond in Indonesian and write clean TypeScript code") into every chat completion centrally from the Web Dashboard.

🔒 5. Multi-Client Gateway Access Tokens

  • Issue secure gateway access tokens (ar-sk-...) for different team members or local editors.
  • Protects the proxy endpoint from unauthorized external access.

📦 6. Live Model Catalog & 1-Click Copy

  • Search across all imported models from active keys and copy model IDs in 1 click for editor setup.

⚡ 7. Live Provider Network Ping Test

  • Test real-time network latency (in ms) to Groq, Mistral AI, OpenAI, DeepSeek, Gemini, and OpenRouter directly from the dashboard.

📊 8. Graph Analytics & Usage Breakdown

  • Visual request distribution per provider, average processing latency, and estimated total token savings.

🚀 Quick Start

📦 Option 1: Global NPM Installation (Recommended)

Install AuraGate globally and launch it instantly from any terminal window:

# Install AuraGate globally from NPM
npm install -g auragate

# Launch AuraGate Server & Web Dashboard
auragate

# Or launch on a custom port
auragate -p 8080

Open http://localhost:20128 in your browser to access the Web Admin Dashboard.


🛠️ Option 2: Local Source Installation

# Clone the repository
git clone https://github.com/gugun024/Auragate.git
cd Auragate

# Install dependencies
npm install

# Initialize SQLite database schema
npx prisma db push

# Launch Development Server
npm run dev

🔌 Integration Guides

OpenCode CLI (opencode.json)

{
  "provider": "openai",
  "options": {
    "baseURL": "http://localhost:20128/v1",
    "apiKey": "ar-sk-your-client-gateway-token"
  }
}

cURL

curl -X POST http://localhost:20128/v1/chat/completions \
  -H "Authorization: Bearer ar-sk-your-client-gateway-token" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "Halo dari cURL!"}]
  }'

Python SDK (openai)

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:20128/v1",
    api_key="ar-sk-your-client-gateway-token"
)

response = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Halo dari Python!"}]
)

print(response.choices[0].message.content)

Node.js SDK (openai)

import OpenAI from 'openai';

const openai = new OpenAI({
  baseURL: 'http://localhost:20128/v1',
  apiKey: 'ar-sk-your-client-gateway-token',
});

async function main() {
  const completion = await openai.chat.completions.create({
    model: 'gpt-4o-mini',
    messages: [{ role: 'user', content: 'Halo dari Node.js!' }],
  });

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

main();

Context7 MCP Integration

Add Context7 MCP server to your editor configuration (opencode.json / claude_desktop_config.json):

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@context7/mcp-server"]
    }
  }
}

🛡️ Security & Privacy

  • Local SQLite Database: Your API keys and client access tokens remain 100% local on your machine in prisma/dev.db.
  • .gitignore Protected: .env and SQLite database files are excluded from git commits to prevent accidental token exposure.

📜 License

MIT License © 2026 AuraGate Team