Quick reference
*Bottom to top: each layer changes the answer*
- Model — The foundation model: a hosted API, open weights or a fine-tune. · *model*
- Gateway — One endpoint in front: keys, quotas, retries, routing and logs. · *gateway*
- Retrieval — Chunks, embeddings and a vector index, so answers use your data. · *retrieval*
- Orchestration — The loop that plans, calls tools and assembles the final prompt. · *agent loop*
- Guardrails — Input and output checks: PII, injection, schema and policy. · *guardrails*
- Evals — Scored test sets that gate a prompt or model change before release. · *evals*
Explained
The lower layers
Model. A hosted API, an open-weight model or a fine-tune. The choice sets cost, latency, context window and what data leaves your network.
Gateway. One endpoint in front of every model: keys, quotas, retries, routing and logs. Without it, every team hard-codes a different provider key.
Retrieval. Chunks, embeddings and a vector index, so the model answers from your documents instead of its training data. The quality of the chunks matters more than the model choice.
The upper layers
Orchestration. The loop that plans, calls tools and assembles the prompt. It is where an agent lives, and where most latency and most failure modes live too.
Guardrails. Input and output checks: PII, prompt injection, schema validation, policy. They sit around the model, not inside it.
Evals. Scored test sets that gate a prompt or model change before release. Without them, every change is a vibe check. Start with thirty real questions and a pass mark.
The honest caveat: evals are the weakest layer in most teams. An LLM judge is useful, but it correlates with quality rather than proving it, so keep a small human-reviewed set.
The lesson: debug the layer, not the model.
In one line
The model is one layer. Every layer above it can change the answer.
Start with evals: pick 30 real questions and score them
More notes: AI infrastructure & LLM security
Open in the notes app: search, filters, copy This note on GitHub