SmartRouter: How We Select the Optimal AI Model Per Task
Deep dive into SmartRouter — our 41,000-line AI model selection engine. How it picks the best model across 8 providers for 21 task types, balancing cost, quality, and latency in real-time.
How we built AI business infrastructure from the ground up. Original architecture decisions, implementation patterns, and lessons from 4 million lines of code.
Deep dive into SmartRouter — our 41,000-line AI model selection engine. How it picks the best model across 8 providers for 21 task types, balancing cost, quality, and latency in real-time.
How we built a 9-layer safety system that prevents runaway AI costs across hundreds of businesses. Redis-based tracking, spike detection, per-company budgets, and the architecture behind 50,000+ lines of cost control.
How we built cross-conversation AI memory using Haiku for fact extraction, Redis for sub-millisecond reads, and PostgreSQL for durability. Zero inference cost on retrieval. Topic-match boosting. Confidence scoring with decay.
5-layer security stack: input sanitization, 41 pattern detectors across 6 threat types, heuristic analysis, ML-based classification, and output validation with canary tokens. 16ms overhead, 99%+ detection rate.
7-layer isolation stack: JWT auth, query filtering, RLS on 298 tables, agent isolation, Fernet-encrypted credentials, per-company KB cloning from 52 industry templates, and Redis-tracked budget isolation.
Two-tier MCP architecture: 600 internal tools for 14 agents + 19 public endpoints with per-tenant auto-generated manifests. 14 server categories, 33 security scopes, domain-aware discovery.
The architecture behind ADA, our AI coordinator that orchestrates 13 other agents. How agents hand off work, escalate decisions, and quality-check each other in real-time.
Solid# has 4 million lines of code, 1,156 internal technical documents, and architecture decisions refined over two years of building AI infrastructure that runs real businesses.
We publish these deep dives because the problems we solve — AI model selection at scale, real-time cost control, multi-tenant agent isolation, prompt injection prevention — are problems every team building with AI will eventually face. Our approach isn't the only way, but it's battle-tested in production across 52 industries.
The technical complexity is our moat. Sharing how we think about these problems makes the industry better and demonstrates that Solid# isn't a wrapper or a bolt-on — it's real infrastructure.