Q: What are guardrails in AI apps?
Guardrails are checks that run around the model, in your own code, to keep an AI app on-topic, safe, and on-format.
They come in two kinds. Input guardrails inspect what's about to reach the model: is this question on-topic for the app? Does it look like a prompt injection attempt? Output guardrails inspect the response before the user sees it: does it leak personal data, break the required format, or drift off task? A common pattern uses a small, cheap model as the checker in front of or behind your main model.
Why not just write the rules into the system prompt? Because a prompt is a request, and code is enforcement. Models can be talked out of their instructions, and a public-facing app will meet users who try. Anything the system prompt permits by accident (off-topic questions, oversharing, misuse of your API budget) will eventually happen. Guardrails are how you make the rules actually hold.