Skip to main content
ARCHOS 525 BLUEPRINT · /d/dgm_llm-constrained-decoding-and-structured-output

Constrained decoding and structured output (schema-checked answers)

10 COMPONENTS · 12 FLOWS · UPDATED 2026-11-21
GITHUB README / PR PREVIEW CARD
[![Constrained decoding and structured output (schema-checked answers) — ArchOS Architecture](https://archos.sageideas.dev/d/dgm_llm-constrained-decoding-and-structured-output/opengraph-image)](https://archos.sageideas.dev/d/dgm_llm-constrained-decoding-and-structured-output)

*Interactive architecture diagram powered by [ArchOS Studio](https://archos.sageideas.dev/d/dgm_llm-constrained-decoding-and-structured-output)*
NOTION / DOCS / CONFLUENCE EMBED
<iframe src="https://archos.sageideas.dev/embed/dgm_llm-constrained-decoding-and-structured-output" width="100%" height="580" style="border:1px solid rgba(240,236,225,0.14);border-radius:6px;" loading="lazy" title="Constrained decoding and structured output (schema-checked answers) — Interactive in ArchOS"></iframe>
PORTABLE MERMAID SPEC (GITHUB / NOTION / RFC)
flowchart LR
  client_0[("API Client")]
  gw_1["API gateway"]
  llmgw_2["AI gateway"]
  engine_3["Inference server"]
  grammar_4["Structured output"]
  dlq_5[("Dead-letter queue (DLQ)")]
  secrets_6[("Secrets manager")]
  tsdb_7[("Time-series database (TSDB)")]
  alerting_8[("Alerting")]
  capacity_9["Capacity Estimate"]
  client_0 -->|"1. Calls with a JWT · HTTPS"| gw_1
  gw_1 -->|"2. Forwards (mTLS) · HTTP/2"| llmgw_2
  llmgw_2 -->|"3. Sends prompt (mTLS) · HTTP/2"| engine_3
  engine_3 -->|"4. Asks allowed tokens · method call"| grammar_4
  grammar_4 -->|"5. Returns token mask · method call"| engine_3
  engine_3 -->|"6. Returns JSON text · HTTP/2"| llmgw_2
  llmgw_2 -->|"7a. Returns result · HTTP/2"| gw_1
  gw_1 -->|"8. Returns JSON · HTTPS"| client_0
  secrets_6 -->|"Supplies credential · HTTPS"| llmgw_2
  llmgw_2 -->|"Exports (OTLP) · OTLP"| tsdb_7
  tsdb_7 -->|"Notifies · HTTP"| alerting_8
  llmgw_2 -.->|"7b. Parks failures · TCP"| dlq_5

COMPONENT STACK (9)

  • API ClientSTATEFUL
    Sends a prompt and a schema from an untrusted network
  • API gatewaySTATELESS
    Checks the JWT and scope, caps requests in flight
  • AI gatewaySTATELESS
    Checks the schema, validates output, retries once
  • Inference serverSTATELESS
    Samples one token per step from the allowed set
  • Structured outputSTATELESS
    Turns the schema into a grammar and masks tokens
  • Dead-letter queue (DLQ)STATEFUL
    Parks answers that fail twice
  • Secrets managerSTATEFUL
    Holds the server credential and TLS certificates
  • Time-series database (TSDB)STATEFUL
    Stores check failures, retries and first-token time
  • AlertingSTATEFUL
    Pages on-call when checks fail or the DLQ grows

REQUEST & DATA FLOW (12)

  1. API Client → API gateway (Calls with a JWT)[HTTPS]
  2. API gateway → AI gateway (Forwards (mTLS))[HTTP/2]
  3. AI gateway → Inference server (Sends prompt (mTLS))[HTTP/2]
  4. Inference server → Structured output (Asks allowed tokens)[method call]
  5. Structured output → Inference server (Returns token mask)[method call]
  6. Inference server → AI gateway (Returns JSON text)[HTTP/2]
  7. AI gateway → API gateway (Returns result)[HTTP/2]
  8. API gateway → API Client (Returns JSON)[HTTPS]
  9. Secrets manager → AI gateway (Supplies credential)[HTTPS]
  10. AI gateway → Time-series database (TSDB) (Exports (OTLP))[OTLP]
  11. Time-series database (TSDB) → Alerting (Notifies)[HTTP]
  12. AI gateway → Dead-letter queue (DLQ) (Parks failures)[TCP]
Configure NGINX / Postgres / K8s →60-Sec L4–L7 Diagnostic →