Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_llm-gateway-routing

AI gateway (model routing, fallback, semantic cache and quotas)

13 COMPONENTS · 18 FLOWS · UPDATED 2026-11-20
GITHUB README / PR PREVIEW CARD
[![AI gateway (model routing, fallback, semantic cache and quotas) — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_llm-gateway-routing/opengraph-image)](https://archos.sageideas.dev/d/dgm_llm-gateway-routing)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_llm-gateway-routing)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_llm-gateway-routing" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="AI gateway (model routing, fallback, semantic cache and quotas) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0[("API Client")]
  api_1["API gateway"]
  pdp_2["Policy decision point (PDP)"]
  rl_3[("Rate limiter")]
  rcache_4[("Distributed cache")]
  ai_5["AI gateway"]
  scache_6[("Semantic cache")]
  secrets_7[("Secrets manager")]
  tsdb_8[("Time-series database (TSDB)")]
  alerting_9[("Alerting")]
  pa_10["Inference server"]
  pb_11["Inference server"]
  capacity_12["Capacity Estimate"]
  client_0 -->|"1. Calls with JWT · HTTPS"| api_1
  api_1 -->|"2. Asks policy (mTLS) · HTTP/2"| pdp_2
  pdp_2 -->|"3. Returns allow or deny · HTTP/2"| api_1
  api_1 -->|"4. Asks for quota (mTLS) · HTTP/2"| rl_3
  rl_3 -->|"5. Returns decision · HTTP/2"| api_1
  api_1 -->|"6. Forwards (mTLS) · HTTP/2"| ai_5
  ai_5 -->|"7. Looks up answer (mTLS) · HTTP/2"| scache_6
  scache_6 -->|"8. Returns hit or miss · HTTP/2"| ai_5
  ai_5 -->|"9a. Calls with API key · HTTPS"| pa_10
  ai_5 -->|"9b. Falls back with API key · HTTPS"| pb_11
  pa_10 -->|"10a. Returns completion · HTTPS"| ai_5
  pb_11 -->|"10b. Returns completion · HTTPS"| ai_5
  ai_5 -->|"11. Returns answer · HTTP/2"| api_1
  api_1 -->|"12. Returns answer or HTTP 429 · HTTPS"| client_0
  ai_5 -->|"Fetches API keys · HTTPS"| secrets_7
  rl_3 -->|"Runs bucket script · RESP"| rcache_4
  ai_5 -->|"Exports (OTLP) · OTLP"| tsdb_8
  tsdb_8 -->|"Feeds metrics · HTTP"| alerting_9

COMPONENT STACK (12)

  • API ClientSTATEFUL
    Sends prompts from an untrusted network
  • API gatewaySTATELESS
    Checks the JWT, then asks policy and quota
  • Policy decision point (PDP)STATELESS
    Allows a model per team; denies if unsure
  • Rate limiterSTATEFUL
    Token bucket per key; fails open on timeout
  • Distributed cacheSTATEFUL
    Holds the bucket counters
  • AI gatewaySTATELESS
    Routes by rule, fails over, checks cache first
  • Semantic cacheSTATEFUL
    Returns a stored answer for a similar prompt
  • Secrets managerSTATEFUL
    Holds the provider API keys
  • Time-series database (TSDB)STATEFUL
    Stores latency, errors, fallbacks, hits
  • AlertingSTATEFUL
    Pages on-call when errors or fallbacks spike
  • Inference serverSTATELESS
    Provider A: small and large models
  • Inference serverSTATELESS
    Provider B: fallback for the same tasks

REQUEST & DATA FLOW (18)

  1. API Client → API gateway (Calls with JWT)[HTTPS]
  2. API gateway → Policy decision point (PDP) (Asks policy (mTLS))[HTTP/2]
  3. Policy decision point (PDP) → API gateway (Returns allow or deny)[HTTP/2]
  4. API gateway → Rate limiter (Asks for quota (mTLS))[HTTP/2]
  5. Rate limiter → API gateway (Returns decision)[HTTP/2]
  6. API gateway → AI gateway (Forwards (mTLS))[HTTP/2]
  7. AI gateway → Semantic cache (Looks up answer (mTLS))[HTTP/2]
  8. Semantic cache → AI gateway (Returns hit or miss)[HTTP/2]
  9. AI gateway → Inference server (Calls with API key)[HTTPS]
  10. AI gateway → Inference server (Falls back with API key)[HTTPS]
  11. Inference server → AI gateway (Returns completion)[HTTPS]
  12. Inference server → AI gateway (Returns completion)[HTTPS]
  13. AI gateway → API gateway (Returns answer)[HTTP/2]
  14. API gateway → API Client (Returns answer or HTTP 429)[HTTPS]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →