How NeMo Guardrails puts Claude behind programmable rails
The anthropic engine in NeMo Guardrails runs Claude through the opt-in LangChain framework, and it supports streaming and tool calls. A team that already runs Claude in an application and needs input and output checks it controls can add those checks without rewriting the model call. The integration is not on by default, so the first decision is to accept the LangChain dependency. The library itself is open source under the Apache 2.0 license, and the current release is 0.25.0. Confirm the license terms and the release notes for your version before you standardize on it, since the release history and deprecations affect how you write your configuration.
The rails do not have to use Claude for everything. Input rails, output rails and dialog rails can call other models, including NVIDIA safety models and self-hosted classifiers, while Claude serves as the main application model. That split matters for cost, latency and data handling, because a safety check can run on a model you host and inspect yourself. Ask your team which checks need a model that stays inside your network and which can call a hosted service, and record the answer in the configuration design before any code is written.
Before you go further, confirm three things in your own environment: the Python version you run (0.25.0 requires Python 3.11, 3.12 or 3.13), the packages your image will install, and the Anthropic credential your deployment will hold. Each one changes the container build and the review evidence your security team will ask for later. The NeMo Guardrails documentation is the right starting point for matching these settings to the release you choose.
What you need before connecting Claude to NeMo Guardrails
Connecting Claude to NeMo Guardrails depends on a short list of runtime, package, credential and network conditions. Each card below covers one of them, so the platform team can confirm each item before the first guarded request runs.
Supported Python version
NeMo Guardrails 0.25.0 requires Python 3.11, 3.12 or 3.13. Check the interpreter inside the build image or virtual environment, not only the workstation, because a host and a container often run different versions. An unsupported interpreter fails at install or import time, which is easiest to catch in a staging build before any application code depends on the guardrails.
- Supported Python
- 3.11 to 3.13
LangChain and langchain-anthropic packages
The anthropic engine runs through the opt-in LangChain framework, so the image needs langchain and langchain-anthropic installed alongside nemoguardrails. Pin both versions in your lock file and confirm they resolve against your chosen NeMo Guardrails release. Treat package upgrades as change-controlled events, since LangChain updates can alter behavior that your rails depend on.
LangChain opt-in environment variable
LangChain integration is disabled unless you set NEMOGUARDRAILS_LLM_FRAMEWORK=langchain. Without it, the anthropic engine will not load even when the packages are present. Set it in the container environment or deployment manifest, and add a startup check that logs the active framework so a missing variable is caught at deploy time rather than in production traffic.
Anthropic API key handling
The provider credential is ANTHROPIC_API_KEY. Inject it from your secrets manager at runtime rather than baking it into the image or a config file in the repository. Use a key scoped to the workload, record who owns it, and plan rotation. Confirm the Claude model names you configure and the key's permissions against your own Anthropic account and Anthropic's current documentation, since model availability changes.
Outbound network access to Anthropic
The NeMo Guardrails host or container must reach the Anthropic API over HTTPS. In segmented or air-gapped networks, this is often blocked by default, so add an explicit egress rule through your proxy or firewall and test it from the same network namespace the guardrails run in. Remember that every guarded request sends prompt content to the external model, which matters for data handling reviews.
Local safety models alongside Claude
Input and output rails that use self-check prompts can call Claude, while content safety or topic safety checks can run on NVIDIA or self-hosted models. Each model endpoint needs its own engine configuration and network path, so list every model in config.yml and confirm each one is reachable from the runtime. Decide early which checks must stay inside your network, because that determines whether outbound Claude access is the only external dependency.
How to configure the anthropic engine step by step
This sequence takes a team from an empty environment to a NeMo Guardrails configuration that calls Claude through the LangChain-backed anthropic engine, with rails tested before anyone relies on it. Each step ends with a check you can run and record.
Confirm the Python environment and install packages
The platform engineer creates a virtual environment on a supported Python version, which for NeMo Guardrails 0.25.0 is Python 3.11, 3.12 or 3.13. They install
nemoguardrailsfrom PyPI, then installlangchainandlangchain-anthropic, because the anthropic engine runs through the LangChain framework. The step is done whenpip show nemoguardrails langchain langchain-anthropiclists all three packages and the interpreter version matches the supported range.Opt in to the LangChain framework
Before NeMo Guardrails loads any configuration, set the environment variable
NEMOGUARDRAILS_LLM_FRAMEWORKtolangchain. The integration is opt-in, so without this variable the anthropic engine is not available. Set it in the same shell or service definition that will run the application, so the same value applies in local tests and later in containers. The step is done when a short Python script that imports the library starts without a framework error.Provide the Anthropic API key
The team sets
ANTHROPIC_API_KEYin the runtime environment, using the secret store they already operate rather than a file committed to source control. Confirm with the account owner which key, workspace and spend controls apply to this application, since those are set in Anthropic's console and not in NeMo Guardrails. The step is done when the key is visible to the process and a single direct call to the model from the same environment succeeds.Write the config.yml with the anthropic engine
In a configuration folder, the developer writes
config.ymlwith amodelsentry that sets the engine toanthropicand names the Claude model to use. Pick the model identifier from Anthropic's current model list and record the choice, since it becomes part of the evidence for the deployment. Add any input and output rails the design requires in the same file. The step is done when loading the folder with the Python API returns a rails object without configuration errors.Add Colang flows and rails
The developer adds Colang files that define the messages and flows the rails will match, such as blocked topics or refusal responses. Colang 1.0 is the default, so decide early whether the project uses 1.0 or 2.x, because the two syntaxes are not interchangeable and NVIDIA documents a conversion tool that still needs manual review. Keep Python actions in a separate file and reference them from the configuration. The step is done when a sample input that should trigger a flow visibly triggers it in a local run.
Test a blocked prompt
The tester sends a prompt that the configured input rails should refuse, such as a request that falls under a blocked topic or a known injection pattern, through the Python API. The test is run by the team that owns the policy, using prompts they write from their own requirements. The step is done when the response is the configured refusal, the model was not called for that input where the rail is designed to stop it, and the result is recorded in the test log.
Test a streamed response through the guardrails server
The engineer builds or runs the NeMo Guardrails server with a Dockerfile, mounting the configuration folder and passing
NEMOGUARDRAILS_LLM_FRAMEWORK=langchain,langchainand the provider packages in the image, andANTHROPIC_API_KEYin the container environment. They then send an allowed request to the HTTP API with streaming enabled and confirm that tokens arrive and that output rails run on the response. The step is done when a streamed reply from Claude passes through the server, and the container logs show no missing package or credential errors.
How a request flows through rails and Claude
The request starts at the client, which calls either the Python API or the guardrails server running in a container. Input rails check the prompt first, and only allowed prompts reach the Claude call, which goes out through LangChain to Anthropic's external API. Output rails then check the response before it returns, and any NVIDIA or self-hosted safety model calls sit inside the container boundary. Check that each rail's model calls stay inside the boundary you intend, and that blocked requests never reach Claude.
Request path through rails, the LangChain Claude call and optional safety models.
How the container environment differs from local development
On a developer workstation, NeMo Guardrails runs as a Python process inside a virtual environment. The developer installs the packages, exports the variables in the shell, and starts the application. Because the shell carries the configuration, a missing package or variable usually surfaces immediately as an import or authentication error during the first run.
- Packages: install
langchainandlangchain-anthropicinto the same environment asnemoguardrails, using a Python version the release supports. - Opt-in variable: export
NEMOGUARDRAILS_LLM_FRAMEWORK=langchainin the session that starts the application. - Credential: export
ANTHROPIC_API_KEYin the shell, scoped to the developer's own key or a test key. - Feedback: errors appear in the terminal, so configuration problems are found early.
- Scope: the environment is personal and often differs from other developers' machines, which makes results harder to reproduce.
Before relying on a local run as evidence, confirm that the same packages and variables are declared somewhere other than a personal shell.
In a container, the image is the environment. Anything a LangChain-only engine needs at runtime must already be present in the image when it is built. The Docker documentation for NeMo Guardrails describes the same three requirements as local development, but they are applied through the build and the deployment manifest instead of an interactive shell.
- Framework variable: set
NEMOGUARDRAILS_LLM_FRAMEWORK=langchainin the container environment, for example in the Dockerfile or the orchestrator's configuration. - Provider packages: include
langchainandlangchain-anthropicin the image's dependency layer, so the build fails or the check catches a missing package before deployment. - Credential at runtime: pass
ANTHROPIC_API_KEYwhen the container starts, through the runtime secret mechanism your platform provides. - Configuration folder: mount or copy the guardrails configuration so the server loads the intended
config.ymland Colang files. - Image tag: record the image digest and package versions so the deployed build can be traced later.
After each build, inspect the installed packages in the image and confirm the framework variable is present in the container's environment.
The most common container mistake is placing the Anthropic key where it becomes part of the image. An image is copied to registries, caches and other environments, so a key baked into a layer should be treated as exposed. The key belongs in the runtime layer, supplied by the platform's secret store, and it should be rotated if it has ever appeared in a build log or image history.
- No secrets in the Dockerfile: do not use
ENV ANTHROPIC_API_KEYwith a value, and do not copy a.envfile containing the key into the build context. - Build context: add secret files and local environment files to
.dockerignore. - Build arguments: avoid passing the key as a build argument, because build arguments can persist in image metadata.
- Runtime injection: supply the key from a secret manager or orchestrator secret, and restrict who can read it.
- Rotation: plan a rotation procedure for the key and confirm the container can reload it without a rebuild.
Check the image history and build logs for the key string before the image is promoted to another environment.
The container should be verified in its own environment, not assumed to match a local run. The checks below confirm that the packages, the opt-in and the credential all reach the running process. They also confirm that the server answers a request that uses the Claude engine, which is the test that matters.
- Package check: run a command inside the built image to confirm
langchainandlangchain-anthropicimport successfully. - Variable check: confirm the framework variable is set in the running container, not only in the Dockerfile.
- Credential check: confirm the key is present at runtime without printing its value to logs.
- Request check: send a test request through the guardrails server that exercises the Anthropic engine and confirm a response.
- Secret scan: scan the image layers and metadata for the key string as part of the release pipeline.
Record the results with the image digest so the same build can be shown to the security and compliance teams that review the deployment.
Which rails can still use NVIDIA or self-hosted safety models
The main model can be Claude while individual safety checks run on other engines. NeMo Guardrails lets each rail reference its own model in the configuration, so a team can keep the anthropic engine for the main model and point a self-check, moderation or jailbreak rail at a self-hosted model on vLLM, a NemoGuard model served through NVIDIA's hosted endpoints, or a local model. The split is decided per rail, not per application, which means the Claude setup does not force every safety check onto the same provider. Before you commit to a mixed design, confirm in the NeMo Guardrails documentation which engines each built-in safety model supports, since not every NemoGuard or third-party model is wired to every engine.
Each engine brings its own requirements. The anthropic engine needs the LangChain opt-in and langchain-anthropic, and a rail that uses a vllm endpoint, an nim engine or an ollama engine may need its own packages and credentials in the same image. In a container, every provider credential, such as NVIDIA_API_KEY for hosted NIM models or the NGC key needed to pull local NIM containers, has to reach the process through the environment or a secret mount. Build the image with the union of packages the configuration actually loads, then test each rail in isolation to confirm it starts and resolves its model before you test the combined pipeline.
Treat the models block of every config.yml as the record of what each rail calls. For each rail, check the engine name, the model identifier, the endpoint, and the API key reference, and confirm that the rail's prompts and any Colang flows reference the intended model. Mixed configurations are easy to change without noticing: a copied rail can keep an old endpoint, or a default model can apply to a rail you assumed used a different one. Record this mapping in your change process, and rerun the rail tests after any change to the models section so the data path your compliance team reviews matches the running system.
Mapping config keys, environment variables and credentials
This table maps each setting in a NeMo Guardrails Claude setup to the part of the configuration or container it controls. Read it as a checklist: the config.yml engine, the LangChain opt-in variable, the Anthropic credential and the image packages must all agree before the Claude engine will run. Confirm exact key names in the supported LLMs documentation before you write the file.
| Setting | Where it goes | What it controls | What to confirm |
|---|---|---|---|
| Model engine in config.yml | config.yml under the models section | Selects the anthropic engine for the main model, which runs through LangChain | Exact key names and the model identifier in the supported LLMs documentation |
| NEMOGUARDRAILS_LLM_FRAMEWORK | Shell or container environment, set to langchain | Opts the process into the LangChain framework that the anthropic engine depends on | That the variable is set in every process and container that loads the configuration |
| ANTHROPIC_API_KEY | Container environment or secret store, not config.yml | Credential the Anthropic provider package uses to call Claude | That the key is injected at runtime and never baked into the image |
| langchain and langchain-anthropic | Python environment or Docker image layer | Runtime packages the anthropic engine imports when the guardrails server starts | Versions compatible with the NeMo Guardrails release you pinned |
| Python version | Base image or local virtual environment | Interpreter that the NeMo Guardrails release supports | Python 3.11, 3.12 or 3.13 for NeMo Guardrails 0.25.0 |
| Configuration folder | Mounted into the container, loaded by the guardrails server | Holds config.yml, optional Python actions and Colang files the server reads | That the mounted path matches the path the server is started with |
| Safety model endpoints | config.yml rail definitions, separate from the Claude engine | Models used by rails, which can stay on NVIDIA or self-hosted endpoints | Each safety model's own engine and credential settings in the supported LLMs documentation |
Securing the Claude key, the container and the rails
A NeMo Guardrails server in front of Claude holds a live provider credential, accepts requests from its callers and runs custom code. The cards below cover the controls that keep the key contained, the server reachable only by approved clients and the rails trustworthy after each change.
Keep the Anthropic key out of images
Pass ANTHROPIC_API_KEY into the container at runtime from your secrets store, not as a Dockerfile instruction, build argument or file copied into the image. Check that the key does not appear in the image history, the config folder or the repository holding the Colang and YAML files. Ask who can read the runtime environment of the container, since anyone who can inspect it can read the key.
Docker deployment docsLimit egress to the Anthropic endpoint
Allow the guardrails server to reach only the Anthropic API and any safety model endpoints you have approved, and block other outbound traffic by default. This limits what a compromised action or a misconfigured rail could send out. Confirm the exact hostnames with Anthropic and your network team, and test the allow list from inside the running container, not only from the host.
Restrict the server to internal clients
The guardrails server exposes an HTTP API, so place it behind a private network path, an internal gateway or a service mesh and authenticate every caller. Do not publish the port to the internet, and do not let application front ends call it directly with a shared key. Decide which services may select each configuration, because a caller that can choose a configuration can choose which rails apply.
Review what custom actions can reach
Custom Python actions run with the permissions of the container, so a helper that reads files or calls an internal API widens the attack surface. List every action, the files, tools and hosts it can touch, and remove what the rails do not need. Run the container as a non-root user with a read-only filesystem where practical, and mount only the directories the configuration requires.
Retest rails after every change
Changes to config.yml, Colang files, prompts, actions, the model name or the framework setting can silently alter which inputs are blocked. Rerun a fixed set of allowed and blocked prompts, including jailbreak and injection samples, after each change and before each container rollout. Keep the results with the change record so reviewers can see what was tested for each version.
- Current library release
- 0.25.0
Common failures when connecting Claude
This table lists the failures teams most often hit when pointing NeMo Guardrails at Claude, with the likely cause and the fix for each. Read it top to bottom when a Claude-backed configuration fails to start, fails inside a container, or behaves differently after an upgrade. The main takeaway is that most failures come from the LangChain opt-in, the packages in the runtime, or the Colang version, not from the Claude API itself.
| Failure | Likely cause | Fix |
|---|---|---|
| Anthropic engine fails to load | LangChain was not opted in, so the anthropic engine has no framework to run through | Set NEMOGUARDRAILS_LLM_FRAMEWORK=langchain in the environment where the guardrails run, then restart the process or container |
| Import error for Anthropic provider | langchain or langchain-anthropic is missing from the Python environment or the Docker image | Install langchain and langchain-anthropic in the same environment, and add them to the image build if you run a container |
| Authentication error from Claude | ANTHROPIC_API_KEY is unset, misspelled, or set in a different shell or container than the one running the server | Confirm the variable name exactly, pass it into the container environment, and test the key with a minimal call outside NeMo Guardrails |
| Installation or startup fails on Python version | The interpreter is outside the Python 3.11 to 3.13 range that NeMo Guardrails 0.25.0 supports | Create a virtual environment on Python 3.11, 3.12 or 3.13 and reinstall the packages there |
| Streaming output differs from expectations | Streaming depends on the LangChain path and the caller consuming chunks as the engine emits them, so a non-streaming client or proxy can appear to hang or buffer | Confirm the calling code handles streamed responses, test streaming with the Claude model directly, and check any reverse proxy that buffers responses |
| Tool calls are missing or malformed | The tool schema, the tool result format, or the rails validating tool calls do not match what the Claude model returns | Test one tool call end to end, log the raw call and result, and align the tool definitions with the LangChain tool format before adding rails |
| Config works locally but fails after upgrade | The configuration was written in Colang 1.0 and the upgraded setup expects Colang 2.x syntax, or the reverse | Check the colang_version setting in config.yml and the Colang files, run the nemoguardrails convert tool if you are moving to 2.x, and review the converted output manually |
| Colang flows behave differently after conversion | Converted configurations still need manual review, and default behavior differs between Colang versions | Compare blocked and allowed test cases before and after conversion, and keep the Colang version explicit in every configuration |
| Deprecation warnings after upgrade to 0.25 | The LLMRails class is deprecated in favor of Guardrails in 0.25.0, with removal planned no earlier than 0.27.0 | Follow NVIDIA's 0.25 migration guide and update initialization code before the class is removed |
Questions teams ask before connecting Claude to NeMo Guardrails
What does it cost to run NeMo Guardrails in front of Claude?
The NeMo Guardrails library is open source under Apache 2.0, so the software itself has no license fee. The recurring costs come from three places: model usage fees paid to Anthropic for every Claude call the rails make, including the extra calls that self-check rails add, compute for the server and any self-hosted safety models, and the engineering time to build and maintain the configuration. Model usage depends on how many rails call an LLM and how long the prompts are, so ask any quote to show which rails trigger extra model calls. Infrastructure depends on whether safety models run on GPUs you already own. Engineering time is largely one-time for the initial build and recurs for rail updates and testing.
How long does it take to add Claude guardrails?
Duration depends mainly on rail scope. A configuration with a small set of input and output checks on one Claude model is far shorter to build than one with dialog rails, retrieval rails for RAG, tool validation and self-hosted safety models, because each rail needs its own design, tests and review. Other drivers include how many applications and environments need the guardrails, whether Colang 2.0 or existing Colang 1.0 files are involved, and how quickly your security and compliance reviewers can sign off on the rail policies. No duration is fixed by the library itself, so ask any proposal to tie its timeline to a written list of rails.
Can our team do this alone using the documentation?
Yes, a team with Python experience can install NeMo Guardrails, set the Anthropic credential and the LangChain opt-in, and run a basic configuration from the official documentation. Teams usually find the harder parts are designing rail policies that match their risk, writing tests that show the rails block what they should, and maintaining Colang files across version changes. If your team has no one who has written Colang or run LLM evaluations, budget time for learning, or bring in outside help for the design and test stages. Start by reading the supported LLMs and Docker pages linked on this page.
What do we need to provide before the work starts?
You will need an Anthropic account with an API key that the team is allowed to use, a Python 3.11, 3.12 or 3.13 environment or container image for the server, and access to the container registry and the infrastructure where the guardrails will run. Most important for the rails is a test dataset of prompts your application should allow and prompts it should block, drawn from real traffic or a realistic threat list you agree on. You also need a named owner who can approve rail policies, decide what happens when a rail blocks a request, and sign off on changes.
Which Claude setup requires the LangChain opt-in?
The anthropic engine in NeMo Guardrails runs through the LangChain framework, which is opt-in. Set the environment variable NEMOGUARDRAILS_LLM_FRAMEWORK=langchain and install the packages with pip install langchain langchain-anthropic. Without the opt-in, the anthropic engine does not load. In containers, the same variable, the LangChain packages and the ANTHROPIC_API_KEY credential must all be present in the image and the container environment. Confirm the exact package versions against the release you are deploying, because LangChain and its provider packages change independently of NeMo Guardrails.
Can NVIDIA or self-hosted safety models run alongside Claude?
Yes. Claude can serve as the main application model while other rails call separate models. NeMo Guardrails includes NVIDIA content safety and topic safety models, self-check prompts that use whichever LLM you configure, and jailbreak and injection detection, so a configuration can route different rails to different models. Self-hosted safety models can run on infrastructure you control, which keeps those checks inside your network even though the main model call goes to Anthropic. Confirm which safety models your rail design needs, the hardware they require, and whether any model's license terms affect your deployment.
What happens to the setup if NeMo Guardrails releases a new version?
New releases can change configuration, Python APIs and the server, so plan a test run before each upgrade. NeMo Guardrails 0.25.0 deprecates the LLMRails class in favor of Guardrails, with removal planned no earlier than 0.27.0, and NVIDIA publishes a 0.25 migration guide. Colang 1.0 to 2.x conversion uses the nemoguardrails convert tool, and NVIDIA says converted configurations still need manual review. Keep your test dataset and rail tests in version control so each upgrade can be checked against the same expectations. Also check that the LangChain and Anthropic packages still match the versions your image uses.
What changes when NeMo Guardrails moves to 0.25 and beyond
Teams running a Claude integration on an older NeMo Guardrails release should plan a review before upgrading to 0.25.0, because this release changes the class your code calls. 0.25.0 deprecates the LLMRails class in favor of Guardrails, and removal is planned no earlier than 0.27.0. Code that still builds its rails object with LLMRails will keep working for now, but it will need to move before the removal. NVIDIA publishes a 0.25 migration guide, which is the first document to read before changing the import and initialization code in your Claude application.
The Claude path also depends on the LangChain opt-in, so an upgrade is a good moment to confirm that the NEMOGUARDRAILS_LLM_FRAMEWORK=langchain setting and the langchain-anthropic package are still present in your local environments and container images. Do not assume that a new image built from an old Dockerfile carries these settings forward. Check the container environment and the installed packages after every rebuild, and run a short test call through Claude before routing traffic to the new build.
If you were considering the NeMo Guardrails microservice for this integration, note that NVIDIA sunset the NeMo microservices on October 1, 2026, with no new releases. Plan around the open-source library or the self-hosted server built from it, and ask your NVIDIA account team to confirm what, if anything, applies to your existing deployment. Finally, review your config.yml, Colang files and custom actions after each upgrade, since NVIDIA says converted Colang configurations still need manual review. Keep a test set of blocked and allowed Claude requests so that you can show that each rail still behaves as before.
How DeployOpen scopes and delivers a Claude guardrails integration
DeployOpen approaches NeMo Guardrails with Anthropic Claude models as a fixed-scope piece of work inside infrastructure you control. We agree the Claude engine path, the container and package set, and the safety models each rail uses before any build starts, then hand over the configuration, deployment and evidence your teams need to review it.
How we scope
- Confirm which Claude models, which rails and which NVIDIA or self-hosted safety models the written scope covers
- Record the LangChain opt-in, the provider packages and the Python version the target runtime will use
- Agree in writing where the guardrails server runs, how the ANTHROPIC_API_KEY credential is supplied and who owns it
How we build
- Configure the anthropic engine with the LangChain framework enabled, then test streaming and tool call behavior against your application
- Build the container image with the langchain and langchain-anthropic packages and the NEMOGUARDRAILS_LLM_FRAMEWORK setting
- Wire any self-hosted safety models alongside Claude and test each rail separately before the full pipeline runs end to end
How we hand over
- Deliver the config.yml, Colang files, Python actions and image definitions in a version-controlled repository your team owns
- Document each rail, its model dependency, its credential needs and the logs it produces for security and compliance reviews
- Walk through the test results and a runbook covering upgrades, including the deprecation of LLMRails in favor of Guardrails
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover, scoped in writing
- Retest the configuration when NeMo Guardrails, the LangChain packages or the Claude model in use changes
- Confirm with your account team where the NeMo Guardrails microservice sunset affects your deployment plan before any upgrade

