Guardrails
Screen harmful promptsbefore they reach a model.
Input guardrails check the text of each request for sexual content, self-harm, hate and violence before ModelRiver calls a provider. Block it, log it, or turn the check off, for each project.
How guardrails work
Guardrails are on for every project unless you change them. The check runs before any provider is called.
- 01
Read the input
ModelRiver takes the text from the request’s messages, prompt and input. Images aren’t checked.
- 02
Classify it
A built-in classifier checks the text first. Unclear cases can go to OpenAI’s moderation model for a second look.
- 03
Block or allow
In enforce mode, flagged text is blocked before any model sees it. In monitor mode it goes through, and the result is logged.
- 04
Slow down repeat abuse
A caller who is blocked 5 times in 15 minutes gets 429 with Retry-After for a while.
The numbers
- 4 + 1Categories you can turn on, plus protection for minors that is always on
- 3 modesEnforce, monitor or off, set per project
- 5 in 15 minBlocked requests before a caller is slowed down with 429
- 403Status when a request is blocked; 400 on the OpenAI-compatible endpoint
What a block looks like
Your code gets a clear error it can show or handle. The prompt that was blocked isn’t stored.
HTTP/1.1 403 Forbidden
{
"error": "content_policy_violation",
"message": "Request blocked by content policy.",
"categories": ["violence"]
}Pick the categories
Turn sexual content, self-harm, hate and violence on or off for each project. Protection for minors can’t be turned off.
Try it in monitor mode
Monitor mode lets every request through and logs what would have been blocked, so you can check before you enforce.
Only admins can relax it
Only project owners and admins can weaken a project’s guardrails.
Good to know
Input only
Guardrails check what is sent to the model, not what the model sends back.
Text only
Text in messages, prompt and input is checked. Requests with only images are marked as not checked.
Not a prompt-injection filter
Guardrails look for harmful content. They don’t detect personal data or prompt-injection attempts.
Every entry point
Sync, async and streaming requests, the OpenAI-compatible endpoint and the Playground are all checked. Streaming is checked before the stream starts.
Frequently asked questions
What do guardrails check for?
Sexual content, self-harm, hate and violence, which you can turn on or off per project, plus protection for minors that is always on.
What happens when a request is blocked?
In enforce mode the API returns 403 with content_policy_violation and the matching categories, and no provider is called. The OpenAI-compatible endpoint returns 400.
Can I test guardrails without blocking users?
Yes. Monitor mode lets requests through and logs each flagged one, so you can review results before switching to enforce.
Are blocked prompts stored?
No. The decision is logged, but the text of a blocked prompt is never stored.
Do guardrails check the model’s answer?
No. They check the input before the provider is called. Responses are not moderated.
Works well with
Guardrails are on from the start
Create a project on the free plan and every request is checked before it reaches a model.