Output guard
Request and response schema for the output guard, provider requirements, and provider-unavailable fallback.
Evaluates model output before you return it to users or tools. When session_id matches stored input context, the provider may receive both the original user text and the LLM response for joint review.
For external providers, output flag/block decisions require valid module attribution (modules_triggered) from configured output modules.
Provider requirements
If output guarding is enabled, the configured output provider must be an LLM provider that supports modules (claude or openai). Using defend as guards.output.provider results in 400 with Output guarding requires an LLM provider (claude or openai).
The selected model must support tool/function calling because Defend enforces structured verdict output through provider tool invocation.
Disabled output guard
When guards.output.enabled is false, the handler short-circuits to action: pass without calling a provider.
Request
Prop
Type
Response
Uses the same GuardResult shape as input guard.
Provider unavailable
If the LLM provider throws ProviderUnavailableError, the service maps the failure to guards.output.on_fail (block or flag) instead of returning a 5xx.
Examples
curl -s -X POST http://localhost:8000/v1/guard/output \
-H "Content-Type: application/json" \
-d '{"text":"Model answer here.","session_id":"def-abc12345"}'import httpx
r = httpx.post(
"http://localhost:8000/v1/guard/output",
json={"text": "Model answer here.", "session_id": "def-abc12345"},
)
print(r.json())