Testing an LLM Guard deployment with promptfoo

A plan for measuring an existing LLM Guard deployment with promptfoo before you replace it, using a custom Python or HTTP provider, guardrail flags and a reusable test suite.

On this page

Testing an LLM Guard deployment with promptfoo before you replace it

If you run LLM Guard today, the first thing to establish is what it actually blocks and what it wrongly blocks, because the project is archived and no longer maintained. Its repository was archived by the owner on 9 July 2026, and the README states that the project and its Hugging Face models are no longer under active development. That means the scanner behavior you depend on will not receive fixes, and any replacement decision needs measured evidence rather than assumptions about how the scanners perform on your traffic. Before you change anything, confirm which LLM Guard version is pinned in your environment. The last PyPI release is 0.3.16, uploaded on 19 May 2025, and you should check that the deployed build matches it.

promptfoo has no built-in LLM Guard integration, so the documented route is a custom provider. The promptfoo Python provider documentation describes a Python provider, and the guardrail testing guide recommends a custom Python provider for guardrails without a built-in integration. Your provider can call the LLM Guard scanners directly as a Python library, or it can send requests to an LLM Guard API server through an HTTP provider. In either case, the provider should map each scanner verdict to a guardrail flag, so that a block is recorded as a guardrail decision rather than as a model answer. Decide early which scanners run on input and which run on output, since the inputs you pass in determine what each test actually measures.

Build the suite so it can outlive LLM Guard. Keep the attack set and the benign set as plain data files, record for each case which scanner fired and its score, and separate provider errors from genuine passes and blocks. Benign traffic matters as much as attacks here, because a scanner that blocks legitimate users is the failure you most need to measure before switching. Once the provider and datasets are stable, rerun the same suite against the replacement, such as a NeMo Guardrails configuration, so both systems are compared on identical inputs. Confirm with your security and product owners which false positive rate and missed attack rate are acceptable before you start, so the comparison ends in a decision.

What you need before wiring LLM Guard into promptfoo

Before writing a promptfoo provider, confirm the versions, runtime, scanner set and data your test will depend on. LLM Guard is archived, so each item below needs checking in your own environment, not just on paper. Get these right first and the test results will be comparable from one run to the next.

Pin the LLM Guard version

The last LLM Guard release on PyPI is 0.3.16, uploaded on 19 May 2025. Record the exact version you run in production, not the latest one you can install, because scanner behavior and default thresholds can differ between releases. Install the same pinned version in the test environment so a result from last month can be reproduced. Check whether your deployment runs LLM Guard as a Python library or as an API server, since that decides how the provider calls it.

LLM Guard on PyPI

Match the Python runtime

LLM Guard's last release requires Python 3.10 or newer but below 3.13. Confirm that your test runner, container image or virtual environment falls inside that range, and that the dependencies pulled in by your scanners install cleanly under it. Python 3.13 and later are outside the supported range for this release, so a newer default interpreter on a build agent can break the install without an obvious error.

Python range
3.10 to 3.13

Install a supported promptfoo

The promptfoo 0.124.1 release was published on 8 October 2026 and requires Node.js 22.22.0 or newer. Use a Node.js version that meets this floor on every machine that runs the suite, including CI runners. Check the release notes for changes before upgrading, because a promptfoo upgrade can alter how custom providers are loaded and how results are stored. Keep the promptfoo version in your test configuration so reruns use the same tool.

promptfoo on npm

Inventory the scanners in use

LLM Guard documents 15 input scanners and 20 output scanners. Your deployment probably enables only a subset, such as Prompt Injection, Secrets, Toxicity or Sensitive, each with its own threshold and settings. Write down every enabled scanner, its configuration and whether it runs on prompts or responses. Your test should map to that list, because a missing scanner in the inventory means a gap in coverage that no test will reveal.

Allow Hugging Face model downloads

Many LLM Guard scanners load models from Hugging Face on first use and cache them locally. Confirm that the test host, container or air-gapped network can reach the model hosts, or pre-download the model files into a mounted cache and pin their revisions. Without this, a test run can fail on a cold start or, worse, load a different model version than production uses. Record the cache location so both environments load identical weights.

LLM Guard documentation

Build a labeled attack and benign set

Create two datasets with ground-truth labels: adversarial prompts and outputs that the deployment should block, and legitimate requests that it should allow. Keep the labels, source and date of each case in the file so a flagged result can be traced back to its expected outcome. The benign set matters as much as the attack set, because it is how you measure wrongly blocked users. Store both sets under version control so the replacement guardrail is tested against the same cases.

Confirm availability in your environment

The archive notice means the project and its models will not receive fixes, so your team must confirm that the dependencies and model files still resolve in your environment. Check that the package index, model mirror and base images you use remain available, and keep a copy of the required artifacts in your own registry. Ask whether any security issue found during testing has a fix path, since none will come from upstream. Record this check as a dated step in the test plan.

How to configure the provider, flags and first run

This sequence turns an existing LLM Guard setup into a repeatable promptfoo test, where each scanner verdict becomes a guardrail flag that the suite can score. The output is a baseline eval run you can compare against later when you evaluate a replacement.

  1. Pin the test environment

    The engineer running the test installs promptfoo and the LLM Guard Python package into one isolated environment, pinning both versions so results stay comparable across reruns. Confirm the Node.js version promptfoo requires (the release notes state Node.js 22.22.0 or newer for the 0.124.1 npm release), and confirm the LLM Guard package version you have deployed, since the last PyPI release is 0.3.16 and requires Python 3.10 or newer but below 3.13. The step is done when both tools start from the command line and report the versions you recorded.

  2. Load the scanners your deployment uses

    Start from the scanner list in your production configuration, not from the full catalog. LLM Guard documents 15 input scanners and 20 output scanners, and a typical deployment enables a subset, such as Prompt Injection, Secrets or Toxicity on inputs and Sensitive or Malicious URLs on outputs. Record each enabled scanner with its settings and threshold. The check is a short script that loads the same scanner objects your application loads and prints their names and thresholds, which should match your deployed configuration exactly.

  3. Write the Python provider

    Create a Python provider file that accepts a prompt, runs the input scanners, forwards the prompt to the target only if no input scanner rejects it, and then runs the output scanners on the response. If your deployment calls the LLM Guard API server instead of the library, the provider sends the same two requests over HTTP. The provider is written by your engineers or the DeployOpen team, and the check is a direct call on one known prompt from your own environment, confirming the provider returns a response object without errors.

  4. Map scanner verdicts to guardrail flags

    Each scanner returns a validity result and a risk score. In the provider response, set a guardrail flag for every scanner that marks the output invalid, and record the scanner name so a failed test shows which filter acted. Keep the mapping in one table so that a later replacement guardrail can be mapped the same way. The check is a unit test with one prompt the scanner should reject and one it should accept, confirming the flag appears only in the first case and names the expected scanner.

  5. Point the config at the target application

    In the promptfoo configuration file, reference the Python provider and the application under test, with the prompt variable and any system prompt your application uses. Keep the target application and the guard in the same order they run in production, so the test reflects the real path. Confirm the configuration parses by running promptfoo's config validation or a dry run, and check that the target responds to one plain request.

  6. Confirm a known attack is flagged and a benign prompt passes

    Before building the full dataset, run two anchor cases: one prompt you know your guard should block, such as a clear injection string, and one ordinary business question. The attack case must show a guardrail flag naming the expected scanner, and the benign case must return the normal application answer with no flag. If either anchor fails, fix the provider or the mapping before continuing, because every later result depends on these two behaviors being correct.

  7. Run the baseline eval and record results

    Run the full suite once against the current deployment and save the output, including the flag count, the number of blocked benign prompts and any provider errors reported separately from passes. This run is the baseline that the replacement guardrail will be measured against. Store the configuration, scanner settings and package versions with the results so the run can be reproduced. The step is done when the baseline file exists and an identical second run gives the same flags for the same inputs.

How a test request flows through the provider to LLM Guard

The flow starts in the promptfoo runner on the test host, which sends each attack or benign prompt to a custom Python or HTTP provider. The provider calls the LLM Guard input scanners first. If no input scanner blocks the prompt, it goes to the application or model under test, and the response passes through the output scanners. The provider then returns a result to promptfoo that records the blocking scanner and its score as a guardrail flag. Check that the trust boundary matches where your LLM Guard runtime actually runs.

Test requests crossing from the promptfoo host into the LLM Guard runtime.

How LLM Guard scanner results map to promptfoo fields

This table shows how each LLM Guard input and output scanner result should be recorded in promptfoo as a guardrail flag, a reason, and the attack or benign label in your dataset. Read it as a mapping to confirm against your own scanner configuration and the provider response shape in the promptfoo Python provider documentation before you build the wrapper. The main takeaway is that a block must be counted only when the scanner's own verdict is captured, so each scanner needs its own flag and reason rather than one generic pass or fail.

ScannerFlag and reason to recordDataset label to pair it withWhat to confirm
Prompt Injection (input)Flag as guardrail block when the scanner marks the prompt invalid; record its risk score as the reasonAttack rows from injection sets; benign rows should not triggerThreshold setting used in your config
Secrets (input)Flag block and record the secret type detected, without storing the secret valueAttack rows containing planted test credentialsWhether redaction replaces the value before the model sees it
Ban Topics (input)Flag block and record the matched topic labelOff-topic attacks; benign rows on allowed but nearby topicsTopic list and wording matches your policy
Toxicity (input and output)Flag block and record the toxicity scoreAbusive attack rows; benign rows with strong but acceptable languageScore cutoff, which drives false positives
Invisible Text (input)Flag block and record that hidden characters were foundAttack rows with zero-width or control charactersWhether the scanner strips or only reports the characters
Token Limit (input)Flag block and record the token count against the limitOversized attack rows; benign rows near the limitTokenizer used, which changes counts
Anonymize (input)Record redacted entities as metadata; flag only if the request is rejectedBenign rows with personal data expected to pass after redactionWhether your app expects a rejection or a sanitized prompt
Malicious URLs (output)Flag block and record the URL category returnedOutput rows containing unsafe links; benign rows with normal linksWhether lookups run offline or call external services
Sensitive (output)Flag block and record the entity type found in the responseResponses seeded with test personal or secret dataEntity list enabled in your scanner setup
Factual Consistency and No Refusal (output)Record the score as a reason; treat as a quality signal, not a block, unless configured otherwiseGrounded benign answers; adversarial rows designed to force refusalsWhether your application uses these scores to block
Errors and timeouts (any scanner)Record as error, separate from pass and blockAny row; exclude from block ratesHow the provider reports exceptions in your wrapper

Reusing the suite when you test a replacement guardrail

The simplest reuse keeps the entire suite as it is and changes only the providers entry. The attack dataset, benign dataset, assertions and grading stay in place, so the replacement is measured against the same questions the existing LLM Guard setup answered. This works well when the replacement exposes a similar decision, such as blocked or allowed, that the Python or HTTP provider can translate into the same flag format.

  • Freeze the datasets: Store the attack and benign files under version control and reference them by hash or tag, so both runs read identical prompts.
  • Keep the flag mapping: Map each replacement signal (for example, a block verdict or a category label) to the same flag names used for LLM Guard, and check that mapping with a few known prompts before the full run.
  • Match the assertions: Use the same not-guardrails or guardrails assertions on both runs so pass and fail counts mean the same thing.
  • Record provider errors separately: Timeouts and authentication failures from the new service should not count as blocks or passes.
  • Keep the grading identical: Any judge model or rubric should be unchanged between runs.

Before trusting the comparison, confirm with the replacement vendor exactly what its API returns when it blocks, because some services return a status code, others a metadata field, and some only a rewritten output.

Securing the test harness and the scanner runtime

The promptfoo harness that wraps your LLM Guard scanners holds credentials, sends prompts and stores responses, and the scanners themselves load third-party models. Each card below covers one place where that setup can leak data or run untrusted code, and what to check before the suite is trusted with production-like traffic.

Keep keys out of configs

Your promptfoo config and the Python or HTTP provider files that call LLM Guard should read API keys and application tokens from environment variables or a secrets manager at run time. Avoid hardcoding them in promptfooconfig.yaml or committing .env files to the repository. Check that CI logs do not echo provider settings, and rotate any key that has appeared in a shared config or chat thread.

Run scanners where you control them

Host the LLM Guard scanners as a library inside your provider process or as an API server in a network you operate, so test prompts never leave your environment. Confirm which scanners call external services at run time, since some depend on models fetched from Hugging Face. Write down the host, network path and egress rules for the scanner runtime before the first benign dataset is sent through it.

Restrict stored prompts and responses

Attack datasets, benign customer-style prompts and scanner outputs can contain personal data, secrets or sensitive examples, and promptfoo keeps results for review. Store eval output on an encrypted volume with access limited to the testing group, and decide how long results are kept. Redact or synthesize sensitive fields in test cases so the evidence file does not become a copy of production data.

Pin dependencies in an archived project

The LLM Guard repository was archived by its owner, so it will not receive fixes for vulnerabilities or breaking changes in its dependencies. Pin the exact llm-guard version, the Python interpreter and the scanner models in a lock file, and build the runtime image once. Record the promptfoo version as well, and review the pins before each suite run because a rebuild can silently pull new transitive packages.

llm-guard on PyPI

Verify model downloads before use

LLM Guard scanners download model weights the first time they run, and those files are code-adjacent input your process will load. Fetch them from a pinned revision, compare checksums against values you recorded during a review, and load them in an isolated environment without credentials. Keep a local mirror of approved models so a later change in the upstream repository cannot alter scanner behavior between test runs.

Limit who can change the suite

A change to a guardrail threshold, a scanner list or an assertion can make a failing guardrail look like it passes. Limit write access to the promptfoo config and scanner code, require review for changes to expected-block labels, and keep the git history as the audit trail. Because the self-hosted promptfoo server has no built-in authentication or RBAC, put it behind your identity layer or keep it off shared networks.

Why LLM Guard tests fail or give misleading results

This table lists the failures that most often break or distort an LLM Guard test run with promptfoo, with the cause and fix for each. Read it before the first run, and again whenever results change without a change to the application. The main takeaway is that a pass is only meaningful when the scanner ran cleanly and its decision was recorded as a guardrail flag.

FailureLikely causeFix
Install fails on Python 3.13 or newerThe last PyPI release, 0.3.16, requires Python 3.10 or newer but below 3.13Pin a supported Python interpreter in a dedicated virtual environment and confirm it before installing
Model download fails at first scanScanners fetch models from Hugging Face on first use, and the project's models are no longer maintainedPre-download the models in a controlled environment, mirror them internally and record the versions used
Scanner errors counted as passesA wrapper returns a safe result when the scanner raises an exception or times outMap errors to a separate error status in the provider, and exclude them from pass rates
Provider exceptions mixed with guardrail decisionsHTTP timeouts, 500 responses or Python tracebacks are reported as blocks or allowsReturn a distinct error output and keep guardrail flags only for scanner verdicts
Flag mapping drifts between runsScanner names or output keys change between versions, or the wrapper maps labels by positionMap flags by explicit scanner name, store the mapping in version control and fail on unknown keys
Threshold defaults change after an installA reinstall or a new environment loads different default thresholds for scanners such as Prompt Injection or ToxicitySet every threshold explicitly in configuration and record it in each run's report
Results differ between machinesDifferent package versions or model files are installed on each machine or CI runnerLock package versions and model revisions, and run the same image in every environment
Suite passes after the scanner is removedThe test asserts only that the application responds, not that the scanner made a decisionAdd guardrail assertions for expected blocks and not-guardrail assertions for benign prompts

Questions teams ask before testing LLM Guard

Does promptfoo have a built-in LLM Guard connector?

No, promptfoo does not ship a built-in LLM Guard connector. The promptfoo guardrail testing guidance recommends a custom Python provider for guardrails without a built-in integration, so the usual approach is to wrap LLM Guard's scanners or its API server in a Python or HTTP provider. That wrapper calls the scanners, maps each block to a guardrail flag, and returns the result to promptfoo, which then grades it with the same assertions you use for other guardrails. Because you write the wrapper, the mapping of scanner verdicts to flags is a design decision you own and should document, including which scanners run on inputs and which on outputs. Check the promptfoo Python provider documentation for the current provider interface before you start.

How much effort does testing an LLM Guard deployment take?

The effort depends on four drivers: how many scanners are enabled, how much labeled data you have, how much runtime setup is needed, and how far the versions are pinned. LLM Guard documents 15 input scanners and 20 output scanners, so a deployment that enables many of them needs more mapping work and more test cases per scanner than one that enables a few. Labeling attack and benign examples is usually the largest task, because each example needs a clear expected outcome. Runtime setup covers Python 3.10 to below 3.13, model downloads and hosting the API server. Ask any partner for a written estimate that breaks these four drivers out separately, and ask which of them they have assumed.

What does our team need to supply for the work?

Three things are needed before work starts. First, labeled data: attack prompts and benign prompts with the expected result for each, drawn from traffic that resembles your real users. Second, a running scanner environment: a Python environment or LLM Guard API server that you can reach from the test runner, with the scanner configuration you use in production written down. Third, owners for decisions: someone who can say whether a block is correct, what false positive rate is acceptable, and what happens when a scanner's output is ambiguous. Without the third item, test results will be accurate but nobody will be able to act on them. Confirm access and data handling rules with your security team before any prompts leave your environment.

Can our own team test LLM Guard without outside help?

Yes, a team with Python experience and access to the LLM Guard setup can build the provider and the first suite internally. The harder parts are usually not the code. They are labeling the datasets consistently, agreeing on what counts as a correct block, and keeping the runtime pinned so that results can be compared over time. Teams that test internally often underinvest in the labeling step and then cannot tell whether a change improved detection or just changed the sample. If you do it yourself, write down the scanner versions, the thresholds and the label rules in the repository from day one, and have a second person review a sample of labels.

Should we replace LLM Guard now that it is archived?

The archive notice is a strong reason to plan a replacement, but it does not require replacing LLM Guard on a fixed date. The project was archived by its owner on 9 July 2026, and its README states that the project and its Hugging Face models are no longer under active development or maintained. That means no new security fixes or model updates should be expected. DeployOpen does not recommend new LLM Guard rollouts. For an existing deployment, the practical sequence is to measure it with a promptfoo suite now, record the baseline, then use the same suite to test a maintained alternative such as NeMo Guardrails before cutting over. Keeping the suite is the part that makes the migration safe.

Is promptfoo itself licensed for this work?

promptfoo is licensed under the MIT license, and the Community edition is free and includes all LLM evaluation features, all model providers and integrations, and red teaming with 10k probes per month. Running a custom provider that calls LLM Guard does not require a paid promptfoo edition. LLM Guard is also MIT licensed, according to its README. Review both licenses with your legal team, and note that any model downloads or third-party services your scanners call may carry their own terms. Confirm these details against the current promptfoo pricing page before you rely on them.

How do we keep the test suite useful after the migration?

Treat the suite as an asset that outlives LLM Guard. Store prompts, expected outcomes and the provider wrapper in version control, and keep the scanner names and versions recorded with each run. Once you move to a replacement, implement a second provider for it and run the same datasets, so the two results can be compared directly. Ask any partner how they will hand over the suite, including the label documentation, and who will maintain it after the engagement ends. DeployOpen offers ongoing support and continuous testing as retainers, and those terms are set out in writing for each scope.

Moving from LLM Guard to a maintained guardrail

No new LLM Guard rollouts are recommended, because the project was archived by its owner on 9 July 2026 and the README states it is no longer under active development or maintained. The purpose of this section is narrower: keep an existing deployment safe while you plan the move. A maintained option such as NeMo Guardrails is a reasonable candidate, and you should evaluate it with the same promptfoo suite you used to measure LLM Guard, so both sets of results are comparable. Start by listing which of the 15 input and 20 output scanners your application actually depends on, since not every scanner carries the same business risk.

Rank scanners by consequence. A missed Prompt Injection or Secrets detection on a tool-using assistant usually matters more than a Ban Topics miss on a marketing chatbot. For each high-risk scanner, record the attack and benign datasets, the thresholds in use, and the block and pass outcomes from your current runs. Retain these as audit evidence: the promptfoo results files, the configuration that produced them, the LLM Guard version (0.3.16, uploaded 19 May 2025, is the last PyPI release) and the Python environment it ran in. Confirm with your compliance team how long these records must be kept and in what form, because they describe the controls that were in force before the change.

Set the cut-over point in writing before the replacement is tested. A reasonable condition is that the candidate matches or beats the current scanner on each high-risk dataset, with its false positives on benign traffic within a threshold your business owners approve. Run both configurations in parallel for a period you agree with them, and keep LLM Guard in place until the evidence is accepted. Also confirm that the candidate's license, hosting model and dependencies fit your infrastructure, and that you have a rollback plan that does not depend on an unmaintained component.

How DeployOpen scopes and delivers LLM Guard testing

DeployOpen approaches testing an LLM Guard deployment with promptfoo as a fixed-scope piece of work. We agree in writing which scanners, API endpoints and applications are in scope, build the promptfoo provider and test suite around that setup, and hand over a suite your team can run and extend, since LLM Guard itself is archived and no longer maintained.

How we scope

  • Inventory which LLM Guard scanners, input or output, your applications actually call, and whether they run as a Python library or an API server.
  • Agree the attack and benign datasets, the blocked-request categories to record as guardrail flags, and the pass criteria before any test is written.
  • Confirm the replacement candidate, if one is chosen, so the suite can be reused against it without rework in the written scope.

How we build

  • Wrap the existing LLM Guard setup in a promptfoo Python or HTTP provider, following promptfoo's guardrail testing guidance for integrations without a built-in provider.
  • Map each scanner decision to a guardrail flag, so blocks are recorded separately from model failures and errors are reported apart from passes.
  • Build assertions for guardrails and not-guardrails cases, and version the configuration files so results can be reproduced.

How we hand over

  • Deliver the provider code, promptfoo configuration, datasets and a short run guide that your engineers can execute in their own environment.
  • Document the baseline results, the known false positives and missed attacks, and the open questions to confirm with your security team.
  • Provide a written note on how to point the same suite at a maintained guardrail, so the replacement can be compared on equal terms.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer, scoped separately from the initial engagement.
  • Support can cover updates to promptfoo versions, changes to scanner configuration and re-running the suite after a guardrail change.
  • Ask for the support boundaries, response expectations and who owns the datasets in your quote before work starts.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.