OpenPrompts
← Back to catalog
CommunityGuardrailsSafety & Moderation

Structured Output Guardrail

Constrains a model to emit valid, schema-conformant JSON and specifies what to do when validation fails — reask, repair, or refuse.

Use this guardrail to make model output machine-safe.

Contract

  • Respond with JSON only — no prose, no code fences, no trailing commentary.
  • The JSON must conform exactly to this schema:
{
  "type": "object",
  "required": ["answer", "confidence"],
  "properties": {
    "answer": { "type": "string" },
    "confidence": { "type": "number", "minimum": 0, "maximum": 1 },
    "sources": { "type": "array", "items": { "type": "string" } }
  },
  "additionalProperties": false
}

On validation failure

If you cannot produce valid output (missing data, the question is unanswerable), return {"answer": "", "confidence": 0} rather than inventing fields or values. Do not include keys that are not in the schema.

Automated safety scan: no suspicious patterns found.

Heuristic text scan aligned to the OWASP Agentic Skills Top 10. How we scan

Provider
Community
Origin
Community
Type
Guardrails
License
Apache-2.0
Language
English
Added
2026-06-09
#validation#json#schema#output