AI model router across Anthropic, OpenAI, Gemini, NVIDIA & DeepInfra. Auto-routes by complexity, streams SSE, tracks spend server-side.
Prismatix automatically routes each request to the best AI model for the job — balancing response quality, cost, and latency across Anthropic, OpenAI, Google, NVIDIA, and DeepInfra. You get a single chat interface backed by every frontier model.
- Smart routing — A heuristic complexity scorer analyses each query (token count, keywords, code signals, question depth) and routes to the appropriate model tier: Haiku / GPT-mini / Llama 4 Scout for quick lookups, Sonnet for code, Flash for general use, Opus / Gemini Pro / Qwen3-235B for deep analysis
- Multi-provider streaming — Normalised SSE stream from Anthropic, OpenAI, Google Gemini, NVIDIA Nemotron, and DeepInfra. One client, every model
- Debate mode — Optional multi-model deliberation: parallel challenger models critique the prompt, a synthesis model produces the final answer
- SMD pipeline — Structured Multi-Draft: Draft → Skeptic → SynthDecision → Formatter, gated by a fast-path complexity guard (experimental, off by default)
- Video pipeline — Upload, process, and query video assets via Supabase Storage + a background worker edge function
- Cost tracking — Pre-flight cost estimates, live token counting during streaming, per-message final cost logged to Supabase
cost_logs, plus server-side request, daily spend, rate, and concurrent-stream guards - Long-term memory — Conversation windows are periodically summarised and injected as context on future requests
- Auth — Supabase email/password auth with JWT verification on every edge function call
| Layer | Tech |
|---|---|
| Frontend | TypeScript (Vite) — React 18 used only for UI components (~17 .tsx files); the bulk of the codebase is plain .ts (services, engine, hooks, types) |
| Backend | TypeScript on Deno — edge functions on Supabase |
| AI Providers | Anthropic, OpenAI, Google Gemini, NVIDIA NIM, DeepInfra |
| Database | Supabase Postgres (conversations, messages, cost_logs, user_memories, video_assets) |
| Auth | Supabase Auth (JWT, RLS) |
| Deployment | Vercel (frontend) + Supabase (backend) |
src/
components/ React components (ChatInterface, Auth, SpendTracker, ...)
hooks/ Custom hooks (useAuth, useContextManager, useStreamHandler, ...)
services/ API services (storageService, financeTracker, contextManager)
styles/ CSS (ChatInterface.css, mobile.css)
smartFetch.ts Router API client
costEngine.ts Token counting + pricing math
modelCatalog.ts UI model registry
types.ts Shared TypeScript types
supabase/
functions/
router/ Main routing edge function + modules (db_helpers, memory_helpers, video_helpers, ...)
spend_stats/ Spend statistics aggregation
video-intake/ Video upload intake
video-status/ Video processing status
video-worker/ Background video processing
migrations/ Postgres schema migrations
docs/ Architecture docs, integration guides, contributing notes
scripts/ Build scripts
Copy .env.example to .env.local and supply your values:
VITE_SUPABASE_URL=https://YOUR_PROJECT.supabase.co
VITE_SUPABASE_ANON_KEY=your_anon_key
VITE_ROUTER_ENDPOINT=https://YOUR_PROJECT.supabase.co/functions/v1/router
VITE_ENABLE_VIDEO_PIPELINE=falseSupabase edge function secrets (set via supabase secrets set):
ANTHROPIC_API_KEY
OPENAI_API_KEY
GOOGLE_API_KEY
NVIDIA_API_KEY
DEEPINFRA_API_KEY
ALLOWED_ORIGIN=https://your-frontend.vercel.app
ENABLE_DEBATE_MODE=false
ENABLE_SMD_LIGHT=false
ENABLE_VIDEO_PIPELINE=false
ENABLE_DEEPINFRA=true
ENABLE_SERVER_SPEND_LIMIT=true
DAILY_SPEND_LIMIT_USD=2
PER_REQUEST_COST_LIMIT_USD=0.5
USER_RATE_LIMIT_WINDOW_MS=60000
USER_RATE_LIMIT_MAX_REQUESTS=20
MAX_ACTIVE_STREAMS_PER_USER=2
-
Install the Supabase CLI — docs
-
Link your project:
supabase login supabase link --project-ref YOUR_PROJECT_REF
-
Run database migrations:
supabase db push
-
Set edge function secrets (one-time, per provider key you want active):
supabase secrets set ANTHROPIC_API_KEY=sk-... supabase secrets set OPENAI_API_KEY=sk-... supabase secrets set GOOGLE_API_KEY=... supabase secrets set NVIDIA_API_KEY=... supabase secrets set DEEPINFRA_API_KEY=... supabase secrets set ALLOWED_ORIGIN=http://localhost:5173 supabase secrets set ENABLE_DEBATE_MODE=false supabase secrets set ENABLE_SMD_LIGHT=false supabase secrets set ENABLE_VIDEO_PIPELINE=false supabase secrets set ENABLE_DEEPINFRA=true supabase secrets set ENABLE_SERVER_SPEND_LIMIT=true supabase secrets set DAILY_SPEND_LIMIT_USD=2 supabase secrets set PER_REQUEST_COST_LIMIT_USD=0.5 supabase secrets set USER_RATE_LIMIT_WINDOW_MS=60000 supabase secrets set USER_RATE_LIMIT_MAX_REQUESTS=20 supabase secrets set MAX_ACTIVE_STREAMS_PER_USER=2
-
Deploy edge functions:
supabase functions deploy router supabase functions deploy spend_stats
-
Install frontend dependencies and start dev server:
npm install npm run dev
npm run dev # start Vite dev server
npm run type-check # TypeScript typecheck (no emit)
npm run lint # ESLint
npm run test # Vitest unit tests
npm run build # production buildDeploy edge functions after changes:
supabase functions deploy router
supabase functions deploy spend_statsSee CHANGELOG.md for release history.
See CONTRIBUTING.md for setup instructions, architecture overview, and PR guidelines.
MIT — LICENSE