OpenRouter-style AI gateway platform built with Bun, Express, Next.js, Prisma/PostgreSQL, Redis, BullMQ, and TanStack Query.
apps/web: Next.js dashboard, TanStack Query, API key management, credits, model catalog, chat playground.apps/server: auth, API keys, model catalog, payments, webhooks, usage, conversations, rate limiting, workers.apps/gateway: API-key authenticated chat completions, gateway rate limiting, response cache, routing, fallback, billing, usage queueing.
packages/db: Prisma schema/client export and seed script.packages/ai: provider abstraction, router, retry/fallback, streaming helpers.packages/types: shared TypeScript API/domain types.packages/validation: Zod schemas.packages/utils: shared utilities.
POST /auth/sign-upPOST /auth/verifyPOST /auth/sign-inGET /auth/meGET /api-keysPOST /api-keysPATCH /api-keys/:idDELETE /api-keys/:idGET /modelsGET /models/providersGET /models/:slugGET /models/:slug/providersPOST /payments/onrampPOST /payments/checkoutPOST /webhooks/paymentsGET /usage/summaryGET /usage/recentGET /conversationsGET /health
POST /chat/completionsPOST /api/v1/chat/completionsGET /health
See DOCKER.md for one-command setup with Docker Compose.
- Bun (latest)
- PostgreSQL (15+)
- Redis (7+)
Create .env at root:
# Database
DATABASE_URL="postgresql://user:pass@localhost:5432/omniroute"
# Redis
REDIS_HOST="localhost"
REDIS_PORT="6379"
# Auth
JWT_SECRET="your-jwt-secret"
OTP_SECRET="your-otp-secret"
# Server
SERVER_PORT="4001"
SERVER_URL="http://localhost:4001"
# Gateway
GATEWAY_PORT="4000"
GATEWAY_URL="http://localhost:4000"
# App
APP_URL="http://localhost:3000"
# Email (Resend)
RESEND_API_KEY="re_xxx"
# Payments (Stripe)
STRIPE_SECRET_KEY="sk_test_xxx"
STRIPE_WEBHOOK_SECRET="whsec_xxx"
# AI Providers
OPENAI_API_KEY="sk-xxx"
ANTHROPIC_API_KEY="sk-ant-xxx"# Install dependencies
bun install
# Generate Prisma client
bun prisma generate
# Push database schema
bun prisma db push
# Seed database
bun prisma db seed# Run all apps and packages
bun run dev
# Run individual apps
cd apps/web && bun run dev
cd apps/server && bun run dev
cd apps/gateway && bun run devbun run build