Open-source alternative to Lakera prompt defense

Self-hosted NeMo Guardrails and Guardrails AI can replace Lakera Guard's prompt attack detection, but detection quality must be measured on your own traffic before you switch. This page shows how.

On this page

Open-source alternative to Lakera Guard prompt defense: the short answer

If your team holds a Lakera Guard contract and needs prompt attack defense to stay inside your own infrastructure, the two main open-source options are NVIDIA NeMo Guardrails and Guardrails AI, both Apache-2.0 licensed. Neither is a drop-in replacement: neither ships a managed, continuously updated attack classifier the way Lakera's hosted policy service does. NeMo Guardrails includes jailbreak and injection detection as part of a dialog framework that you configure in Colang, while Guardrails AI assembles validators from Guardrails Hub into input and output guards that you chain into an API. Which one fits depends on whether you want rails wrapped around conversation flows and tool calls, or discrete validators you can call from existing services.

Before choosing, decide what you are replacing. Lakera's value is mostly detection quality maintained by a vendor, so with either open-source option your own engineers take on model selection, threshold tuning, false positive review and ongoing attack testing. Confirm with each vendor which detection models run locally, which call external services, and what hardware they need, and check the current release notes before you pin a version. Note also that LLM Guard is archived, so it should be excluded from any new rollout.

Treat measured testing as a precondition for enforcement, not a later step. Record real traffic through both the current control and the candidate, compare verdicts, and run a red-team suite such as promptfoo against the candidate to measure how often known injection and jailbreak patterns get through. Only move the candidate into blocking mode once false positives and missed attacks are both within the thresholds your security and product owners have signed off.

Which Lakera prompt defense capabilities map to which open-source options

This table maps the main Lakera Guard prompt defense capabilities to NeMo Guardrails and Guardrails AI with Guardrails Hub validators, and lists the gaps each option leaves. Read it as a starting inventory for a proof of concept, not as a parity claim, because detection quality for attacks, harmful content and leakage must be measured on your own traffic.

Lakera capabilityNeMo GuardrailsGuardrails AI with Guardrails HubGap to verify
Prompt injection and jailbreak detectionJailbreak and injection detection is included in the library, configured as input rails in ColangValidators must be chosen and installed from Guardrails Hub; coverage depends on which validators you addDetection rate on your attack corpus, false positives on legitimate prompts, and who retunes models after new attack patterns
Harmful content moderationSelf-check input and output moderation, NVIDIA content safety and topic safety models are includedToxicity and similar validators are available on Guardrails Hub, installed separatelyCategory coverage against your policy, multilingual behavior, and the model or validator version you pin
Data leakage and PII checksNo dedicated PII rail is confirmed in the library; output rails can call custom actions or third-party integrationsRegex matching and other validators can be chained to catch patterns such as identifiersWhether PII detection meets your data classes; regex alone usually misses context-dependent leaks
Policy configurationRails are written in Colang, versioned as files alongside application codeGuards are defined in Python and validators are chained in code or configurationWho writes and reviews policy changes, and how changes are tested before release
Central policy consoleNot included; configuration is files loaded by a guardrails serverNot included; a standalone REST service loads guards, with no management console describedWhether you need a shared dashboard, and the cost to build or buy one
API integrationPython API or a guardrails server with an HTTP API and provided DockerfileStandalone Flask REST service started with guardrails start, called through the OpenAI SDKLatency added per call and the sizing of CPU or GPU capacity for detection models
Structured output validationNot a core focus of the libraryGenerates output matching Pydantic models, a capability Lakera Guard does not coverOnly relevant if your application needs typed output; treat it as an addition, not a replacement
Vendor-maintained detection updatesNVIDIA publishes releases, but detection model updates must be checked per releaseValidators are community and contributed; maintenance varies by validatorOwnership of updates, and a retest after every library or model change

NeMo Guardrails or Guardrails AI: which fits which prompt defense job

Both libraries are Apache-2.0 and can run in your own infrastructure, but they solve different parts of prompt defense. NeMo Guardrails controls conversation flow and detects jailbreaks and injections through rails, while Guardrails AI checks and shapes individual inputs and outputs with validators. Read each card against the attack types, runtime and team skills you actually have.

NeMo Guardrails for rail-based control

NeMo Guardrails configures input, dialog, retrieval, execution and output rails in the Colang language, and its library includes jailbreak and injection detection. It fits teams that need to govern a whole conversation flow, including what the model may discuss and which tools it may call. The trade-off is Colang learning effort, which your engineers must absorb before rails are reviewable by security staff. Confirm the detection models and their GPU or CPU needs in your environment before sizing.

Current release
0.25.0
NeMo Guardrails docs

NeMo Guardrails runtime requirements

NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, so the host image and dependency pins must match before any rollout. It can run through its Python API or as a guardrails server that loads configuration from a folder and exposes HTTP, with a Dockerfile provided for a server image. Check that your platform team can supply that Python version and a container build pipeline. Plan the migration from LLMRails to Guardrails, since the older class is deprecated in this release.

Python versions
3.11 to 3.13

NeMo Microservices sunset and the Helix path

NVIDIA has sunset the NeMo microservices, and the NGC container for the guardrails microservice is no longer supported with no new releases. Do not build a new deployment on that container. NVIDIA's archived notice points existing users to their account team and to NeMo Platform, and the repository it links now resolves to NeMo Helix, which runs NeMo Guardrails as an inference gateway plugin. Before choosing this path, confirm with NVIDIA whether the library or the Helix plugin is supported for your use case.

NeMo sunset notice

Guardrails AI validators from Guardrails Hub

Guardrails AI builds guards from validators such as regex matching or toxicity detection, installed separately from Guardrails Hub and chained together. It fits teams whose main risks are format, data leakage patterns and content checks on specific fields. The trade-off is testing burden: each validator and each chain needs its own test cases, and coverage against prompt injection depends on which validators you select and maintain. Ask which validators you will own, who reviews updates, and how false positives are measured.

Guardrails AI REST service and structured output

Guardrails AI can run as a standalone Flask REST service started with the guardrails start command and called through the OpenAI SDK, which keeps the guard outside application code. It also generates structured output that matches Pydantic models, using function calling or prompt optimization. This suits applications that already return typed data and need the output validated before use. Confirm during setup that anonymous metrics reporting, which the configure step asks about, is set the way your data policy requires.

Guardrails AI quickstart

Testing detection before you switch

Whichever library you choose, measure its verdicts on your own traffic and on attack sets before enforcing them. promptfoo is MIT licensed, runs locally, and covers red teaming against the OWASP LLM Top 10, the NIST AI Risk Management Framework and the EU AI Act references. Run the same probes against each candidate and record false positives on legitimate prompts. Ask your red team to confirm coverage of injection through retrieved content and tool outputs, not only direct prompts.

promptfoo red teaming

Why NVIDIA's NeMo microservice sunset changes the plan

The NeMo Guardrails microservice container in the NVIDIA NGC catalog is sunset as of October 1, 2026, with no new releases and no continued support for the artifact. If your plan was to pull that container and run it as a black box behind your gateway, that plan no longer holds. NVIDIA's archived NeMo Microservices documentation says all new development has moved to NeMo Platform and asks existing users to contact their NVIDIA account team to discuss next steps. Treat that account team conversation as a dependency you must close before go-live, not as a formality.

The NeMo Platform repository linked from that sunset notice now resolves to NVIDIA-NeMo/nemo-helix, an Apache-2.0 control plane. Its documentation runs NeMo Guardrails as an inference gateway middleware plugin that applies guardrail configurations to model endpoints. That is a different deployment shape from the library or the guardrails server, with its own control plane to operate. Before you commit to it, confirm with NVIDIA whether the plugin covers the jailbreak and injection rails your threat model needs, and which release cadence they will support.

The safer path is to build on the artifacts you control. Pin the nemoguardrails Python package at a specific release, which is Apache-2.0 and still published by NVIDIA, or build your own server image from the Dockerfile in the open-source repository. Keep your Colang configurations in version control so the rails, not the container, are the reviewed asset. Ask NVIDIA in writing which release line will receive security fixes and how long it will be maintained. The answer determines how often your team must retest after upgrades and whether a Guardrails AI validator layer is needed as a second opinion.

How to measure prompt defense with promptfoo before switching

This sequence gives you a local, repeatable way to compare Lakera's verdicts with a candidate open-source guardrail on the same prompts, so the switch rests on measured false positives and misses rather than vendor claims. The output is a reviewed comparison you can take into a security review.

  1. Install promptfoo on your own machine

    An engineer on the security or platform team installs the promptfoo CLI, which is MIT licensed and requires Node.js 22.22.0 or newer, using npx promptfoo or a global npm install. Run the evals from a workstation or a CI runner you control, because promptfoo runs completely locally and talks directly with the model endpoints. You know the step is done when promptfoo --version returns a version on that machine and a sample config runs to completion.

  2. Define the target application as a provider

    Write a promptfooconfig.yaml that points a provider at the application under test, including the path where prompts reach your model gateway and, for the candidate, the NeMo Guardrails or Guardrails AI endpoint in front of it. Keep the system prompt, tools and model identical across both arms so only the guardrail differs. Done means a dry run sends a test prompt through each provider and returns a response from each.

  3. Run red-team probes mapped to recognized frameworks

    Run promptfoo's red-team generator against the target so it produces attack probes for prompt injection, jailbreaks and data exposure. Tag the results against the OWASP LLM Top 10 categories and keep a mapping to the NIST AI Risk Management Framework and the EU AI Act, which promptfoo's red-team documentation names as supporting systematic testing before deployment. Confirm with your compliance lead which framework mapping your assessors expect, since the mapping is your evidence, not a certification. Done means each probe carries a category tag and a pass or fail result.

  4. Record Lakera and candidate verdicts on the same prompts

    Replay one fixed prompt set through Lakera Guard and through the candidate guardrail, saving each verdict, the category returned and the final model response side by side. Use the same prompts, the same ordering and the same model so differences come from the detectors. Store the raw verdicts with timestamps so the comparison can be rerun. Done means every prompt has a Lakera verdict and a candidate verdict in one results file.

  5. Compare false positives and misses

    Group the results into four outcomes: both block, both allow, Lakera blocks and the candidate allows (a candidate miss), and the candidate blocks and Lakera allows (a candidate false positive or a new block). Review each disagreement by hand with an engineer and a security reviewer, because automated labels can be wrong on borderline prompts. Done means every disagreement has a reviewed label and a decision on whether to tune the candidate's rails or validators.

  6. Decide where the self-hosted app fits

    The promptfoo self-hosted app is an Express server that uses a local SQLite database that cannot be shared across replicas, has no RBAC, horizontal scaling, built-in authentication or SSO, and is not recommended for production use. Use it, if at all, only as a single-user review tool. For shared, multi-user use, plan for promptfoo Enterprise or On-Premise, and ask the vendor for its current feature list and pricing in writing. Done means the team has written which environment holds the evaluation records and who can access them.

  7. Confirm OpenAI ownership implications for governance

    OpenAI acquired promptfoo, announced on 9 March 2026, and the founders state that promptfoo will remain open source and continue to support a diverse range of providers and models. Before adopting it as a control in your assessment, ask your legal, procurement and governance owners to confirm what the acquisition means for data handling, license terms, roadmap and vendor dependency in your environment. Record the answer in the evidence file. Done means the governance owner has signed off on the tool and the decision is documented.

Where the guardrail sits between the user, the model and the red-team harness

The request starts with a user and enters the application inside the organization's trust boundary. The application passes the prompt to an input rail (NeMo Guardrails or Guardrails AI), and only allowed prompts reach the LLM call. The response then passes an output rail before it returns to the user. A separate promptfoo harness replays recorded traffic and red-team prompts against the same guard, so you can check verdicts before and after any switch.

Guardrails sit on both sides of the model call, with the red-team harness testing the same input rail.

How the setup differs for cloud, on-premises and air-gapped teams

Cloud teams usually package the guardrail service as a container and run it beside the application in an existing cluster. Both NeMo Guardrails and Guardrails AI can be built into an image, so the service follows the same build, scan and deploy pipeline as other workloads. Traffic to the guardrail stays inside the cluster network, but any model endpoint or external validator the rails call still determines where prompts travel.

  • Build your own image: Use the Dockerfile in the NeMo Guardrails repository to build a server image in your own registry. NVIDIA has sunset the NeMo microservices container on NGC, so do not base the plan on that artifact.
  • Pin the Python version: NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, so the base image and build tooling must match one of those versions.
  • Manage configuration as code: Keep Colang and YAML configuration in a ConfigMap or a versioned volume so every rail change goes through review and has a history.
  • Set egress rules: Restrict outbound traffic from guardrail pods to the endpoints you have approved, and confirm where any hosted classifier or validator call is sent.
  • Size replicas by measured latency: Guardrails AI runs as a REST service, so set the replica count from load tests against your own prompts.

Confirm with your platform team which namespace, secret store and network policy the guardrail service will use before you write the Helm chart or manifests.

What buyers ask before replacing Lakera prompt defense

How much total effort does replacing Lakera prompt defense take?

The effort depends on how many applications call Lakera, how many detection paths you must cover, and how much red-team evidence your reviewers expect. The work splits into four parts: selecting detection rails or validators, deploying a self-hosted server, building side-by-side comparisons on recorded traffic, and testing the new controls before enforcement. Lakera's own pricing is not something this page can quote, so use your current contract as the baseline. Ask for a written scope that lists each application, each rail type (input, output, retrieval or execution), and the test cases each one must pass before switching.

What recurs after a NeMo Guardrails or Guardrails AI rollout?

Three things recur. First, detection tuning: false positives and missed attacks change as your prompts, users and models change, so someone must review verdicts and adjust thresholds or validators. Second, library upgrades: NeMo Guardrails 0.25.0 deprecates the LLMRails class in favor of Guardrails, with removal planned no earlier than 0.27.0, so configurations need migration work on a schedule you set. Third, red-team retesting after each model, prompt or rail change, using tools such as promptfoo. Ask a provider to state which of these is included in a fixed-scope project and which moves to a retainer.

What drives the cost of a self-hosted guardrail up or down?

Four factors move the cost most. Traffic volume determines how many checks run per request and how much compute the server needs. Latency targets decide whether detection models can run on CPU or need GPU capacity, and whether checks run in series or in parallel with the model call. Model choice matters because some NeMo Guardrails detection models are heavier than rule-based validators in Guardrails AI. Finally, the number of applications and environments multiplies the testing and monitoring load. Request load tests at your expected peak traffic before accepting a sizing estimate.

Can our internal engineers replace Lakera prompt defense without outside help?

Yes, if your team has Python, container and security testing skills and time to own the rails after launch. NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, and Guardrails AI can run as a REST service started with guardrails start, so the deployment path is standard. The harder part is detection quality: writing Colang flows or validator chains, choosing thresholds and proving the results to a security review. Teams without that testing capacity often bring in an implementation partner for the first rollout and keep the operation in-house. Decide which side of that line your team sits on before you commit to a date.

How long does it take to get a first side-by-side comparison?

The first comparison depends on how quickly you can export representative traffic, stand up a self-hosted guardrail server and agree on what counts as a correct verdict. No supplied source gives a timeline, so treat any date as something to confirm in writing. Start by recording a sample of real prompts with their Lakera verdicts, label a set of known attacks and benign prompts, then run both systems on the same inputs. Ask any provider for the duration of each step and what they need from your side, such as data access approvals and test environments.

Why is archived LLM Guard not a target for a new rollout?

LLM Guard is no longer a sound choice for new rollouts because it is archived, which means it no longer receives maintenance for new model or attack patterns. Start new work on NeMo Guardrails, which is Apache 2.0 licensed and still receives releases such as 0.25.0 published on November 19, 2026, or on Guardrails AI, which is Apache-2.0 licensed with v0.11.0 published on August 14, 2026. Confirm the current status of any archived project with its repository before you rely on it.

What should we ask for in a quote for this replacement?

Ask for a written scope that names every application, rail or validator type, deployment target and test case. Require line items for deployment, Colang or validator configuration, the side-by-side comparison on recorded traffic, red-team testing with promptfoo or a similar tool, false-positive tuning, and knowledge transfer. Separate one-time work from recurring work such as tuning, library migrations and retesting. Ask how the provider handles data, where tests run and who keeps credentials. DeployOpen does not publish a price list, and a quote follows from the written scope.

Does promptfoo replace the need for a guardrail?

No. promptfoo measures how well your defenses work, while NeMo Guardrails or Guardrails AI enforce policy at runtime. promptfoo runs evals and automated red teaming locally, and its documentation references the OWASP LLM Top 10, the NIST AI Risk Management Framework and the EU AI Act for systematic testing. Its Community edition is free and includes red teaming with 10k probes per month. The self-hosted app uses a local SQLite database that cannot be shared across replicas and has no RBAC or SSO, so plan a different setup for production team use.

Running the guard alongside the rest of your AI stack

The guard is only useful if its verdicts reach the same place as the rest of your LLM traffic. Decide where enforcement happens before you write any integration code. In most designs the guard runs as a separate service that the application or the gateway calls before a prompt reaches the model and again before a response goes back to the user. Whichever layer makes the call, confirm that a blocked request returns a controlled response and never silently passes through, and that a failure of the guard service has a defined behavior (fail closed for high-risk routes, fail open only where your risk owner has accepted it in writing).

Your gateway is the natural place to attach the guard without changing every application. If you run LiteLLM, its self-hosted proxy can log requests to Langfuse, Opik, OpenTelemetry or Prometheus, so you can keep guard verdicts in the same trace as the model call they belong to. Confirm with your platform team which fields the guard response exposes (verdict, rule or validator name, score, input or output side) and map each one to a trace attribute. Do the same for Portkey if it is your gateway. Treat the gateway's own logging settings as part of the design: a trace that stores raw prompts also stores any sensitive data the guard was meant to catch, so set redaction rules for stored content before you turn on full payload logging.

Log every guard verdict as an audit record, not only as a debugging aid. For each decision, keep a timestamp, the calling application and user or service identity, the model route, the guard configuration version, the rule that fired and the action taken (allowed, blocked or modified). Store the configuration version alongside each verdict, so an auditor can reconstruct which rails or validators were active on a given date. Confirm your retention period and access controls for these records with your compliance team, and check whether your Langfuse or Opik deployment will hold them in a store your existing log governance already covers.

How DeployOpen scopes and delivers a prompt defense replacement

DeployOpen plans, implements, tests and hands over self-hosted prompt defense inside your own infrastructure, so guardrails run where your security team can review them. Engagements start with a written scope that fixes the detection targets, deliverables and timeline before any work begins.

How we scope

  • Inventory every LLM endpoint and agent that currently calls Lakera Guard, including which input and output checks each one uses
  • Agree in writing which attack classes, such as jailbreaks and injections, the replacement must cover and which gaps are accepted
  • Confirm the hosting target, Python version, GPU or CPU capacity and network boundaries before choosing NeMo Guardrails or Guardrails AI
  • Define the red-team test set and pass criteria that will decide the cutover, and confirm that no archived LLM Guard component is selected

How we build

  • Deploy the chosen guardrail framework in your environment, with configuration files versioned in your own repository
  • Map existing policies to input, output and execution rails or chained validators, and document every rule and its owner
  • Run the candidate guardrails beside current traffic in a test setting, then tune false positives against recorded prompts and responses
  • Test the rails with promptfoo and other agreed tools, and record results so the cutover decision rests on measured detection

How we hand over

  • Deliver written documentation covering architecture, configuration, model and dependency versions, and the operational runbook
  • Provide the red-team report with findings, fixes and a retest of each fixed issue, so your security team can review the evidence
  • Train your platform and security engineers to change rules, add validators and read guardrail logs
  • Prepare the control and evidence material your compliance team needs for internal reviews, without issuing any audit or certification

How we support

  • Engagements are fixed-scope, and scope, deliverables and timelines are agreed in writing before work starts
  • Ongoing support, framework upgrades and continuous red-team testing are available as a retainer after handover
  • Ask any quote to itemize implementation, testing, model hosting, and retainer work, so you can see which parts recur
  • Confirm with the framework maintainers and your own engineers which release, licensing and support terms apply to your deployment

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.