Run 1Router on your own infrastructure
Operate the site, Better Auth, PostgreSQL, Rust gateway, provider credentials, and monitoring yourself. Stripe is optional and managed-service-only.
Quick Start
Clone the repository
git clone https://github.com/1router/1router.git
cd 1routerConfigure storage, auth, and providers
cp apps/site/.env.example apps/site/.env.local
# Set site values in apps/site/.env.local.
# ROUTER_API_URL defaults to https://api.1router.com.
# bun run dev overrides it to the local Rust API at http://localhost:3001.
# In the gateway shell, export ROUTER_API_KEY, provider keys, and:
export ROUTER_IDENTITY_SECRET=$(openssl rand -hex 32)Start everything locally
# Set provider keys in your shell first, for example: export OPENAI_API_KEY=sk-...
bun run dev
# Starts Dockerized Postgres, bootstraps Better Auth, and runs site + local API.Run services individually when needed
bun run dev:site
# In another terminal:
bun run dev:api
# The database can remain running from bun run dev.Or deploy to Kubernetes
kubectl apply -f apps/api/k8s/
kubectl apply -f apps/site/k8s/
# Create site-secrets and api-secrets out-of-band.Why Self-Host?
Full Control Plane
Run routing, Better Auth accounts, organizations, API keys, rate limiting, and provider credentials on your own hardware.
Data Sovereignty
No telemetry, no analytics, and no Stripe dependency. Your PostgreSQL database, API keys, prompts, and logs stay in your infrastructure.
Private Network
Deploy behind your VPN or firewall. Restrict access with Better Auth, your own SSO, or IP allowlists.
Custom Models
Add fine-tuned models, local LLMs via Ollama, or private endpoints alongside hosted providers.
Your Own Storage
Use your own PostgreSQL for Better Auth, usage history, and optional daily quotas. Stripe is optional and can remain disabled.
Open License
Released under FSL-1.1-Apache-2.0. Use, modify, and self-host for permitted internal, research, and educational purposes.
Architecture
Client
OpenAI-compatible API requests or browser session
Next.js Control Plane
Better Auth, organizations, API keys, signed identity assertions, optional Stripe
Rust Gateway
Master-key auth, identity verification, provider routing, and streaming
Your Infrastructure
Database, credentials, monitoring, and ingress
Want zero operations?
Use the managed service for hosted PostgreSQL, Better Auth, Stripe billing, provider routing, monitoring, and updates. The self-hosted path remains available with no Stripe dependency.
Compare deployment modes