Making generative AI into a "working demo" is easy now. But making it into a "trustworthy production system" — one exposed to customer input, running the business, and surviving regulation, invoices, and incidents — is an entirely different job. And its success is decided, again and again, not by the model's cleverness but by the engineering around it.
A production LLM app stands on six pillars.
- Security — defend against attacks (prompt injection, etc.).
- MCP / tool connection — connect AI safely to external tools and data.
- Evaluation & testing — protect quality and against regressions.
- Privacy & compliance — protect customer data and PII.
- Reliability & resilience — don't go down on outages, rate limits, or cost blow-ups.
- Caching & performance — run fast and cheap.
This article is a map (hub) to each pillar's deep-dive, plus the single design principle that unifies them, the adoption order, and integrated code composing the six into one request flow. First, the unifying principle:
Treat the LLM as a "probabilistic, untrusted component," and surround it with "deterministic architecture."
All six pillars are concretizations of this principle.
Why "production AI" is hard
Traditional web development works by validating at the boundary between "untrusted input (the user)" and "trusted code (us)." In LLM apps, that premise breaks.
- Non-deterministic — the output varies for the same input. "It worked once" is no guarantee.
- Free-form output the user can effectively steer — flowing LLM output downstream unvalidated is the same as passing user input to SQL unvalidated.
- External dependency that fails — provider outages, rate limits, and latency spikes are a question of "when," not "if."
- Blurred trust boundaries — RAG, tools, and agents keep pouring external data into the prompt.
- Regulation applies — PII, cross-border transfer, data retention. If you don't bake it into the design early, it stops you later.
So instead of clever prompting, you place deterministic control outside the LLM. That's the shared language of the six pillars.
The six pillars: at a glance
| # | Pillar | Core question | Key decision |
|---|---|---|---|
| 1 | Security | How do you defend the LLM from attack? | Zero-trust output validation + least-privilege tools + human approval |
| 2 | MCP / tool connection | How do you connect AI to external tools safely? | Tools = arbitrary code execution. Least privilege, OAuth 2.1, no token passthrough |
| 3 | Evaluation & testing | How do you protect quality and regressions? | Dataset + automated grading + CI gate |
| 4 | Privacy | How do you protect customer data/PII? | PII minimization, ZDR, cross-border (APPI Art. 28 / GDPR Art. 28) by design |
| 5 | Reliability | How do you avoid going down on failures? | Transient-only retries, circuit breaker, multi-provider, idempotency |
| 6 | Caching / performance | How do you run fast and cheap? | Prompt + semantic caching, false-hit mitigation |
Below are each pillar's essence and the deep-dive link.
Pillar 1. Security: don't trust the output
Prompt injection fundamentally cannot be prevented by input filters (OWASP LLM01). Defense lives not in the input but in the architecture: validate LLM output with zero trust, keep tools at least privilege, and require human approval for high-impact actions. See LLM app security (OWASP LLM Top 10).
Pillar 2. MCP / tool connection: treat as arbitrary code execution
MCP is the standard for connecting AI to external tools. The crux is the premise "tools = arbitrary code execution": least privilege, propose/execute separation, and OAuth 2.1 token validation (no token passthrough). See MCP production server guide.
Pillar 3. Evaluation & testing: don't protect quality by eye
The quality of non-deterministic output can't be protected by eye. A dataset + automated grading (deterministic + LLM-as-judge) + a CI gate let the pipeline catch regressions. See LLM app evaluation & testing.
Pillar 4. Privacy & compliance: design to "not send"
API tiers don't train on your data by default — but with exceptions. Minimize and mask PII before sending, and bake in ZDR, region pinning, and cross-border transfer (APPI Art. 28 / GDPR Art. 28 DPA). See LLM app data privacy & compliance.
Pillar 5. Reliability & resilience: on the premise of failure
The LLM is a failing external dependency. Contain the damage with transient-only retries (backoff + jitter), circuit breakers, multi-provider fallback, and idempotency. See LLM app reliability & resilience.
Pillar 6. Caching & performance: fast and cheap
Re-processing the same/similar inputs every time is wasteful. Cut cost and latency with prompt caching (static content at the front) + semantic caching (with false-hit mitigation). See LLM app caching strategy.
Adoption order (implementation roadmap)
Add the six pillars in order, not all at once. From foundation to optimization.
- Threat modeling — make trust boundaries visible (what to protect).
- Output validation + least-privilege tools (pillars 1 & 2) — first, shrink the blast radius.
- Evaluation gate (pillar 3) — a way to not ship broken output, before adding features.
- Privacy design (pillar 4) — once the data you handle is decided, design to not send / not retain.
- Reliability (pillar 5) — get to a non-stopping setup before traffic hits.
- Caching optimization (pillar 6) — once it works, make it fast and cheap.
Integrated code: composing the six pillars into one flow
The six pillars aren't isolated knowledge — they compose into a single request flow. Below is the skeleton of a "trustworthy LLM call," where each step maps to its pillar (and the code in its deep-dive).
// 6本柱を1つのフローに合成した「信頼できるLLM呼び出し」。
async function trustworthyGenerate(input: UserInput, ctx: RequestContext): Promise<Answer> {
// 柱4 プライバシー:送る前に PII を最小化・マスクする
const safe = await redactPii(minimizeFields(input));
// 柱6 キャッシュ:意味的に似た質問は LLM を呼ばずに返す(scope でパーソナライズを隔離)
const cached = await semanticCache.get(safe, ctx.scope);
if (cached) return cached;
// 柱5 信頼性:多プロバイダ・フォールバック+一時障害限定リトライ+タイムアウト
// 柱1 セキュリティ:出力は Zod スキーマで検証(ゼロトラスト)
// 柱2 MCP:ツールは最小権限、破壊的操作は「提案」のみ(実行は承認後)
const raw = await generateResilient(safe, {
schema: AnswerSchema,
tools: leastPrivilegeTools,
idempotencyKey: ctx.requestId, // 冪等:リトライで二重実行しない
});
// 柱1 セキュリティ:スキーマ検証を通っても、業務ルールは決定的コードで再確認する
const answer = assertBusinessPolicy(raw, ctx);
await semanticCache.put(safe, ctx.scope, answer);
sampleForOnlineEval(ctx, safe, answer); // 柱3 評価:本番トラフィックを継続評価
return answer;
}
All six pillars appear in this flow — PII minimization (4) → caching (6) → fallback & retries (5) + output validation (1) + least-privilege tools & idempotency (2) → business-rule re-check (1) → online evaluation (3). Every step is an expression of the same principle: surround the probabilistic LLM with deterministic code.
Integrated checklist (one item per pillar)
- Security — is LLM output schema-validated, and are business rules re-checked in deterministic code?
- MCP / tools — are tools least-privilege, with destructive operations via human approval + an idempotency key?
- Evaluation — do you gate deploys on the pass rate against a fixed dataset?
- Privacy — is PII minimized/masked, and is cross-border (APPI 28 / GDPR 28) baked into the design?
- Reliability — do you have transient-only retries, circuit breakers, multi-provider, and idempotency?
- Caching — with prompt caching as the base, is semantic caching managed with a high threshold + TTL + evaluation?
Summary
A production LLM app stands on six pillars — security, MCP, evaluation, privacy, reliability, caching. And all of them reduce to a single principle.
Treat the LLM as a probabilistic, untrusted component, and surround it with deterministic architecture.
Validate output, narrow permissions, require human approval, gate quality, bake regulation into the design, absorb failures, and skip waste — all in deterministic code outside the LLM. Do that, and generative AI becomes a production system that is "fast to build, secure, unbreakable, trustworthy, non-stopping, and cheap." Building fast and defending fully are compatible when you design correctly.
For each pillar's implementation, see the deep-dives above. Turning these six into your design, one by one, is the shortest path from demo to production.