Open-source alternative to Portkey Guardrails: the short answer
If you are replacing Portkey Guardrails because of a plan change, a tier gap between Basic, Partner and Pro checks, or a rule that prompts and responses must stay inside your network, plan around NeMo Guardrails as the maintained open-source option. Guardrails AI is a validator-based alternative that fits teams who want to assemble checks from individual validators, and LLM Guard is archived, so it should only be considered for keeping an existing deployment running while you move off it. Portkey's AI Gateway is itself MIT licensed and can run in your own infrastructure, but the guardrail tiers are tied to Portkey plans: the Developer plan gets basic guardrails only, the Production plan adds Partner and Pro guardrails, and Enterprise adds custom guardrails. Running the gateway yourself therefore does not, by itself, give you the same checks.
The practical decision is where each check runs. Guardrails sit on the request and response path, so the choice of library determines whether prompts and model outputs pass through a process you operate. Before you commit, confirm with your security team which checks are mandatory (for example, PII scanning or prompt-injection detection), which Portkey partner integrations you currently depend on, and whether your gateway must make outbound calls to any third-party guardrail API. Check the license and release status of each library against your procurement rules, and confirm the Python version your platform team supports, since the NeMo Guardrails 0.25.0 release requires Python 3.11, 3.12 or 3.13. Your first step is an inventory of the guardrails you enable today, mapped to the open-source checks that cover each one.
Which open-source option covers each Portkey guardrail capability
This table maps each Portkey guardrail capability to the open-source option that can cover it: NeMo Guardrails, Guardrails AI or LLM Guard. Read each row as a starting point, since coverage depends on the validators or rails you configure and on the gaps listed for partner-hosted detectors and gateway actions.
| Portkey capability | NeMo Guardrails | Guardrails AI | LLM Guard (archived) |
|---|---|---|---|
| Regex match | Possible through custom input or output rails written in Python actions or Colang | Covered by the regex validator on Guardrails Hub | Covered by the Sensitive and related output scanners, confirm patterns for your use |
| JSON schema validation | Possible through output rails and custom checks, confirm schema enforcement in your rails | Covered by generating and validating structured output against Pydantic models | Covered by the JSON output scanner |
| Code detection | Possible through custom rails, confirm detector coverage for your languages | Confirm whether a validator exists on Guardrails Hub for your language set, or write a custom validator | Confirm coverage with the scanner documentation, which does not list a dedicated code detector in the facts supplied |
| Gibberish detection (LLM-based) | Confirm a self-check or custom rail covers this case | Confirm the matching validator on Guardrails Hub | Confirm against current scanner list, the archived project may not be updated |
| Prompt injection detection | Covered by the jailbreak and injection detection in the library | Confirm the validator and model choice for your deployment | Covered by the Prompt Injection input scanner, but the project is archived and no new rollouts are recommended |
| Partner policies (Aporia, SydeLabs, Pillar Security) | Gap: these are hosted partner detectors, so you must replace them with local models or another provider | Gap: confirm whether equivalent validators exist, since partner APIs are not included | Gap: partner-hosted detectors need replacement with self-hosted scanners |
| Custom guardrails | Covered by custom actions and rails in your own configuration | Covered by writing and publishing custom validators | Covered by writing custom scanners, confirm the extension path in the documentation |
| Deny, log, fallback and retry actions | Confirm how each rail response maps to your gateway, since the gateway owns fallback and retry | Confirm how validation failures map to retries and logging in your gateway | Gap: scanners return results, so deny, fallback and retry must be built in your gateway |
NeMo Guardrails, Guardrails AI and LLM Guard: when each fits
Each option below can run input and output checks beside a self-hosted gateway, but they differ in license status, maintenance, and how much of the policy you write yourself. The cards set out what each one does, the Python version it needs, and where it fits in a Portkey Guardrails replacement.
NeMo Guardrails for policy-driven rails
NeMo Guardrails is Apache-2.0 licensed and configures five rail types: input, dialog, retrieval, execution and output. Policies are written in Colang, so security and product teams can review the flow in one place. Release 0.25.0 deprecates the LLMRails class in favor of Guardrails, with removal planned no earlier than 0.27.0, so pin the version and follow NVIDIA's 0.25 migration guide. Version 0.25.0 requires Python 3.11, 3.12 or 3.13. Check the Python baseline and the Colang version your configs use before you commit.
Guardrails AI for validated structured output
Guardrails AI is Apache-2.0 licensed and builds guards from validators published on Guardrails Hub, such as regex matching or toxicity detection. You install each validator separately and chain them, which suits deterministic checks on JSON or schema-bound replies. It can also generate output that matches Pydantic models. It runs as a Flask REST service started with guardrails start, so gateways can call it through the OpenAI SDK. Plan for validator installation and version pinning, since each validator is a separate dependency. Run guardrails configure deliberately, because it asks whether to enable anonymous metrics reporting.
- Latest release
- 0.11.0
LLM Guard for existing deployments only
LLM Guard is MIT licensed and offers 15 input scanners, including Prompt Injection, Secrets and Anonymize, plus 20 output scanners, including Sensitive and Malicious URLs. Its repository was archived on 9 July 2026 and the README says it is no longer maintained, so no new rollouts are recommended. The last PyPI release, 0.3.16, requires Python 3.10 or newer but below 3.13. Treat it as a migration source, not a target. Keep existing installs on an isolated, patched runtime, and plan a move of PII and injection checks to a maintained option.
LLM Guard repositoryChoosing between the three
Choose NeMo Guardrails when you need conversation-level policy and tool or retrieval rails. Choose Guardrails AI when most checks are deterministic validators on structured output. LLM Guard is only relevant where a team already runs it. Whichever you pick, confirm the Python version required by your gateway host, since the three ranges differ. Ask your vendor or integrator to document which checks run before the model call, which run after, and where logs of blocked content are stored.
Where each check runs: gateway, sidecar or application
An input check runs after the request reaches the gateway and before the model call, and an output check runs after the model responds and before the answer reaches the caller. Portkey's guardrails sit in that gateway path: they inspect requests and responses on the gateway and can deny a request, log the result, or fall back or retry against another model. When a check denies a request, the caller gets a refusal from the gateway and the model never sees the prompt. Decide in advance which failures block traffic and which only log, and confirm how your gateway reports a denied request so applications can handle it.
The open-source alternative keeps that same request path but moves the check logic into a guardrail service that the gateway calls before and after the model. NeMo Guardrails can be called in two ways: through its Python API inside your application or gateway process, or as a guardrails server that loads configurations from a folder and exposes an HTTP API, which the gateway can call as a sidecar or internal service. The Python route adds no network hop but ties guardrail upgrades to your application release cycle. The server route lets a security team version and patch the checks separately, at the cost of one more service to monitor, scale and secure. Confirm the latency each option adds under your own peak load before choosing.
The trust boundary is the main reason to place checks in your own network. When the gateway, the guardrail service and any detection models run inside your VPC or data center, prompts and model responses are inspected without leaving your network. Partner guardrails that call a third-party API send the content to that provider, so review each external call against your data handling terms before enabling it. Confirm with your security team which log fields, such as matched text or PII values, the check service writes, and whether those logs are stored in a location that meets your retention rules.
How input and output checks wrap a self-hosted gateway call
The diagram starts with an application call inside the client network. The input check runs before the gateway forwards the request, and the self-hosted gateway calls the model endpoint only if the input passes. The output check then inspects the model response before it returns to the application. A deny branch stops the request, and a retry branch sends it back for another attempt. Check which parts of the path are open source and where each log entry is written, because that determines what leaves your network.
Input and output checks run inside the client network around the gateway call.
Running open-source guardrails beside Portkey or a self-hosted gateway
Teams that stay on Portkey's hosted or hybrid gateway can keep its guardrails for routing decisions and add self-hosted checks only where Portkey's policies do not cover the need. Portkey Guardrails check requests and responses on the gateway and can deny a request, log the result, fall back to another model or retry. Basic guardrails come with the Developer plan, Partner and Pro guardrails require the Production plan, and custom guardrails require Enterprise, so confirm your tier before designing around it.
- Partner keys: Partner policies from Aporia, SydeLabs and Pillar Security need that provider's API key added to Portkey. Keys can be removed only after the matching check runs in your own service and no policy still references that provider.
- Hook placement: Confirm with Portkey whether a self-hosted check can be called from a guardrail policy on your plan. Do not assume a webhook hook exists.
- Logging: Guardrail verdicts are recorded in Portkey's control plane, so the record of blocked prompts may sit outside your network. Confirm where logs are stored under the hybrid model before you rely on it for evidence.
- Deterministic checks: Regex match and JSON schema validation remain available as Portkey guardrails, so they can stay in place while PII or injection scanning moves to your side.
Check your plan tier, the hook types available to custom checks, and where guardrail logs are stored before you remove any partner key.
Running the MIT-licensed Portkey AI Gateway yourself keeps routing, retries and fallbacks in your infrastructure. The gateway can run with npx, Docker, Node.js, Cloudflare Workers or Kubernetes. Portkey's repository lists prompt management, semantic caching, advanced logging and tracing, access control and PII redaction as enterprise features outside the open-source gateway, so the checks you need in this model are usually built and called by your team. The boundary between the gateway and your check service is where your controls live.
- Partner keys: No Portkey partner keys are needed in this model, because the policies your applications depend on are your own services. Remove every provider key that the old configuration referenced so none remain stored in the new gateway config.
- Check placement: Place the check service on the request path before the gateway forwards a prompt, and on the response path before the answer returns to the application. Measure the added latency during testing.
- Logging: Advanced logging and tracing are enterprise features, so blocked requests and verdicts need another destination, such as OpenTelemetry or Langfuse, that you configure and operate.
- Feature gap: Semantic caching, prompt management and access control also sit outside the open-source gateway, so list any guardrail behavior your team relied on in those paths.
Confirm the gateway version and the hook points it exposes in your environment before you write the contract for the check service.
LiteLLM gives applications one OpenAI-compatible endpoint with virtual keys, budgets, rate limits, fallbacks and logging to Langfuse, Datadog, OpenTelemetry and Prometheus. A guardrail service sits beside it. Guardrails AI can run as a standalone Flask REST service started with guardrails start and called through the OpenAI SDK, and NeMo Guardrails can run as a server that loads configurations from a folder and exposes an HTTP API. An application or thin middleware calls the guard before and after LiteLLM.
- Partner keys: None are needed because no Portkey policy is involved. Provider keys stay in LiteLLM's configuration, and the guard service needs only its own credentials.
- Validators and rails: Guardrails AI guards are built from Guardrails Hub validators, such as regex matching or toxicity detection, installed separately with pip and chained together. NeMo Guardrails configures input, dialog, retrieval, execution and output rails in Colang.
- Runtime: NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, so confirm your base image first. Its server ships with a Dockerfile for container builds. Decide deliberately how to answer the anonymous metrics prompt that guardrails configure displays.
- Logging: Write guard verdicts with the same request ID that LiteLLM records, so a blocked prompt can be traced across both services. LiteLLM Enterprise adds SSO, SAML, audit logs and multi-team management if you need them.
Confirm which validators your compliance team accepts, how the guard handles errors and timeouts, and that request IDs match across both logs.
Some teams already run LLM Guard, which documents 15 input scanners and 20 output scanners, including Prompt Injection, Anonymize, Secrets, Sensitive and Malicious URLs. The protectai/llm-guard repository was archived by its owner on 9 July 2026, and its README says the project and its Hugging Face models are no longer maintained. The last PyPI release is 0.3.16, uploaded on 19 May 2025. DeployOpen does not recommend new LLM Guard rollouts, so this tab covers keeping an existing deployment stable while you plan a move.
- Partner keys: Scanners do not use partner keys, but if Portkey partner policies are still enabled, keep them active until replacement checks are verified.
- Support risk: Pin the installed version and Python runtime, which must be 3.10 or newer and below 3.13. Treat the archived models as dependencies that will not receive fixes.
- Logging: Scanner results return to your application, so route them into your existing store and apply your retention policy to both the inputs and the outputs that were scanned.
- Migration path: Map each scanner in use to a maintained option, such as a NeMo Guardrails rail or a Guardrails AI validator, then test with your own prompts before cutting over.
Confirm which scanners run in production, the Python and model versions they pin, and who owns the migration plan.
Moving guardrail rules from Portkey configs to open-source checks
This sequence turns every enabled Portkey guardrail into a documented open-source check, proves that the replacement blocks what it should without blocking legitimate traffic, and only then removes the Portkey path. Each step produces a record your security team can review before cutover.
Inventory every enabled guardrail
Export the guardrail settings from each Portkey config, including the route or virtual key it attaches to, the action on failure (deny, log, fall back or retry), and the plan tier that provides it. Note which checks are Basic, Partner or Pro, and which depend on partner API keys from providers such as Aporia, SydeLabs or Pillar Security. Ask Portkey support or your account team to confirm any setting that is not visible in the dashboard. The step is done when you have one table listing each route, each check and its failure action, and the owner of that route.
Map each check to an open-source rail or validator
Classify each inventoried check by what it does. Deterministic checks such as regex match, JSON schema validation and code detection usually map to Guardrails AI validators or NeMo Guardrails output rules. PII and prompt-injection checks map to LLM Guard scanners or NeMo Guardrails input rails, with the note that LLM Guard is archived and should only support existing deployments. Mark any check with no clear equivalent as a gap that needs a custom validator or a decision to drop it. The step is done when every row has a target component, a decision, and a named owner for each gap.
Build a test set from your own traffic
Sample prompts and responses from your own gateway logs, covering each route, language and user group, then add known attack patterns such as instruction overrides and data-exfiltration requests. Remove or mask personal data before the set leaves the logging store. Have your security team review and label every case as benign or attack, and record expected outcomes. The step is done when the labeled set is approved, versioned, and stored inside your environment, so the same cases can rerun after each configuration change.
Run both paths in shadow mode
Send the same labeled traffic through the Portkey guardrail path and the open-source check path, with the open-source results logged but not enforced. Keep the Portkey decision as the one that applies to users. Record each denial, pass, latency difference and error for both paths, keyed to the test case ID. The step is done when every labeled case has a result from both paths in one log, with no unexplained gaps.
Compare denials and false positives
Build a comparison that shows where the two paths agree, where the open-source path blocks something Portkey allowed (false positives in its eyes), and where it allows something Portkey blocked (missed attacks relative to the old setup). Have the security team review each disagreement and decide whether the rule, threshold or validator needs tuning. Rerun the test set after every change. The step is done when the disagreements are either resolved or accepted in writing by the named owner.
Cut over route by route
Move one route at a time to the open-source check path, enforcing its decisions and keeping the Portkey guardrail in log-only mode for a rollback window that your team sets. Confirm that failure actions (deny, fall back or retry) behave as they did in the inventory, and that denials are written to your own audit log. The step is done when each route runs on the open-source path, the rollback procedure has been tested, and the change record names who approved it.
Retire the Portkey guardrails and partner keys
After the final route is stable, disable the Portkey guardrail policies, then revoke the partner provider API keys that were added for Aporia, SydeLabs or Pillar Security. Confirm with the vendors how their data-handling terms apply to any traffic that already reached them, and request deletion where your contract allows. Keep the labeled test set and comparison records as evidence for your compliance team. The step is done when no partner keys remain active in Portkey, the vendor confirmations are on file, and the open-source checks run on a schedule your team owns.
What self-hosted guardrails cost to run
The main cost of self-hosted guardrails is not the software, which is open source, but the people and compute that keep the checks accurate. Start by separating one-time work from recurring work. One-time work includes standing up the check service, writing the regex and schema rules that replace Portkey's deterministic guardrails, choosing and wiring validators, and building the test set that proves each rule blocks what it should. Recurring work includes running the check service, storing logs of blocked and allowed requests, patching the runtime, and reviewing false positives every time a rule or model changes. Ask any firm quoting this work to split the estimate along that line, because the recurring share is what your team will carry after the engagement ends.
Compute and language runtime deserve their own line items. A check service that only runs regex and JSON schema validation is light. A service that runs local models for prompt-injection or PII detection needs memory and, often, GPU capacity sized to your request volume and latency budget. Python version management also recurs: NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, and LLM Guard's last PyPI release, 0.3.16 from 19 May 2025, supports Python 3.10 through 3.12 only, which matters if you keep it for existing deployments. Ask the vendor or implementer which interpreter and base image each component pins, and who rebuilds them when a dependency changes its API. Guardrails AI and NeMo Guardrails both change between releases, so budget for upgrade testing as a recurring item, not a one-time setup.
Engineering time for rails and validators and the ongoing review of false positives usually drive the total more than infrastructure. Ask for the number of rails, the validators each one uses, the test cases per rule, and how many rounds of tuning are included in the fixed scope. Confirm who owns the blocked-request logs, how long they are kept, and whether they hold prompt content that itself needs protection. Finally, ask how a false positive is reported, reviewed and fixed, and whether retests after each change are part of the agreed scope or a retainer. Those answers tell you whether the quote covers operating the guardrails or only building them.
Questions teams ask before replacing Portkey Guardrails
Can our team build open-source guardrails without outside help?
Yes, if you have engineers comfortable with Python, a gateway that can call an external check, and someone who owns the policy decisions. Guardrails AI and NeMo Guardrails both install with pip and can run as a standalone HTTP service, so the mechanics are within reach of a platform team. The harder part is deciding what each check should block, log or retry, and writing tests that prove it. Teams that lack capacity in security engineering or LLM operations often bring in a partner for the policy design and testing, then run the result themselves. Confirm your team's Python and container skills before you commit to a plan.
How much effort does a first guardrail rollout take, and what drives it?
The effort depends mostly on how many checks you need, where they run, and how much evidence you must keep. The main cost components are engineering time to choose validators and wire them into the gateway, compute for the check service, testing against your own prompts and responses, and ongoing maintenance of the validators and their models. Costs that recur include patching dependencies, retuning thresholds and running regression tests after model changes. Ask any partner for a written scope listing the checks, the gateway integration, the test cases and the retest plan, since those items set the timeline more than the library choice does.
Is LLM Guard still safe to adopt for new projects?
No new rollouts are recommended. The protectai/llm-guard repository 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. The MIT license still lets you run the last release, which is 0.3.16 from 19 May 2025, but you would own every future security fix. If you already run LLM Guard, plan a move to a maintained option such as NeMo Guardrails or Guardrails AI, and keep the existing deployment limited to what you must support until that move is complete.
Which Python versions do the open-source guardrail libraries require?
It depends on the library. NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13, according to its README and PyPI metadata. The last LLM Guard release on PyPI, 0.3.16, requires Python 3.10 or newer but below 3.13. Check your base images and CI runners against the library you choose before you build, because a version mismatch is one of the most common causes of failed installs. Guardrails AI publishes its own requirements on its releases page, so confirm them for the version you pin, for example v0.11.0.
Does moving guardrail checks in-house meet our audit needs?
Open-source checks can support an audit, but they do not create one by themselves. Auditors look for documented controls, consistent enforcement, change records, logs of blocked and allowed requests, and evidence that the checks were tested. Self-hosting gives you direct control over where prompts and logs live, which many reviewers want. DeployOpen prepares systems, controls and evidence for compliance assessments, but it does not issue audit reports, attestations or certifications; independent auditors and certification bodies do. Ask your assessor which control evidence they expect before you design the logging.
Do open-source tools handle PII redaction and prompt injection equally well?
No, and you should not assume parity. Portkey lists PII redaction as an enterprise feature outside its open-source gateway, while the open-source options cover these risks in different ways. LLM Guard documents an Anonymize input scanner and a Prompt Injection scanner, and NeMo Guardrails includes jailbreak and injection detection along with input and output rails. Guardrails AI relies on validators from Guardrails Hub, so coverage depends on which validators you install. Test each category with your own data, including non-English text and documents, and confirm the detection rates you need with the project or your partner.
Which Portkey guardrail features must we confirm before switching?
Start by listing every guardrail your Portkey plan enables today, separated into deterministic checks such as regex and JSON schema validation, LLM-based checks, and partner policies from providers such as Aporia, SydeLabs and Pillar Security. Portkey Guardrails can deny a request, log the result, fall back to another model or retry, so you need equivalents for each action, not only the detection. Confirm with your vendor which tier-gated features you rely on, and check that each open-source replacement covers the same input and output direction before cutover.
What evidence a reviewer will want from the checks
A security or compliance reviewer will want proof that each guardrail ran, what it decided and that the rules did not change without a record. For a self-hosted setup, that means four kinds of evidence: request and decision logs from the gateway and from each check (input scanner, output scanner, schema validator), configuration history showing which validators, thresholds and fallback actions were active on a given date, test results from a fixed set of prompt-injection, PII and malformed-output cases, and change records that tie each configuration change to a reviewer and a ticket. Portkey's hosted guardrail logs can be exported only under its enterprise terms, so with a self-hosted check path you own these records from day one. Confirm where each component writes its logs and how long they are kept in your environment.
The logs need to show the decision, not just the request. For each blocked, redacted or retried call, a reviewer will look for the guardrail name, the version of the rule or model that fired, the action taken (deny, fall back or retry) and a correlation ID that links the gateway call to the application call. Keep raw prompts and responses under the same access controls as other personal data, and confirm with your privacy team whether redacted or hashed copies are enough for review. Test the chain once end to end before an assessment, because a missing correlation ID is the most common gap reviewers find when they trace one blocked request.
DeployOpen prepares systems, controls and evidence for compliance assessments, including the configuration exports, test runs and change history described above. It does not issue audit reports, attestations or certifications. Independent auditors and certification bodies decide what evidence is sufficient for your framework, so agree the evidence list with them before the checks are built. Ask them specifically whether a test run from a non-production environment counts, how often they expect retests after a validator update, and whether the archived LLM Guard components need a documented exception or replacement plan.
How DeployOpen scopes and delivers guardrail replacement
DeployOpen plans and implements open-source guardrails inside your own infrastructure, placed beside a self-hosted gateway so that input and output checks run where your data already flows. Each engagement starts from a written scope that names the checks, the enforcement points and the tests that will prove them.
How we scope
- Inventory which Portkey guardrails your applications rely on, including regex, JSON schema and partner policies
- Decide which checks run in the gateway path and which run inside the application or pipeline
- Agree the written scope, deliverables and timeline in advance, since most engagements are fixed-scope
- Confirm the supported Python versions and whether NeMo Guardrails 0.25.0 or the current release fits your stack
How we build
- Deploy the chosen guardrail library in your cloud account, data center or air-gapped network, with no outbound control plane
- Write regex, schema and PII rules as versioned configuration, and test each rule against recorded sample prompts and responses
- Wire deny, log, fallback and retry behavior to match the decisions your team agreed in scope
- Run security testing against prompt injection and bypass attempts before any production traffic is routed through the checks
How we hand over
- Document each check, where it runs, what it logs and which data it can see or store
- Deliver configuration files, deployment artifacts and runbooks that your platform team can operate after handover
- Provide the test results and evidence your security and compliance reviewers ask for, without issuing audit opinions
- Walk through the rollback path so the team knows how to disable a check safely during an incident
How we support
- Ongoing support, upgrades and continuous testing are available as retainers after handover
- Track upstream releases and advisories for the guardrail library and its validators, and plan upgrades in writing
- Retest rules after model, prompt or gateway changes so coverage does not drift silently
- Ask any provider for a quote based on the written scope, since DeployOpen does not publish a price list

