Self-hosting overview
Sleepy AI is open infrastructure: the hosted service at sleepyai.org runs this exact stack, and you can run it yourself. Self-hosting gives you the same gateway, billing, chat app, and CLI — on your…
Sleepy AI is open infrastructure: the hosted service at sleepyai.org runs this exact stack, and you can run it yourself. Self-hosting gives you the same gateway, billing, chat app, and CLI — on your own domain, with your own upstream provider keys.
This section covers what you get, the architecture, requirements, and how to deploy and operate it.
What you get
| Component | What it is |
|---|---|
| Dashboard | Next.js 16 web app: public site, user dashboard, admin panel, and the entire API layer |
| API gateway | /api/v1/* — OpenAI- and Anthropic-compatible proxy with metering, plan limits, queueing and multi-router failover |
| SleepyAI Chat | Standalone ChatGPT-style app sharing the same DB, session and limits |
| Sleepy CLI | Terminal-native coding agent (built from the open sleepy-code repo) |
| Search sidecar | Small FastAPI service used only by the chat app for web research |
Architecture in one paragraph
The dashboard is the brain. It owns auth (NextAuth, JWT sessions, virtual API
keys), the billing ledger, plan/limit enforcement, the admin panel, and the
whole /api/v1/* proxy. Every AI request — from the dashboard, the chat app,
the CLI, or a third-party client — funnels through that proxy, which:
- resolves the caller (session, JWT, or virtual key),
- checks plan, model restrictions and daily free allowances,
- takes a billing reservation before the upstream call,
- picks a healthy router (multi-router failover), queues if saturated,
- forwards upstream, translates the Anthropic envelope when needed, streams the response back,
- settles the reservation and writes a
UsageEvent.
Routers (OmniRoute, VansRouter) are the upstream-facing gateways that hold provider keys; the dashboard picks a healthy one per request. The chat app never talks to a router directly — it always calls the dashboard internally.
Requirements
- A VPS with root/sudo and a domain pointing to its IP (HTTPS via Caddy is set up automatically)
- Docker + Compose (the one-command deploy installs Docker if missing)
- At least one upstream LLM provider key (OpenAI / Anthropic / DeepSeek / Gemini / GroQ) so non-free routes have something to call
- PostgreSQL 16 (the compose stack runs it; PgBouncer sits in front for connection pooling)
- Optional integrations: PipraPay (payments, BDT), Brevo or SMTP (transactional email), Telegram (bot + group gate), Google OAuth
Deployment options
- One-command VPS deploy (recommended) — a script installs Docker, clones the repo, generates secrets, builds, starts, migrates and seeds. See Install.
- Docker Compose — clone, edit
.env,docker compose up -d --build. - Local development — run the dashboard, chat, CLI and search sidecar individually (Node 20+, local Postgres, Bun for the CLI).
See Install for the exact steps.
Repository layout (what's where)
sleepy-ai/
├── dashboard/ Next.js 16 — UI, admin panel, and ALL backend APIs
│ ├── app/api/v1/ the OpenAI/Anthropic-compatible gateway
│ ├── lib/ auth, key/device auth, compat layers, services/
│ └── prisma/ schema + migrations + seeds
├── chat/ SleepyAI Chat — standalone Next.js 16 app
├── search/ FastAPI sidecar (web research for chat)
├── api/ standalone backup API gateway (Go)
├── gateway/ upstream gateway config
├── client/ sleepy-client TypeScript SDK
├── scripts/ deploy.sh, backup.sh, check-service-sync.sh
├── docker-compose.yml the full multi-service deployment
└── .env.example every supported environment variable, documented
Operations you'll care about
- Configuration — env vars + DB-backed settings: Configuration
- Admin panel — users, plans, models, routers, transactions, invoices, coupons, shop, announcements, broadcast, email logs, CMS pages, SEO, audit log, request log, queue, health, maintenance mode, analytics, monitor
- Backups — daily at 03:00 UTC to
/opt/sleepy-ai/backups/(7-day retention); manual trigger from Admin → Settings - Updating —
git pull && docker compose up -d --build(migrations run automatically on boot)
Details in Admin & maintenance.
Why self-host
- Own the stack end to end — no vendor lock, no per-seat SaaS fees
- Bring your own upstream provider keys
- Same product surface as the hosted service: billing, plans, chat, CLI, multi-router failover
- MIT licensed
Next: Install