Skip to main content

pipecat-guardrails

Output guardrails for Pipecat voice agents. It checks what your bot is about to say, and stops it before it is spoken.

Status: early development. The rule layer (banned terms, regex, personal data, India pack) and guard.check() are built. The Pipecat processor, classifier and LLM judge are next. See PLAN.md.

Quick start

Everything is opt-in: the guard only runs the rules you give it.

from pipecat_guardrails import Guard
from pipecat_guardrails.packs import india
from pipecat_guardrails.rules import PII, BannedTerms, pii

guard = Guard(
    rules=[
        BannedTerms(["acme corp", "globex"], id="no-competitors"),
        BannedTerms(
            ["dawai band kar do", "chinta mat"],
            id="no-medical-advice",
            word_pattern=india.hinglish_word_pattern,   # also matches "davai", "cheenta", ...
            variants={"dawai": ["दवाई"]},
        ),
        PII(pii.email(), pii.card(), india.aadhaar(), india.phone(), id="pii"),  # redacts
    ],
    fallback="Sorry, I can't help with that.",
)

verdict = await guard.check("Aap davaai band kar do.")
verdict.blocked     # True
verdict.text        # "Sorry, I can't help with that."
verdict.rule_ids    # ("no-medical-advice",)
  • Actions: each rule can block (speak the fallback instead), redact (replace the match, e.g. [phone number]), or flag (report only).
  • Opt out: pass enabled=False to a rule, or call guard.disable("pii") at runtime.
  • Shadow mode: Guard(..., mode="shadow") reports what it would do without changing anything, so you can try new rules on live traffic.
  • Errors: a rule that crashes fails closed (blocks) by default. Use on_error="allow" to fail open instead.
  • Custom rules: any function works:
    @rule(id="no-urls")
    def no_urls(text: str) -> bool:
        return "http" in text
    

Runnable examples, the same health bot in two languages: examples/whole_reply_english.py and examples/whole_reply_hinglish.py.

The problem

Pipecat has no built-in output guardrail, so every team writes its own processor between the LLM and the TTS. These homemade processors tend to break on user interruptions, keep speaking after a violation, let blocked text into the LLM history, and miss paraphrases and Hindi/Hinglish text.

This package will provide one processor you add to your pipeline:

pipeline = Pipeline([
    transport.input(), stt, context_aggregator.user(), llm,
    OutputGuardProcessor(guard),   # checks each sentence before it is spoken
    tts, transport.output(), context_aggregator.assistant(),
])

There will also be a plain await guard.check(text) for apps that run their own LLM loop.

See BEFORE_AFTER.md for a side-by-side comparison and PLAN.md for the design and roadmap.

Install

pip install pipecat-guardrails          # includes Pipecat
pip install "pipecat-guardrails[jev]"   # also installs the TypeSafe Jev classifier client

Requires Python 3.11+ and Pipecat 1.12 or later (installed automatically).

How checking works

Each sentence goes through up to three layers, and stops at the first one that is sure:

  1. Banned words, PII, regex: local and instant.
  2. Classifier model (optional), such as TypeSafe Jev: a fast yes/no model with an API key. A confident answer decides; an unsure one moves to layer 3.
  3. LLM judge (optional): any OpenAI-compatible LLM gives the final answer.

Layers 2 and 3 use Pipecat's own classifiers (pipecat.classifiers), so any classifier Pipecat supports works here.

Development

uv sync                      # create .venv with dev tools
uv run pytest                # tests
uv run ruff check .          # lint
uv run ruff format .         # format
uv run pyright               # type check
uv run pre-commit install    # run the checks on every commit

License

BSD-2-Clause, the same as Pipecat.

Metadata

Release files for pipecat-guardrails 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pipecat-guardrails 0.1.0
File Size Uploaded Provenance Actions
pipecat_guardrails-0.1.0.tar.gz 28.0 kB With provenance Details for pipecat_guardrails-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pipecat-guardrails 0.1.0
File Interpreter ABI Platform Actions
pipecat_guardrails-0.1.0-py3-none-any.whl Python 3 none any Details for pipecat_guardrails-0.1.0-py3-none-any.whl

Total release size: 54.1 kB

Release files / pipecat_guardrails-0.1.0.tar.gz

Download URL pipecat_guardrails-0.1.0.tar.gz
Size 28.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7052d9177fb6c6954855b27b75e7f697c3a9e20feefaf8bba1c0bb8b70957852
BLAKE2b-256 checksum
How to use checksums
bdad47afd7577ed3f770cefa01e4c7686276da5749dafacc0644e9097b4d6c7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Release files / pipecat_guardrails-0.1.0-py3-none-any.whl

Download URL pipecat_guardrails-0.1.0-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c172e1b5cacc3025c2f449891cda12a63650a9742d555026d2a5e37a4d91a684
BLAKE2b-256 checksum
How to use checksums
c7bd65a0c72336eb7a71ba978a38b05cd73e9d7b8b598317bb9e0fa2b2a94cc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

Security for pipecat-guardrails 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pipecat_guardrails-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page