FDEInterviews logo
System Design & Production Engineering / 48
hardAnthropicOpenAICloudflare

Design a safety-enforced LLM API gateway: intercept prompts and outputs, apply dynamic policy, add under 5% latency, support streaming

A gateway that screens every prompt and streamed token against a live policy without blowing the latency budget. The strong answer separates the policy decision from its data, runs deterministic checks inline and model checks in parallel, and redacts a leaking secret mid-stream before it renders.

Updated Aug 2026 · Grounded in real Forward Deployed Engineer interview loops and written to a senior-engineer editorial bar.

A gateway that screens every prompt and streamed token against a live policy without blowing the latency budget. The strong answer separates the policy decision from its data, runs deterministic checks inline and model checks in parallel, and redacts a leaking secret mid-stream before it renders.

20 answers per topic instead of 10, plus saved progress and bookmarks · no cardor unlock all 523 remaining answers · ₹2,000 / $25
UP NEXT ON YOUR JOURNEY
FEDITOR'S NOTE

The trap is a synchronous chain of LLM calls per request, which triples latency and misses the under-5% target. The senior move is a tiered engine: deterministic rules and regex inline (microseconds), a small classifier in parallel with the model call, and a hot-reloadable policy store separate from the engine so a new rule (never reveal reset tokens) ships without a deploy. The streaming question is the real test: you must buffer just enough to catch a forbidden span before it reaches the client, and stream the rest.

DISCUSSION · 0

No comments yet — be the first to share your approach.