docs/guides/example-projects/openai-agent-sdk-guardrails.mdx
This demo is a practical guide that demonstrates:
Guardrails are safety mechanisms that run alongside AI agents to validate input, check output, monitor streaming content in real-time, and prevent unwanted or harmful behavior.
<Card title="View the OpenAI Agent SDK Guardrails repo" icon="GitHub" href="https://github.com/triggerdotdev/examples/tree/main/openai-agent-sdk-guardrails-examples"
Click here to view the full code for this project in our examples repository on GitHub. You can fork it and use it as a starting point for your own project. </Card>
<video controls className="w-full aspect-video" src="https://github.com/user-attachments/assets/9b1e55c7-467d-4aca-8b4a-a018014c0827"
</video>
InputGuardrailTripwireTriggered exceptionsOutputGuardrailTripwireTriggered exceptions with detailed error info@input_guardrail decorator that validates user input before processing (example: math tutor that only responds to math questions)@output_guardrail decorator that validates generated responses using a separate guardrail agentResponseTextDeltaEvent streams with async guardrail checks at configurable intervals (example: stops streaming if language is too complex for a 10-year-old)