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.

  1. 01

    Read the input

    ModelRiver takes the text from the request’s messages, prompt and input. Images aren’t checked.

  2. 02

    Classify it

    A built-in classifier checks the text first. Unclear cases can go to OpenAI’s moderation model for a second look.

  3. 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.

  4. 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

What a block looks like

Your code gets a clear error it can show or handle. The prompt that was blocked isn’t stored.

blocked response
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

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.

Guardrails are on from the start

Create a project on the free plan and every request is checked before it reaches a model.