Skip to content

Repository files navigation

OmniRoute

OpenRouter-style AI gateway platform built with Bun, Express, Next.js, Prisma/PostgreSQL, Redis, BullMQ, and TanStack Query.

Apps

  • 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

  • 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.

API

Server, port 4001

  • POST /auth/sign-up
  • POST /auth/verify
  • POST /auth/sign-in
  • GET /auth/me
  • GET /api-keys
  • POST /api-keys
  • PATCH /api-keys/:id
  • DELETE /api-keys/:id
  • GET /models
  • GET /models/providers
  • GET /models/:slug
  • GET /models/:slug/providers
  • POST /payments/onramp
  • POST /payments/checkout
  • POST /webhooks/payments
  • GET /usage/summary
  • GET /usage/recent
  • GET /conversations
  • GET /health

Gateway, port 4000

  • POST /chat/completions
  • POST /api/v1/chat/completions
  • GET /health

Setup

Docker (Recommended)

See DOCKER.md for one-command setup with Docker Compose.

Local Development

Prerequisites

  • Bun (latest)
  • PostgreSQL (15+)
  • Redis (7+)

Environment

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 & Setup

# Install dependencies
bun install

# Generate Prisma client
bun prisma generate

# Push database schema
bun prisma db push

# Seed database
bun prisma db seed

Development

# 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 dev

Build

bun run build

About

No description, website, or topics provided.

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages