A provider-agnostic AI platform
In production since 2025
One gateway. Every product team's model calls run through it, and none of them name a vendor.
- Problem
- Model calls were going to spread across a large monolith, each with its own client, its own error handling, and no way to answer "what is this costing us, and for which tenant?"
- Design
- A single injectable service behind a narrow provider interface. Callers pass a model variation such as "normal" or "pro". No calling code anywhere names a vendor. Requests persist per tenant with input and output token counts, giving cost attribution and full history for free. I built and shipped that persistence layer myself, staged from development through staging to three production regions.
- Result
- Customer summaries, AI-generated preferences across two generations, message generation with brand-guideline enforcement, and the dashboard generator below all ship on the same foundation. Every rollout is gated per tenant. In production it carries enterprise tenants across those regions, and volume has grown substantially over the past year. Growth is nowhere near even between regions, which is why I describe the platform as a whole rather than quoting the flattering region.
- Measured
- The retry path is the one I have actually measured: in a representative week it roughly halved the user-visible failure rate, and no request ever exhausted its four-attempt budget. The per-request token accounting earned its place separately: it showed the busiest surface and the most expensive one were not the same: one feature carried a minority of the requests and most of the token spend, at several times the cost per call of anything else, because it ships a large context and gets a short answer back. Input dominates output by a wide margin across the platform, which puts the optimization on what gets sent rather than on what comes back.
- Where the model stops
- The preference engine on it is the clearest case of a call I keep making: the model extracts and classifies product attributes, but the matching itself is a weighting formula I designed, recency tiers against purchase consistency and clustering, with returns scored negatively. No model decides a preference. When that engine was rebuilt onto the warehouse for its second generation the formula was ported across unchanged, and the deterministic half was the half worth keeping.
PHP Vertex AI Gemini response schemas token accounting feature flags job queue