SRouter

skill
Security Audit
Fail
Health Pass
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Community trust — 16 GitHub stars
Code Fail
  • rm -rf — Recursive force deletion command in apps/api/package.json
  • process.env — Environment variable access in apps/api/src/controllers/admin.controller.ts
Permissions Pass
  • Permissions — No dangerous permissions requested

No AI report is available for this listing yet.

SUMMARY

Local-first AI Gateway: Connect Claude Code, Cursor, Windsurf, & Cline to Antigravity, OpenAI, Claude, & Gemini. One endpoint, OAuth auto-refresh, quota pooling & failover.

README.md

⚡ SRouter

Local-first AI gateway & LLM proxy for OpenAI, Anthropic, and custom models.

Keep a single stable endpoint while SRouter routes requests, refreshes OAuth tokens, enforces quotas, and monitors live telemetry.

Version MIT License Node.js Hono React SQLite

SRouter Dashboard Walkthrough

Quick StartProvidersCoding ToolsIntegrationsAPIDocker


⚡ Quick Start

Get SRouter running locally in under a minute.

Option A: Docker (Recommended)

docker run -d \
  --name srouter \
  --restart unless-stopped \
  -p 3000:3000 \
  -p 1455:1455 \
  -v $HOME/.srouter:/root/.srouter \
  ghcr.io/seaavey/srouter:latest

Data is persisted on the host at ~/.srouter ($HOME/.srouter). Using a named volume like srouter_data:/root/.srouter will store data inside Docker at /var/lib/docker/volumes/srouter_data/_data instead of on the host.

Option B: Local Node.js

git clone https://github.com/seaavey/SRouter.git
cd SRouter
pnpm install
pnpm build
pnpm start

Open http://localhost:3000 to access the dashboard. Configure your provider accounts under Providers, generate a virtual key in API Keys, and test endpoints immediately in Playground.


🔌 Connect Coding Tools

Use @srouter/cli to configure AI developer tools with one command:

# Interactive setup wizard
npx @srouter/cli setup

# Check status & link tools
npx @srouter/cli doctor
npx @srouter/cli link claude --model claude-3-7-sonnet
npx @srouter/cli link opencode --model antigravity/gemini-3.7-flash-high

# Run tools directly wrapped in SRouter environment
npx @srouter/cli run claude

Manual Configuration (Cursor / Windsurf / Cline / Continue)

Point your editor or extension to your local SRouter instance:

  • Base URL: http://localhost:3000/v1
  • API Key: sr-live-your_key (or your master admin key)
  • Model: Any model from http://localhost:3000/v1/models (e.g. antigravity/gemini-3.7-flash-high, openai_codex/gpt-4o)

🌐 Supported Providers

SRouter normalizes authentication and protocol differences across all major model providers:

Provider Model Prefix Auth Method Streaming Live Quota
Google Antigravity antigravity/* OAuth 2.0 PKCE
OpenAI Codex / ChatGPT openai_codex/* OAuth 2.0 PKCE
Anthropic Claude anthropic/* API Key / OAuth
OpenCode Zen opencode_zen/* Free / Access Token
Amazon Q / Kiro kiro/* SigV4 / API Key
Qoder qoder/* OAuth / Device Token
GoRouter gorouter/* API Key
BluesMinds bluesminds/* API Key
SeekAI / TabiToken seekai/*, tabitoken/* API Key
Custom Endpoints custom/* Custom Headers Configurable

💻 Integrate

SRouter exposes standard OpenAI and Anthropic compatible interfaces.

OpenAI SDK (Python)

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:3000/v1",
    api_key="sr-live-your_virtual_key"
)

stream = client.chat.completions.create(
    model="antigravity/gemini-3.7-flash-high",
    messages=[{"role": "user", "content": "Explain vector embeddings in one sentence."}],
    stream=True
)

for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)

Anthropic SDK (TypeScript)

import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
    baseURL: "http://localhost:3000/v1",
    apiKey: "sr-live-your_virtual_key"
});

const message = await client.messages.create({
    model: "anthropic/claude-3-7-sonnet",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello from SRouter!" }]
});

console.log(message.content[0].text);

cURL

curl -N http://localhost:3000/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sr-live-your_virtual_key" \
  -d '{
    "model": "antigravity/gemini-3.7-flash-high",
    "messages": [{"role": "user", "content": "Ping!"}],
    "stream": true
  }'

🎯 Core Features

  • Unified Protocol Translation: Translate between OpenAI chat/completions and Anthropic messages formats dynamically.
  • Automated OAuth Refresh: Background daemon automatically keeps short-lived OAuth sessions refreshed without downtime.
  • Failover & Smart Combo Routing: Define cascade fallback chains to automatically recover from rate limits (429) or provider outages.
  • Token Saver Engine: System-level prompt compression and concise coding rules to cut inference cost.
  • Virtual API Keys: Issue scoped keys (sr-live-*) with individual rate limits, token quotas, and expiration windows.
  • Built-in Cloudflare Tunnel: Expose your local gateway securely to the internet with zero open ports directly from the UI.
  • Embedded Observability: Track exact token usage, cache efficiency, and estimated costs locally in SQLite WAL mode.

📡 API Endpoints

All gateway endpoints are served under /v1:

Inference & Models

Method Endpoint Description
POST /v1/chat/completions OpenAI chat completion (streaming supported)
POST /v1/messages Anthropic messages endpoint
GET /v1/models List all discovered & connected models
GET /v1/models/:model Retrieve specific model schema & capabilities

Management & Metrics

Method Endpoint Description
GET /health Server health check
GET /v1/quota Real-time provider balance & reset countdowns
GET / POST /v1/providers Read or connect provider accounts
GET / POST /v1/keys Manage virtual API keys
GET /v1/logs Query request audit logs and token telemetry
GET / POST /v1/tunnel/* Manage Cloudflare Tunnel daemon state

🐳 Docker Compose

services:
  srouter:
    image: ghcr.io/seaavey/srouter:latest
    container_name: srouter
    restart: unless-stopped
    ports:
      - "3000:3000"
      - "1455:1455"
    volumes:
      - ${HOME}/.srouter:/root/.srouter
    environment:
      - PORT=3000
      - NODE_ENV=production

🛠️ Development

# Install dependencies
pnpm install

# Start local dev server (API + Dashboard with HMR)
pnpm dev

# Quality checks
pnpm lint
pnpm test
pnpm build

💬 Community & Updates

For the latest news, updates, and community discussions, follow our official WhatsApp Channel:

👉 Follow SRouter WhatsApp Channel


📄 License

Distributed under the MIT License.

Reviews (0)

No results found