Skip to main content
Custom security rules let you go beyond built-in detection. Define policies that match your exact business requirements - block specific topics, protect entity names, enforce natural-language constraints, and more.

Policy Types

PromptGuard supports seven policy types. Each policy has a type, an action (block, redact, flag, allow), and either rules (condition-based) or a system prompt (LLM-judged).

Creating Policies

Policies are created and edited in the dashboard. The public API exposes a read-only listing so you can verify which policies are active for your project.

Create in the Dashboard

  1. Navigate to app.promptguard.co → your project → Policies
  2. Click “Create Policy”
  3. Select the policy type
  4. Configure rules or system prompt description
  5. Click “Create Policy”
For example, an entity_blocklist policy named “Block Competitor Mentions” with the rule:

List via API

Verify your project’s policies with the Developer API:
Returns all policies attached to the project associated with your API key, including type, rules, and active status.

Rule Conditions

Rule-based policies (input_filter, output_filter, entity_blocklist, custom) use condition/value/action triples:

Actions

Each rule specifies what happens when the condition matches:

Topic Filter

Topic filters use natural language to define what a conversation should be about. An LLM judge evaluates each request against your description and blocks off-topic queries. Create a topic_filter policy in the dashboard with a description like:
When to use topic_filter vs. input_filter:
  • Use topic_filter when the boundary is semantic (“stay on topic”)
  • Use input_filter with contains_text rules when the boundary is lexical (“block this exact word”)

LLM Guard

LLM Guard policies define custom business rules in natural language, evaluated by an LLM judge. Use these for constraints that are too nuanced for pattern matching. Create an llm_guard policy in the dashboard with your business rule as the description:
Self-hosting the judge? llm_guard runs on a small open model — by default a non-thinking instruct model, which is the right tool for a structured flag/no-flag verdict. If you point LLM_GUARD_MODEL (or a local LLM_GUARD_BASE_URL server) at a reasoning / “thinking” model, it emits a long chain-of-thought before its answer and can run out of tokens before the verdict — the guard then fails open (stops guarding) silently. If you must use a reasoning model, raise LLM_GUARD_MAX_TOKENS well above its trace length; otherwise stick with an instruct model. Watch the llm_guard_truncated log marker to catch this, and use python -m shared.security.evals.guard_model_bakeoff to compare candidate models on accuracy, latency, and truncation rate.

Entity Blocklist

Entity blocklists protect specific names, terms, or identifiers from appearing in prompts or responses. They evaluate against both input and output. Create an entity_blocklist policy in the dashboard with your protected terms:
The contains_text_any condition accepts pipe-separated (|) terms and matches any of them. This is more efficient than creating multiple contains_text rules.

Policy Presets

PromptGuard also provides six use-case-specific presets that combine multiple built-in detectors: See Policy Presets for detailed configuration.

Feature Comparison by Tier

Next Steps

Policy Presets

Pre-configured security policies

Threat Detection

Built-in detection capabilities

Dashboard

Trace policy decisions and debug

API Reference

Full policy management API