input-check before the LLM and output-check on the response.
Streaming responses
For streaming LLM responses, forward each chunk tooutput-check as soon as it is received rather than waiting for the full response. This reduces time-to-detect for unsafe content and supports near-real-time handling decisions while output is still being generated.
Reference implementation — Python
Reference implementation — Node / TypeScript
Failure handling
Decide your fail-open vs fail-closed posture explicitly. Both are reasonable depending on threat model:
Set a generous client timeout (the example uses 30 s) but track per-call latency and budget for the worst-case Protector Plus response in your end-to-end SLO.

