Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_llm-cost-control

LLM Token Budget, Semantic Cache & Cost Control Architecture

8 COMPONENTS · 7 FLOWS · UPDATED 2026-11-24
GITHUB README / PR PREVIEW CARD
[![LLM Token Budget, Semantic Cache & Cost Control Architecture — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_llm-cost-control/opengraph-image)](https://archos.sageideas.dev/d/dgm_llm-cost-control)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_llm-cost-control)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_llm-cost-control" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="LLM Token Budget, Semantic Cache & Cost Control Architecture — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0["Tenant Workload"]
  bud_1[("Budget Enforcer")]
  sem_2[("Semantic Cache")]
  cls_3["Complexity Router"]
  sm_4["Fast Small Model"]
  lg_5["Frontier Model"]
  fin_6[("Cost Attribution Ledger")]
  downstream_7["Downstream & OTel"]
  client_0 -->|"1. Reserve · RESP3"| bud_1
  bud_1 -->|"2a. Check · gRPC"| sem_2
  bud_1 -->|"2b. Cache miss · HTTP"| cls_3
  cls_3 -->|"3a. Route 80% · HTTPS"| sm_4
  cls_3 -->|"3b. Escalate · HTTPS"| lg_5
  cls_3 -.->|"3c. Reconcile · Kafka"| fin_6
  lg_5 -.->|"4. Emit / · OTLP/API"| downstream_7

COMPONENT STACK (8)

  • Tenant WorkloadSTATELESS
    Prompt + Tenant Tier
  • Budget EnforcerSTATEFUL
    Redis atomic $ & TPM caps
  • Semantic CacheSTATEFUL
    Cosine > 0.96 -> 0 token cost
  • Complexity RouterSTATELESS
    80% small model / 20% frontier
  • Fast Small ModelSTATELESS
    8B / Haiku / Flash
  • Frontier ModelSTATELESS
    Complex reasoning only
  • Cost Attribution LedgerSTATEFUL
    Per-tenant $/feature telemetry
  • Downstream & OTelSTATELESS
    Consumers, metrics & SLOs

REQUEST & DATA FLOW (7)

  1. Tenant Workload → Budget Enforcer (Reserve)[RESP3]
  2. Budget Enforcer → Semantic Cache (Check)[gRPC]
  3. Budget Enforcer → Complexity Router (Cache miss)[HTTP]
  4. Complexity Router → Fast Small Model (Route 80%)[HTTPS]
  5. Complexity Router → Frontier Model (Escalate)[HTTPS]
  6. Complexity Router → Cost Attribution Ledger (Reconcile)[Kafka]
  7. Frontier Model → Downstream & OTel (Emit /)[OTLP/API]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →