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
[](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_5COMPONENT STACK (9)
- API ClientSTATEFULSends a prompt and a schema from an untrusted network
- API gatewaySTATELESSChecks the JWT and scope, caps requests in flight
- AI gatewaySTATELESSChecks the schema, validates output, retries once
- Inference serverSTATELESSSamples one token per step from the allowed set
- Structured outputSTATELESSTurns the schema into a grammar and masks tokens
- Dead-letter queue (DLQ)STATEFULParks answers that fail twice
- Secrets managerSTATEFULHolds the server credential and TLS certificates
- Time-series database (TSDB)STATEFULStores check failures, retries and first-token time
- AlertingSTATEFULPages on-call when checks fail or the DLQ grows
REQUEST & DATA FLOW (12)
- API Client → API gateway (Calls with a JWT)[HTTPS]
- API gateway → AI gateway (Forwards (mTLS))[HTTP/2]
- AI gateway → Inference server (Sends prompt (mTLS))[HTTP/2]
- Inference server → Structured output (Asks allowed tokens)[method call]
- Structured output → Inference server (Returns token mask)[method call]
- Inference server → AI gateway (Returns JSON text)[HTTP/2]
- AI gateway → API gateway (Returns result)[HTTP/2]
- API gateway → API Client (Returns JSON)[HTTPS]
- Secrets manager → AI gateway (Supplies credential)[HTTPS]
- AI gateway → Time-series database (TSDB) (Exports (OTLP))[OTLP]
- Time-series database (TSDB) → Alerting (Notifies)[HTTP]
- AI gateway → Dead-letter queue (DLQ) (Parks failures)[TCP]