Examples
Ready-to-run examples demonstrating Guardrails in various scenarios. See the guardrails/examples/
folder for complete implementations. TypeScript examples are available in the guardrails-ts/examples/
folder.
Example Implementations (Python)
- hello_world.py — Basic pipeline configuration with input/output guardrails
- agents_sdk.py — Integration with OpenAI Agents SDK
- pii_mask_example.py — PII detection and scrubbing
- structured_outputs_example.py — Using responses.parse with guardrails
- Streaming (fast) — Stream output while guardrails run
- Blocking (slow) — Validate fully before showing output
Example Implementations (TypeScript)
- hello_world.ts — Basic Guardrails usage
- agents_sdk.ts — OpenAI Agents SDK integration
- streaming.ts — Streaming vs blocking usage
- suppress_tripwire.ts — Handle violations without raising
- multiturn_with_prompt injection detection.ts — Multi-turn with prompt injection detection
- azure_example.ts — Azure OpenAI client
- local_model.ts — OpenAI-compatible local endpoint
Hallucination Detection Example
Complete implementation using real documents as knowledge sources:
examples/hallucination_detection/
Getting Started
- Follow the Quickstart guides: Python · TypeScript
- Explore repositories: Python examples · TypeScript examples
- Run scripts to see Guardrails in action
Each example is self-contained with clear configuration and usage patterns.