What this layer controls
- Which model serves which task, and what happens when it fails
- What every request cost, per feature and per customer
- What the model saw, so a bad answer can be reconstructed
- Whether a model or prompt change is a regression
What it looks like when it is wrong
These are the symptoms that show up in a marketing report or a Monday meeting. Each one has a technical cause in this layer, and each is cheaper to fix before it has a quarter of history behind it.
- One shared provider key, so no feature can be budgeted or disabled alone
- Prompts changed in production with no evaluation
- Customer data in traces with no retention rule
- A provider outage takes the feature down with no fallback
- Nobody can state cost per feature
An open-source stack for this layer
Every project below is open source and self-hostable, with the licence the project publishes today. This is a reference build, not a recommendation to run all of it: pick the layers your stack is missing.
| Layer | Project | Licence | What it does |
|---|---|---|---|
| Gateway | LiteLLM | MIT | One API across providers, virtual keys with budgets, retries and fallbacks. |
| Tracing | Langfuse | MIT (core) | Traces, prompt versions, scores and datasets, self-hosted. |
| Local inference | vLLM or Ollama | Apache-2.0 / MIT | Serve open models for anything that must not leave your network. |
| Evaluation | promptfoo | MIT | Regression tests over a golden prompt set, run on every model or prompt change. |
| Retrieval | Qdrant or pgvector | Apache-2.0 / PostgreSQL | Vector retrieval over your own corpus, with the document metadata that makes citations checkable. |
Evaluation checklist
Answer each of these about your current stack. A ‘no’ is a work item, and the count is a fair summary of the layer’s health.
- Does every request carry a trace with model, tokens, latency and cost?
- Is there a per-feature budget enforced by the gateway?
- Does a golden set gate every model or prompt change?
- Is there a written retention and PII policy for traces?
- Does a provider failure route to a tested fallback?
- Can you answer ‘what did this feature cost per customer last month’ from logs?
What to instrument
Numbers that make the layer’s health visible before a customer complains.
- Cost per feature per day
- Golden-set pass rate per model version
- p95 latency and error rate per model
- Trace coverage (requests with a trace / total requests)
Where this fits
Scope. This page describes the category and an open-source way to build it. It does not publish 5 Kings’ internal method, client data or vendor terms, and it is not an endorsement of every project listed: check the licence and the maintenance activity against your own constraints before you adopt one.