{"_id":"@0xki/kirouter","_rev":"9-adc7ea582391e20d0d96b0457e27b97b","name":"@0xki/kirouter","dist-tags":{"latest":"1.0.8"},"versions":{"1.0.0":{"name":"@0xki/kirouter","version":"1.0.0","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.0","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"6067459809ea34b4f09cfa64b88666ec13ca5d44","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.0.tgz","fileCount":7,"integrity":"sha512-nnuHS3uFKU5Q47aZeRSE5GTUgr1JjOaYS1DQKneEnKHW6J0sztn1kSnz35IdcdPpPVxD1q/Ko+Wq7htYNRgV9Q==","signatures":[{"sig":"MEUCIC6cv+qjVTyYY36t6WKC98ewqyulS0lCj/yRiR5zMdyGAiEAwdLwhe+bpjzII7QkgXyezlhUnKwAmu3g6nZNaHx+J8s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":371702},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=18.0.0"},"gitHead":"e0bdf1db58922bb388f566c9f6a8b3041ce23946","scripts":{"test":"node --check lib/gateway.mjs","start":"node bin/kirouter.js"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.0_1784470288929_0.05132653979893598","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@0xki/kirouter","version":"1.0.1","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.1","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"f2fb38655e19080ba62869ff4e984a3f160ae5ea","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.1.tgz","fileCount":7,"integrity":"sha512-43Ohx7zN4hvXd4AczhzC9I0rFsciM6Ep7z9bTBVWdxdH8tmBmyJJs+Pks+6wudtBypSGQ+LUtGFHYoOM2Cjnow==","signatures":[{"sig":"MEUCIAmTVWGmrLOBa5ePasQvwVYy2JQg4MwYysw9pKgQy9i/AiEAyD342J7V8fXXR76RiSxS9KrOSxlHKa8Cr+rgMQHv9Rk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":372198},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=18.0.0"},"gitHead":"f365abaf4ac978932256369b06e9e8bb3c9b1e80","scripts":{"test":"node --check lib/gateway.mjs","start":"node bin/kirouter.js"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.1_1784470885674_0.7125917043013601","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@0xki/kirouter","version":"1.0.2","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.2","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"45f9d15e184cc6c81a2c2a12786b77c23a4bca44","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.2.tgz","fileCount":7,"integrity":"sha512-YGVMNpTpFYpcoIgAwZtrykyLJdvkiugfEZy/EHKnBYvNDkZQHDJMp+44ap9BexHAkfG08UCNLRo2IunE/I6jsA==","signatures":[{"sig":"MEUCIQDmhucRPNfGiqMLCkbuFoZS9yE/wmlVFGDWPZN8mZg7DAIgGONBFg7Gw2qpfPaP0srtTXPRXjCpn3qIs3hOlkG8OOU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":492613},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=18.0.0"},"gitHead":"583fe23d660d1fecd6ce9b4c2d7c6a3d31677268","scripts":{"test":"node --check lib/gateway.mjs","start":"node bin/kirouter.js"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.2_1784508195667_0.7855068156978204","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@0xki/kirouter","version":"1.0.3","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.3","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"615d9e1b4b6830845424f81bc5696b4574410a54","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.3.tgz","fileCount":7,"integrity":"sha512-YgK0tqVdoW7cupXBkaxJBNlVPr1O1W8tO12papimdgfeefy70IcalJQ06tIUFTd2iP1gEYXCb3NVlID8g4bnhg==","signatures":[{"sig":"MEUCIQD4xMcxjQKiTv1uPt9UyswvRRO5GDr9JullqCx6ZhJk0wIgJQBv5CKmWpQYteOyfxtTZAlrBore25VBg5aDZOwwnrI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":495616},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=18.0.0"},"gitHead":"26e6ae8eaf7823db3c1cdedd9c2bea8619cef646","scripts":{"test":"node --check lib/gateway.mjs","start":"node bin/kirouter.js"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.3_1784513481913_0.8149826319952247","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@0xki/kirouter","version":"1.0.4","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.4","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"2ef7dd18d279d0cb777d1fbe2e7d3a630bde871a","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.4.tgz","fileCount":7,"integrity":"sha512-PK9+US5PzCFI7fizHC+KmL6vrb8XJHFs/vS0vQ9RU7SQSBixtvP+SdAYGXdL7sG8x4txmUtCD3FrsE5k6lPb+w==","signatures":[{"sig":"MEUCIQCppTgvcXRq8LnroeYpkWxrmB91q61HJd0dlTVnsXbExgIgeRVPBbSQ0eDM0ObSdnKtSK7QhDZQNlXQdoXiX1WjtLk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":427055},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=20.0.0"},"gitHead":"c87c295b95b538627649cae0c2ef42b965fe2ad8","scripts":{"test":"node scripts/run-tests.mjs","check":"node scripts/check.mjs","start":"node bin/kirouter.js","verify":"npm run check && npm test && npm run security","security":"npm audit --omit=dev"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.4_1784526695432_0.09858630010039304","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@0xki/kirouter","version":"1.0.5","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.5","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"4113597c5a3a295a4f81e43452e5818a50a770dc","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.5.tgz","fileCount":7,"integrity":"sha512-A4/AR3EXFCCv8E5i+uaiTr0xaYFz5VEPchYWsuxdMQ866te4boYcAvuVnzBK6/QSkfVCpKwf1dOOjnTx54e5YA==","signatures":[{"sig":"MEUCIQDzO6bvV9Ec/kX4M2DTKeY3HOp+Mbo7walFXJ7B+Q+ePAIgUquwmJmaykJq4ZF98zfqVnuq/ZBazT/UN6xcc7smvvc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":431513},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=20.0.0"},"gitHead":"ea52aacfa4a02e5012ed3bb52c2372c0d8e68410","scripts":{"test":"node scripts/run-tests.mjs","check":"node scripts/check.mjs","start":"node bin/kirouter.js","verify":"npm run check && npm test && npm run security","security":"npm audit --omit=dev"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.5_1784529169722_0.1649065708019084","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@0xki/kirouter","version":"1.0.6","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.6","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"cba1e0957aec96a7ea1fb24d2c47b236c5e73687","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.6.tgz","fileCount":7,"integrity":"sha512-vwG0ODXMF6hwYPAnMuBnK0gH6+tyTVmUZ9BSHhH4jkYpKF0FK/ho9psONv2qLwY7qRTyfybLlTslZ/yGrv1twQ==","signatures":[{"sig":"MEUCIFny+vurWaOjkqIfFkBCqu9z9slDrrzLSn4Q17yzOfrhAiEA2HkctWI+SEgLP1OkqOdyNUo3BMvsSZjywnW6d8STIbg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":465866},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=20.0.0"},"gitHead":"b52c2cd6abda3fa099a3f872e150985a9121843f","scripts":{"test":"node scripts/run-tests.mjs","check":"node scripts/check.mjs","start":"node bin/kirouter.js","verify":"npm run check && npm test && npm run security","security":"npm audit --omit=dev"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.6_1784640720755_0.041481407416192884","host":"s3://npm-registry-packages-npm-production"}},"1.0.7":{"name":"@0xki/kirouter","version":"1.0.7","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","_id":"@0xki/kirouter@1.0.7","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"homepage":"https://github.com/0xki/kirouter#readme","bugs":{"url":"https://github.com/0xki/kirouter/issues"},"bin":{"kirouter":"bin/kirouter.js"},"dist":{"shasum":"3e2d65d5c326606677544c7f4184e02b7acecae0","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.7.tgz","fileCount":114,"integrity":"sha512-b4L9CzkE3tpY3pegkbxrCACDI75Toos78vE/aDiFwYoOq8omTWBlzKIcM7KSI8bmihhod13/Z1xQtIe9aVSjsw==","signatures":[{"sig":"MEYCIQCWdnTycKNhZ5k7Ja1pUz2Hl3WXc4GgT/Mv5KBkVlNTWgIhAOKu6up6qT5KT8fVPXpI6am7k6I2u6plwh00RJhmLGzV","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1370383},"main":"lib/gateway.mjs","type":"module","engines":{"node":">=20.0.0"},"gitHead":"be18ee848ef40a2ca094172bc430b6c3caf51752","scripts":{"test":"node scripts/run-tests.mjs","check":"node scripts/check.mjs","start":"node bin/kirouter.js","verify":"npm run check && npm test && npm run security","security":"npm audit --omit=dev"},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"repository":{"url":"git+https://github.com/0xki/kirouter.git","type":"git"},"_npmVersion":"11.12.1","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","directories":{},"_nodeVersion":"24.15.0","dependencies":{"undici":"^6.0.0","better-sqlite3":"^11.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/kirouter_1.0.7_1784721131750_0.9933395069413709","host":"s3://npm-registry-packages-npm-production"}},"1.0.8":{"name":"@0xki/kirouter","version":"1.0.8","description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","type":"module","main":"lib/gateway.mjs","bin":{"kirouter":"bin/kirouter.js"},"scripts":{"start":"node bin/kirouter.js","check":"node scripts/check.mjs","test":"node scripts/run-tests.mjs","security":"npm audit --omit=dev","verify":"npm run check && npm test && npm run security"},"keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"author":{"name":"0xki"},"license":"MIT","engines":{"node":">=20.0.0"},"dependencies":{"better-sqlite3":"^11.0.0","undici":"^6.0.0"},"repository":{"type":"git","url":"git+https://github.com/0xki/kirouter.git"},"bugs":{"url":"https://github.com/0xki/kirouter/issues"},"homepage":"https://github.com/0xki/kirouter#readme","publishConfig":{"access":"public"},"gitHead":"484bcf546f266ab7031f7b2274f1a8ac6119f6c5","_id":"@0xki/kirouter@1.0.8","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-9X4IkxXKkFMndNPxDPuBtQyz4KMHVSL829TwwpG9kxXgPLc6ZgJnB2PE42zUiBY9n4MV671SRYxwSingfYvdbA==","shasum":"391dd8735426359ba418fdd830e8e01c5b0a2a4c","tarball":"https://registry.npmjs.org/@0xki/kirouter/-/kirouter-1.0.8.tgz","fileCount":114,"unpackedSize":1370885,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC0aWeGhYfz8Tc3x0MK2uKoENWkKf5y8E2RBVm394TPlQIgHHzDHZHxPIlYoXFhWVLq9pE447ogkw54eSvaQ5d/0V0="}]},"_npmUser":{"name":"0xki","email":"cryptohuntid@gmail.com"},"directories":{},"maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/kirouter_1.0.8_1784722398175_0.7781147221243772"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-19T14:11:28.741Z","modified":"2026-07-22T12:13:18.544Z","1.0.0":"2026-07-19T14:11:29.083Z","1.0.1":"2026-07-19T14:21:25.884Z","1.0.2":"2026-07-20T00:43:15.814Z","1.0.3":"2026-07-20T02:11:22.065Z","1.0.4":"2026-07-20T05:51:35.563Z","1.0.5":"2026-07-20T06:32:49.862Z","1.0.6":"2026-07-21T13:32:00.937Z","1.0.7":"2026-07-22T11:52:11.903Z","1.0.8":"2026-07-22T12:13:18.381Z"},"bugs":{"url":"https://github.com/0xki/kirouter/issues"},"author":{"name":"0xki"},"license":"MIT","homepage":"https://github.com/0xki/kirouter#readme","keywords":["llm","gateway","api","proxy","openai","anthropic","grok","claude","ai"],"repository":{"type":"git","url":"git+https://github.com/0xki/kirouter.git"},"description":"Multi-provider LLM gateway with unified API, dashboard, and key rotation","maintainers":[{"name":"0xki","email":"cryptohuntid@gmail.com"}],"readme":"# KiRouter\n\nMulti-provider LLM gateway with unified OpenAI-compatible API, key rotation, real-time dashboard, and budget tracking.\n\n[![npm version](https://img.shields.io/npm/v/@0xki/kirouter)](https://www.npmjs.com/package/@0xki/kirouter)\n[![license](https://img.shields.io/npm/l/@0xki/kirouter)](LICENSE)\n[![node](https://img.shields.io/node/v/@0xki/kirouter)](https://nodejs.org)\n\n## Quick Start\n\n```bash\nnpm install -g @0xki/kirouter\nkirouter\n```\n\nDashboard: **http://localhost:8090**\n\n## Features\n\n- **Unified API** — OpenAI-compatible `/v1/chat/completions` for all providers\n- **Key rotation** — automatic failover across multiple API keys\n- **22 providers** — OpenAI, Anthropic, Grok, Gemini, DeepSeek, and more\n- **Real-time dashboard** — stats, sparklines, trends, and health monitoring\n- **Budget tracking** — per-provider spend limits and usage analytics\n- **SQLite persistence** — request history, audit logs, and backups\n- **Auto-update** — checks npm registry on startup, one-command upgrade\n\n## CLI Options\n\n```bash\nkirouter                    # Start on port 8090\nkirouter --port 3000        # Start on custom port\nkirouter --update           # Check for updates and install\nkirouter --version          # Show version\nkirouter --help             # Show help\n```\n\n## Update\n\n```bash\nnpm i -g @0xki/kirouter@latest --prefer-online\n```\n\n## API Example\n\n```bash\ncurl http://localhost:8090/v1/chat/completions \\\n  -H \"Authorization: Bearer $(cat ~/.kirouter/.gateway_key)\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"model\": \"openai/gpt-4o\",\n    \"messages\": [{\"role\": \"user\", \"content\": \"Hello!\"}]\n  }'\n```\n\nModel format: `{provider}/{model_id}` — e.g., `openai/gpt-4o`, `anthropic/claude-opus-4-6`, `grok/grok-chat-fast`\n\n## Configuration\n\nData is stored in `~/.kirouter/` (auto-created):\n\n```\n~/.kirouter/\n├── .gateway_key            # Auto-generated API/admin key (chmod 600)\n├── providers.json          # Provider configs and API keys\n├── provider-key-stats.json # Provider-key usage and budget state\n└── ki-gateway.db           # SQLite request and audit logs\n```\n\n## Environment Variables\n\n| Variable | Default | Description |\n|---|---|---|\n| `KIGW_PORT` | `8090` | Gateway port (`--port` sets this) |\n| `KIGW_DATA_DIR` | `~/.kirouter` | Mutable state directory |\n| `PORT` | — | Legacy port alias; `KIGW_PORT` wins |\n| `KIGW_HOST` | `127.0.0.1` | Listen address |\n| `KI_DATA_DIR` | — | Legacy data-directory alias |\n| `KI_GATEWAY_VERSION` | package version | Version string |\n| `KIGW_SESSION_TTL_MS` | `86400000` | Admin-session lifetime in milliseconds |\n| `KIGW_MAX_ADMIN_SESSIONS` | `100` | Maximum concurrent in-memory admin sessions (oldest idle session is evicted) |\n| `KIGW_TRUST_PROXY` | `0` | Trust sanitized `X-Forwarded-Host`/`X-Forwarded-Proto` from a controlled reverse proxy |\n| `KIGW_FORCE_SECURE_COOKIES` | `0` | Force Secure admin cookies behind a trusted HTTPS proxy |\n| `KIGW_ALLOW_SESSION_NO_ORIGIN` | `0` | Allow session mint/write without Origin only for controlled local tools/tests |\n| `KIGW_CHAT_BODY_LIMIT` | `2097152` | Maximum `/v1/chat/completions` JSON body (2 MiB) |\n| `KIGW_ADMIN_BODY_LIMIT` | `1048576` | Maximum normal admin JSON body (1 MiB) |\n| `KIGW_RESTORE_BODY_LIMIT` | `8388608` | Maximum restore JSON body (8 MiB) |\n| `KIGW_ALLOW_PRIVATE_NETWORKS` | `0` | Explicitly allow custom private/loopback upstreams and proxies; keep disabled unless trusted |\n\n## Admin Security\n\nThe 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.\n\nConfiguration 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.\n\nKiRouter defaults to port **8090**. Port **20128 is reserved for 9router** in Ki’s stack and is not used as the KiRouter default.\n\nCustom 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.\n\nWhen 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.\n\n## Development\n\n```bash\ngit clone https://github.com/0xKii/kirouter.git\ncd kirouter\nnpm install\nnpm install -g .\nkirouter\n```\n\n## License\n\nMIT © 2026 0xki\n","readmeFilename":"README.md"}