Skip to content

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

ComponentWhat it is
DashboardNext.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 ChatStandalone ChatGPT-style app sharing the same DB, session and limits
Sleepy CLITerminal-native coding agent (built from the open sleepy-code repo)
Search sidecarSmall 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:

  1. resolves the caller (session, JWT, or virtual key),
  2. checks plan, model restrictions and daily free allowances,
  3. takes a billing reservation before the upstream call,
  4. picks a healthy router (multi-router failover), queues if saturated,
  5. forwards upstream, translates the Anthropic envelope when needed, streams the response back,
  6. 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

  1. One-command VPS deploy (recommended) — a script installs Docker, clones the repo, generates secrets, builds, starts, migrates and seeds. See Install.
  2. Docker Compose — clone, edit .env, docker compose up -d --build.
  3. 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