Local LLM Guardrails: Moderating Inputs and Outputs

Moving inference onto your own hardware fixes one problem and quietly creates another. You keep user text inside your perimeter, then realise your moderation still calls a hosted endpoint — and that single outbound request re-opens the egress you closed. Local LLM guardrails are the layer that closes it again: a check on the user's input before it becomes a prompt, and a check on the model's output before it reaches a user, a log or another service. This guide covers where those checks belong in the request path, what to screen on each side, how to run the layer inside your own network, and what to look for in a moderation model you can install offline.
What Guardrails Mean for a Locally Hosted LLM
A model file is not a guardrail. When you pull weights onto your own hardware you get the safety behaviour that shipped with those weights, and nothing else. Nothing inspects the user's message before it becomes part of a prompt. Nothing inspects the answer before it reaches the screen. Nothing records what your policy blocked last Tuesday, or why.
So "does a local LLM have guardrails?" is the wrong question. Guardrails are not a property of the model file; they are a layer you place around it. A model with no safety tuning at all can sit behind a strong guardrail layer, and a heavily safety-tuned model can still produce output you would not want stored in a log or forwarded to another service.
Input Guardrails vs Output Guardrails
Two checks, two different jobs:
- Input guardrails run on the user's text before it becomes a prompt. They protect your system: the prompt, the context window, the vector store, the logs, and the downstream tools the model can call.
- Output guardrails run on the model's text before it reaches a user, a database, a log pipeline or another agent. They protect everyone else, and they are the only thing standing between a bad generation and a screenshot.
Both sides need coverage. Checking only the input means a harmless prompt that produces a harmful answer sails straight through.
Where the Checks Sit in the Request Path
Walk the path once and the two checkpoints become obvious:
- Ingest — the message arrives from your UI, bot, API or queue.
- Check the input — run the moderation layer on the raw user text.
- Build the prompt — system prompt, retrieved context, conversation history, user text.
- Run inference — your model on your GPU.
- Check the output — run the moderation layer on the generated text.
- Deliver or store — stream to the user, write to the transcript, hand to the next agent, or send to a review queue.
The checks are synchronous, in-line steps. They are not a batch job that runs overnight, and they are not a dashboard you look at afterwards.
Why a Hosted Moderation API Breaks the Air Gap
Teams move inference in-house for a familiar set of reasons: privacy commitments, data residency, contractual restrictions on subprocessors, or plain network isolation. The moment one of those reasons applies to the model, it applies to every other service that sees the same text.
A hosted moderation endpoint sees the text. If your chatbot sends the user's message to a third party for classification, you have recreated exactly the egress the local model was meant to remove — usually without a line in the architecture diagram, because it hides inside an SDK call. If you chose an air-gapped deployment, the external check is not merely discouraged, it is impossible by design: an air-gapped host has no route to the internet. The moderation layer therefore has to satisfy the same constraint as the model itself. It runs inside your network.
If you are still weighing the two approaches, on-premises vs cloud content moderation lays out the trade-offs before you commit.
Depending on your jurisdiction and sector, privacy and data-protection rules may impose duties about where personal data may be processed and who may access it. Those duties are fact-specific — read the official text of the relevant law, or get legal advice, rather than relying on a summary from a vendor blog.
What to Check on the Input Side
Input screening is about what your system is allowed to ingest, log and act on.
Categories that typically need an input check
- Abuse and harassment — the most common thing a public-facing endpoint receives.
- Hate — slurs and targeted attacks, which also poison your logs and fine-tuning sets.
- Adult content — relevant wherever minors can reach the product.
- Self-harm — the category with the strongest argument for human escalation rather than a silent block.
- Spam — injection-style padding, repeated filler and automated abuse.
- Minor safety — anything suggesting the speaker or the target is a child.
- PII — personal data that should not enter a prompt, a transcript or a vector store.
That list is a starting point, not a policy. Your categories come from your product, your user base and your legal obligations.
What your product does when a check fires
The moderation layer should return a signal; your application decides what the signal means. Typical responses:
- Block — reject the message and show a policy notice.
- Queue for human review — hold the message and keep the user's session intact.
- Redact — strip the offending span and continue with the rest.
- Answer with a canned response — useful for self-harm content, where a generic refusal is the wrong outcome.
Keep that decision logic in your own code, where you can version it, test it and explain it to an auditor. The check itself should return a simple value you can branch on.
What to Check on the Output Side
Model output needs its own pass for three reasons: a benign prompt can still produce a harmful answer; your model has no idea what your policy promises users; and output is what gets stored. A transcript that contains unfiltered abuse, personal data or sexual content becomes a liability the moment someone exports it.
Output checks typically cover the same harmful categories, plus PII (the model may echo or invent personal data) and minor safety, before the response is streamed, stored or handed to another agent. If your product handles generated text in other places — summaries, agent tool calls, emails drafted on a user's behalf — see checking LLM and chatbot output for how a boolean moderation result maps onto those paths.
Why boolean flags beat scores in a pipeline
Many moderation services return a score per category, and teams then spend weeks choosing thresholds. That work does not survive contact with production. A score of 0.62 means different things for different categories, different languages and different user bases, and the distribution drifts as traffic changes. Thresholds need recalibration, and recalibration needs labelled data nobody has time to build.
A boolean is a branch. It is either flagged or it is not, the same way everywhere in your code:
if result["flagged"]:
hold_for_review(result["categories"])
else:
deliver(response_text)No threshold, no calibration run, no argument in code review about whether 0.6 is too aggressive. The trade-off is real — you give up the ability to tune sensitivity — but for an automated pipeline that has to make a decision in milliseconds, a stable branch is usually worth more than a dial.
Streaming complicates the output check
If you stream tokens to the user, you have a choice to make: check the full response before the first token leaves (adds latency, keeps the guardrail absolute), or check chunks as they arrive (fast, but a flagged phrase may already be on screen). A common compromise is to buffer the opening window of the response, check it, then release. Decide deliberately, and make sure the transcript you store is the checked version, not the raw one.
Running the Moderation Layer Inside Your Network
Deployment shapes
Three common layouts, and the trade-offs between them:
- Same host as the LLM — simplest, lowest latency, no extra network hop, but the check competes for the same GPU and the blast radius is shared.
- A separate GPU node in the same cluster — keeps the model and the guardrail independent, so a saturated inference server does not starve moderation, and each can be scaled and upgraded on its own schedule.
- A separate subnet or security zone — strongest isolation and the easiest story for an auditor, at the cost of another hop and more operational surface.
Whichever you choose, the moderation service should be reachable over your internal network only. deploy an on-premises moderation model with Docker covers the mechanics of getting a container running on your own hardware.
Air-gapped installs
For an air-gapped host, two properties stop being nice-to-haves and become requirements: the moderation container must make no outbound network calls, and it must run with no telemetry. A container that phones home for licensing, analytics or model updates is not an air-gapped component, no matter how it is marketed. You also need a way to install and upgrade it offline — an image you can move across the gap on physical media, or a private registry inside your network.
Keep the paper trail inside too
The point of the exercise is that the text never leaves. That applies to the artefacts as well as the payload:
- Audit logs — what was checked, when, which categories fired, and what your application did in response. Store them in your own logging stack.
- Human review queue — escalations should land in a tool your reviewers already have access to, not a vendor console.
- Sampling sets — if you keep examples for quality review, keep them where your policy allows them to live.
Plan for versions and licences
Treat the moderation model like any other internal service. Know which version is deployed, how upgrades arrive, and what the licence permits before you scale from one install to twenty. A model that is easy to run in a proof of concept can become a procurement problem at rollout if the terms restrict installs or redistribution.
Criteria for Choosing a Moderation Model You Can Self-Host
Use this as a checklist when you evaluate vendors. Ask each one to confirm the details against their current documentation — published terms change, and a summary written by anyone, including this article, is not a substitute for the vendor's own docs.
- No outbound network access. The container must run with egress blocked. Ask what happens when it cannot reach the internet, and whether it is designed never to try.
- Offline or private-registry install. You need an image you can pull from your own registry or load from media, plus a documented path for air-gapped environments.
- A predictable output format. You want a result your code can branch on immediately, and documentation that tells you exactly which fields come back.
- Clear category coverage. A published list of categories, with a description of what each one means, so you can map them to your policy instead of guessing.
- Licence terms you can live with. Check the number of permitted installs, whether the software or its keys may be redistributed, what upgrade rights you get, and whether the terms change between versions.
- Air-gapped upgrade support. Ask how a new version reaches a host with no route to the internet, and how often that is expected to happen.
- Operational requirements. GPU, memory, container runtime and startup behaviour, so you can size the node before you buy it.
For every vendor on your shortlist, read their current pricing, licence and documentation pages directly. Do not rely on comparison tables written by anyone else, including competitors.
Common Mistakes When Self-Hosting Moderation
- Mistaking a word blocklist for a moderation model. Blocklists miss context entirely and misfire on ordinary language, and they need constant maintenance.
- Routing text out through a proxy to reach a hosted moderation API. This defeats the reason the model was moved in-house and often violates the same policy that drove the decision.
- Checking inputs only. Model output goes straight to users, logs and downstream agents unchecked.
- Trying to tune a threshold that does not exist. If the API returns booleans, build your logic around booleans and put the nuance in your review queue.
- Ignoring the licence until the second or third install. Licence terms are easiest to negotiate before you are committed.
- Treating the guardrail as a dashboard. A moderation layer that reports rather than blocks is not on the request path, and it will not stop anything.
Frequently Asked Questions
Does a local LLM have guardrails by default? No. A local model ships with whatever safety behaviour its training gave it, which is not the same as a guardrail. Guardrails are checks you add on the request path — one before the prompt is built, one before the output is delivered.
How do I moderate text without sending it out? Run a moderation model inside your own network and call it over localhost or your internal network. The text is checked on hardware you control, and the check itself makes no outbound calls.
Where in the pipeline do the checks go? Two places: on the user's raw input, before it becomes a prompt, and on the model's generated output, before it is streamed, stored or forwarded. Both should be synchronous steps in the request path.
What should I look for in a model I can self-host? No outbound calls, an offline install path, a documented output format, a published category list, licence terms that cover your install count and upgrades, and support for air-gapped environments.
How CautionLabs Runs Local LLM Guardrails on Your Own Servers
CautionLabs ships an on-premises model for exactly this problem. Argus 1 (model id argus_1) is the first on-premises model, and it is a one-time payment of $299 USD per model, with unlimited installs and requests and upgrades to that model included. The On-Premises Guide covers requirements and deployment in full.
Getting it running takes four steps:
- Buy a model.
- Create a private key in the dashboard.
- Log in to the CautionLabs registry with that key as the password, then run the image.
- Call
POST /moderatewith{"text": "..."}on your own network — the default endpoint ishttp://localhost:8000.
A typical call looks like this:
curl -X POST http://localhost:8000/moderate \
-H "Content-Type: application/json" \
-d '{"text": "text to check"}'{
"categories": {
"toxic": false,
"profanity": false,
"hate": false,
"harassment": false,
"self_harm": false,
"adult": false,
"violence": false,
"drugs": false,
"weapons": false,
"pii": false,
"spam": false,
"minor": false
},
"flagged": false
}Responses carry true/false flags for twelve categories — toxic, profanity, hate, harassment, self_harm, adult, violence, drugs, weapons, pii, spam and minor — plus an overall flagged value. There are no scores, no probabilities and no thresholds to tune, so your application branches on a boolean instead of calibrating a cutoff.
The container makes no outbound requests and has no telemetry, and air-gapped installs are supported. The on-premises licence does not allow distributing the software or its API keys. Note also that a private on-premises key does not work with the cloud API.
This article deliberately stays out of the operational weeds on error codes, credits, batching, webhooks and rate limits — the On-Premises Guide is the place for those.
Start with the On-Premises Guide, buy the Argus 1 model, create a private key, run the container inside your own network and call POST /moderate on localhost. Check the pricing page for the current on-premises terms.