Self-Hosting

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

1

Clone the repository

bash
git clone https://github.com/1router/1router.git
cd 1router
2

Configure storage, auth, and providers

bash
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)
3

Start everything locally

bash
# 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.
4

Run services individually when needed

bash
bun run dev:site
# In another terminal:
bun run dev:api
# The database can remain running from bun run dev.
5

Or deploy to Kubernetes

bash
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

1

Client

OpenAI-compatible API requests or browser session

2

Next.js Control Plane

Better Auth, organizations, API keys, signed identity assertions, optional Stripe

3

Rust Gateway

Master-key auth, identity verification, provider routing, and streaming

4

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