Catalog npm
PACKAGE EXPLORERView in registry

@0xki/kirouter

npm

Multi-provider LLM gateway with unified API, dashboard, and key rotation

aianthropicapiclaudegatewaygrokllmopenaiproxy
Versions collected9
Direct dependencies2From release 1.0.8
Last observed21 Oct, 09:01 UTC

README

Current package documentation

KiRouter

Multi-provider LLM gateway with unified OpenAI-compatible API, key rotation, real-time dashboard, and budget tracking.

npm version license node

Quick Start

npm install -g @0xki/kirouter
kirouter

Dashboard: http://localhost:8090

Features

  • Unified API — OpenAI-compatible /v1/chat/completions for all providers
  • Key rotation — automatic failover across multiple API keys
  • 22 providers — OpenAI, Anthropic, Grok, Gemini, DeepSeek, and more
  • Real-time dashboard — stats, sparklines, trends, and health monitoring
  • Budget tracking — per-provider spend limits and usage analytics
  • SQLite persistence — request history, audit logs, and backups
  • Auto-update — checks npm registry on startup, one-command upgrade

CLI Options

kirouter                    # Start on port 8090
kirouter --port 3000        # Start on custom port
kirouter --update           # Check for updates and install
kirouter --version          # Show version
kirouter --help             # Show help

Update

npm i -g @0xki/kirouter@latest --prefer-online

API Example

curl http://localhost:8090/v1/chat/completions \
  -H "Authorization: Bearer $(cat ~/.kirouter/.gateway_key)" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Model format: {provider}/{model_id} — e.g., openai/gpt-4o, anthropic/claude-opus-4-6, grok/grok-chat-fast

Configuration

Data is stored in ~/.kirouter/ (auto-created):

~/.kirouter/
├── .gateway_key            # Auto-generated API/admin key (chmod 600)
├── providers.json          # Provider configs and API keys
├── provider-key-stats.json # Provider-key usage and budget state
└── ki-gateway.db           # SQLite request and audit logs

Environment Variables

VariableDefaultDescription
KIGW_PORT8090Gateway port (--port sets this)
KIGW_DATA_DIR~/.kirouterMutable state directory
PORT—Legacy port alias; KIGW_PORT wins
KIGW_HOST127.0.0.1Listen address
KI_DATA_DIR—Legacy data-directory alias
KI_GATEWAY_VERSIONpackage versionVersion string
KIGW_SESSION_TTL_MS86400000Admin-session lifetime in milliseconds
KIGW_MAX_ADMIN_SESSIONS100Maximum concurrent in-memory admin sessions (oldest idle session is evicted)
KIGW_TRUST_PROXY0Trust sanitized X-Forwarded-Host/X-Forwarded-Proto from a controlled reverse proxy
KIGW_FORCE_SECURE_COOKIES0Force Secure admin cookies behind a trusted HTTPS proxy
KIGW_ALLOW_SESSION_NO_ORIGIN0Allow session mint/write without Origin only for controlled local tools/tests
KIGW_CHAT_BODY_LIMIT2097152Maximum /v1/chat/completions JSON body (2 MiB)
KIGW_ADMIN_BODY_LIMIT1048576Maximum normal admin JSON body (1 MiB)
KIGW_RESTORE_BODY_LIMIT8388608Maximum restore JSON body (8 MiB)
KIGW_ALLOW_PRIVATE_NETWORKS0Explicitly allow custom private/loopback upstreams and proxies; keep disabled unless trusted

Admin Security

The browser exchanges the gateway master key for an opaque, server-side admin session. The master key is not persisted in localStorage, cookies, or SSE URLs. Mutating dashboard requests require both a CSRF token and a matching same-origin Origin/Referer; logout revokes the server session.

Configuration backups use schema version 2 and redact provider keys, credential-bearing proxy URLs, and error details. Plaintext secret export is unsupported. Restore validates the full document and reuses redacted keys that already exist on the same instance; it does not migrate secrets to a fresh host. Provider configuration and key statistics are staged together; an on-disk restore journal completes an interrupted two-file replacement on the next startup.

KiRouter defaults to port 8090. Port 20128 is reserved for 9router in Ki’s stack and is not used as the KiRouter default.

Custom provider and proxy URLs are restricted to public HTTP(S) destinations by default to reduce SSRF risk. Private, loopback, link-local, metadata, multicast, and reserved destinations require the explicit KIGW_ALLOW_PRIVATE_NETWORKS=1 opt-in. DNS is checked and pinned for direct requests, redirects are revalidated, and proxied redirects are rejected. The default local grok2api upstream therefore also requires this opt-in.

When an upstream is reached through a remote HTTP(S) proxy, KiRouter validates both the configured upstream and proxy endpoint before dispatch, but the remote proxy ultimately resolves the CONNECT destination itself. End-to-end DNS pinning therefore applies only to direct requests. Use only trusted remote proxies with their own private-network/metadata egress controls.

Development

git clone https://github.com/0xKii/kirouter.git
cd kirouter
npm install
npm install -g .
kirouter

License

MIT © 2026 0xki

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 9

Collected releases
VersionPublishedDirect dependenciesOpen version
1.0.8Registry latest22 Jul 20262
1.0.722 Jul 20262
1.0.621 Jul 20262
1.0.520 Jul 20262
1.0.420 Jul 20262
1.0.320 Jul 20262
1.0.220 Jul 20262
1.0.119 Jul 20262
1.0.019 Jul 20262

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
0xki/kirouter

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:01 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:21f86262bd7474f78c74e60b426a4c2e6ecf232169fde263b58b00f08da77d3e