Migrating from the OpenAI Moderation API to NeMo Guardrails

Moving from per-request moderation calls to input and output rails means rebuilding the checks inside your application's request flow, not swapping one endpoint for another. This page covers what maps, which import paths are documented, and how a parallel run and threshold calibration reduce cutover risk.

On this page

What moving from the OpenAI Moderation API to NeMo Guardrails involves

Moving from the OpenAI Moderation API to NeMo Guardrails means replacing a per-request classification call with input and output rails that you configure, host and calibrate yourself. The work is mainly configuration, hosting the safety models you choose, and calibrating thresholds against your own traffic. NeMo Guardrails has no documented importer for Moderation API settings, so the category list, thresholds and call pattern in your current code must be rebuilt by hand in a config.yml file and any Colang or Python files you add. Your target is the open-source library or the guardrails server, both under the Apache 2.0 license. The NGC microservice container is sunset, so do not plan around it. The current release is 0.25.0, which requires Python 3.11, 3.12 or 3.13, and its release notes should be read before you pin a version.

Effort depends on three things you can count now: the number of call sites that invoke moderation, the modalities those calls cover (text only, or images as well), and the number of thresholds and categories your application enforces per site. Build that inventory first, including where each moderation result is logged, blocked on or ignored. Pair it with a list of the models you intend to self-host, since hosting capacity and calibration effort follow from that choice. Any duration or cost figure should come from your own inventory and a written quote tied to that scope. Ask the partner or vendor to state which of your call sites, modalities and thresholds are included, and which safety models and hardware they assume. Confirm each capability (such as image checks) against the current NeMo Guardrails documentation before you commit to it in the scope.

Which OpenAI moderation features map to NeMo Guardrails rails

This table compares each OpenAI Moderation API capability your team relies on with its closest NeMo Guardrails equivalent. Read the middle column as the current behavior you are replacing and the right column as what you would build, then check the marked gaps before planning the cutover. The main takeaway is that the per-request call maps well to rails, but the category taxonomy and score meaning do not carry over automatically.

CapabilityOpenAI Moderation APINeMo Guardrails equivalent
Category flagsReturns a boolean flag per category in OpenAI's taxonomy. Confirm the current category list in OpenAI's documentation at the time of writing.No direct equivalent. Map each OpenAI category to a self-check prompt, a content safety model category or a custom action, then document the mapping.
Category scoresReturns numeric scores per category. Confirm score range and meaning in OpenAI's documentation.Scores from NVIDIA content safety or self-check models do not share OpenAI's semantics. Calibrate thresholds on your own labeled traffic.
Per-request call before model generationYour application calls the endpoint on user input before sending it to the model.An input rail runs in the guardrails configuration before the model call, so the check is part of the same request flow.
Per-request call after model generationYour application calls the endpoint on model output before returning it to the user.An output rail checks the generated response before it is returned, with the decision applied inside the rails pipeline.
Blocking responsesYour application decides what to show when a flag is set, usually in its own code.Rails can block, refuse or replace a response through configured outcomes. Confirm the exact refusal behavior in the version you deploy.
Image inputConfirm current image moderation support and input types in OpenAI's documentation.Image checks are not part of the core rail set described here. Confirm whether the multimodal options you plan to use are supported in your NeMo Guardrails version.
Custom policy logicLimited to the fixed taxonomy and your own code around the flags.Custom actions and rail logic let you add organization-specific checks, but they must be written and tested by your team or a partner.

Documented paths for moving moderation logic into NeMo Guardrails

NeMo Guardrails gives you several documented ways to host moderation logic: a configuration folder, Colang flows, Python actions, a Python API, a server container and an optional LangChain path. None of them imports OpenAI Moderation API settings, so the category mapping and thresholds you carry over are decisions your team writes, tests and owns.

Configuration folder with config.yml

Every guardrails setup starts with a config folder. The config.yml file names the models, the rails that run on input and output, and the settings each rail reads. Your moderation policy lives here as configuration, so it can be version controlled and reviewed like any other change. Check which rails are enabled, which model each one calls, and that the file loads in a staging environment before any traffic reaches it.

NeMo Guardrails docs

Colang 1.0 or 2.0 flows

Colang files define how the assistant responds to user messages and how rails interact with the conversation. Colang 1.0 is the default, and Colang 2.0 is also supported. Choose one version for the whole project and confirm which version your team can maintain. Flows are where you express policy branches, such as blocking a message category and returning a fixed refusal, so review them with the same rigor as the thresholds.

Optional Python actions

Python actions let you call code from a rail, for example to score text with a model you host or to apply a rule that Colang cannot express cleanly. This is where a hand-written mapping from moderation categories to your own labels usually lives. Each action is code you must test, secure and deploy, so record who owns it and how it is versioned.

Python API and guardrails server

Your application can call NeMo Guardrails through its Python API, or run the guardrails server, which loads configurations from a folder and exposes an HTTP API. A Dockerfile is provided to build a server image. Choose the server when several services need the same policy, and confirm the request and response format matches what your application expects before you replace the Moderation API call.

NeMo Guardrails repository

LangChain integration

If your application already runs on LangChain, the integration is opt-in and is enabled by setting the environment variable NEMOGUARDRAILS_LLM_FRAMEWORK to langchain. Without that setting, the integration does not load. Check how the variable is set in each environment, including containers and CI, so a deployment does not silently run without its rails.

The convert tool for Colang 1.0 files

The nemoguardrails convert tool helps move existing Colang 1.0 files to Colang 2.x. It applies only to Colang 1.0 files you already have, and it does not translate moderation settings from the OpenAI Moderation API. NVIDIA states that converted configurations still need manual review, so plan a reviewer and a test set for each converted file.

Colang 2 migration guide

How input and output rails replace a per-request moderation call

With the OpenAI Moderation API, the application makes a separate call to a standalone endpoint, interprets the result, and then decides whether to forward the request to a model. With NeMo Guardrails, that check moves into the application's own request path. The user message passes through input rails before it reaches the model, and the model's answer passes through output rails before it returns to the user. The application calls one guardrails configuration instead of coordinating two services, which means the moderation decision is no longer a separate network hop your code can forget to make. Rail order also needs design work: an inexpensive check such as a regex or keyword rail should run before a model-based classifier, and the team must decide which rails run in sequence and which can run in parallel without changing the outcome.

Two behaviors need explicit decisions before cutover. First, the blocking message returned to the user must be defined per rail, so a refused prompt does not reveal which category triggered the block or leak system prompt details. Second, streamed responses change the output rail's job. If tokens reach the user before the output rails have judged the full answer, a harmful passage may already be visible. Confirm in the NeMo Guardrails documentation for your chosen version how streaming output is evaluated and whether the buffering it implies is acceptable for your user experience and latency targets.

Every rail verdict should be logged with enough context to debug a blocked request: the rail name, the configuration version, the input or output that was evaluated (or a hashed reference, if your data handling rules forbid storing raw text), the score or label returned, and the action taken. Without this, a support team cannot tell whether a false block came from a keyword rule or a classifier. Also confirm which self-check and safety model options apply to your NeMo Guardrails version and hosting model, since the set of built-in models and their deployment requirements differ, and check the NeMo Guardrails documentation before assuming a category you used in the Moderation API has a direct equivalent.

Request flow before and after the move

The current path sends each user message to the OpenAI Moderation API as a separate call before the model is invoked, so the application depends on an external service for every check. The target path routes the request through a NeMo Guardrails server or Python API inside the team's own infrastructure, where input rails run before the model and output rails run before the response returns or is blocked. Check where each safety verdict is logged, and confirm which model endpoints, if any, still cross the trust boundary.

Per-request moderation calls compared with input and output rails in the team's own infrastructure.

Sequence for a parallel run and cutover

This sequence moves each moderation route from OpenAI Moderation API calls to NeMo Guardrails rails in controlled stages, so every switch is backed by recorded evidence, a named sign-off and a way back. The length of each step depends on traffic volume and review capacity, so the schedule should be set per route rather than copied from another migration.

  1. Inventory every moderation call site

    List each application, service, batch job and worker that calls the OpenAI Moderation API, and record the modality (text, image or both), the input and output paths, the model or endpoint version used, and the category thresholds your code applies to the returned scores. Include calls made from scripts, background jobs and third-party tools that share the same key. The owning team of each route signs off on the inventory, and the output is a route register that maps every call site to its planned NeMo Guardrails rail or rails. Confirm with your platform team which keys and environments each call uses before you start, because those keys are removed in the final step.

  2. Pilot one application end to end

    Choose one low-risk application with moderate traffic and build its input and output rails in a non-production environment. Deploy the guardrails configuration on the infrastructure you control, wire the application to call it, and run it against representative test traffic that includes known edge cases from your category list. The pilot is complete when the application behaves correctly on the test set, the team has confirmed that blocked responses reach users in the expected form, and the owners sign off on the pilot report with a documented rollback path to the existing moderation call.

  3. Record verdicts in parallel without blocking

    Run NeMo Guardrails beside the existing OpenAI moderation check on the same live traffic for the pilot route. The existing check keeps making the blocking decision, while the guardrails verdict, the scores and the matched rail are written to a separate log keyed to the same request. Store the content under the same retention rules as the existing logs. This step ends when enough recorded traffic exists to compare both systems across all categories and modalities on the route, and the review team has signed off on the comparison scope.

  4. Compare verdicts and calibrate thresholds

    Review disagreements between the two systems, sorting each one into a category mismatch, a threshold difference, a modality gap or a true error in either system. Adjust rail configuration, model choice and thresholds on the guardrails side until the remaining differences are understood and accepted by the route owner and the safety reviewer. Where NeMo Guardrails flags content the existing check allowed, or the reverse, record the decision and its reason. The step closes with a calibration record for the route that lists each threshold, its rationale and the sign-off date.

  5. Cut over each route with a rollback path

    Switch the route so NeMo Guardrails makes the blocking decision, keeping the OpenAI moderation call available behind a configuration flag or deployment toggle for the agreed rollback window. Monitor blocked-request rates, false positive reports, latency and error rates against the parallel-run baseline. Repeat this step for each remaining route, one at a time, rather than switching several at once. A route is complete when its monitoring period ends without a rollback trigger and the route owner signs off the cutover.

  6. Decommission OpenAI moderation calls and keys

    After every route has completed cutover and its sign-off, remove the code paths that call the OpenAI Moderation API, delete or disable the API keys used only for moderation, and confirm in your secrets manager and provider console that no active process still uses them. Update the route register and the data flow documentation to show that the OpenAI endpoint no longer receives content. The step ends with a written decommissioning record that names each removed key and call site, signed by the security owner.

What drives the cost and duration of this migration

This table lists the main drivers of effort and spend when moving from the OpenAI Moderation API to self-hosted NeMo Guardrails rails. Each row shows whether the cost is one-time or recurring and what to ask for in a written quote. Use it to scope the work before comparing proposals.

DriverWhy it changes effortOne-time or recurring, and what to ask for
Call sites and applicationsEach application that calls the moderation endpoint needs its own input and output rail wiring, tests and rollout plan.One-time. Ask for a list of applications and call sites included in the scope, with the rail placement for each.
Image and non-text moderationThe Moderation API accepts image input in some configurations, so a self-hosted image check needs a separate model choice, hosting and calibration.One-time for setup, recurring for hosting. Ask whether image moderation is in scope and which model and hardware the quote assumes.
Number of categories and thresholdsEach category needs a mapping to a rail or model output, and each threshold needs calibration against your own traffic.One-time. Ask for the category mapping table and the calibration method, including who sets the final thresholds.
Labeled test setCalibration and regression testing depend on a representative set of labeled prompts and responses that your team or the partner can supply.One-time. Ask who labels the data, how many examples the plan assumes, and how the set is kept for later retests.
Self-hosted safety model hostingSelf-hosted models need CPU or GPU capacity sized to your request volume, and that capacity is paid for in your infrastructure.Recurring infrastructure cost plus one-time sizing. Ask for the hardware assumptions, model sizes and the expected peak request rate.
Latency targetsTight latency targets may require parallel rails, smaller models or additional capacity, which adds design and load testing work.One-time design and testing, with possible recurring capacity. Ask for the target latency per request path and the load test plan.
Logging and audit requirementsRecords of blocked requests, verdicts and configuration changes need storage, retention rules and access controls.Recurring storage and review effort. Ask what must be retained, for how long, and who can read the logs.
Colang or Python custom actionsCustom actions and Colang flows beyond the standard rails add development and review work, and Colang 1.0 is the default configuration language.One-time development, with ongoing maintenance on each NeMo Guardrails upgrade. Ask which custom actions are in the quote and how upgrades are covered.

Choosing a deployment option for the rails

Embedding the library places the rails inside the application process. The application imports the package, loads a configuration folder with config.yml and Colang files, and calls the rails before and after each model request. This is the smallest moving part and the closest match to a per-request moderation call, but every application that uses it becomes responsible for the same configuration, dependencies and upgrades.

  • Team skills: Python development on a version the package supports (3.11, 3.12 or 3.13 for 0.25.0), plus someone who can write and review Colang and the config files.
  • Where verdicts live: In the application's own logs and telemetry, since the rails run in its process. Each service must ship its own log and trace fields.
  • Application code change: The moderation call is replaced by a rails call in each service, so every codebase needs the change and its tests.
  • Upgrade effort: Each application pins and upgrades the library separately, which means coordinating releases across teams.
  • Model access: Safety models and the LLM are reached from the same process, so the host needs the compute and network paths for them.

Confirm that each service can carry the library's dependencies before choosing this option for more than one application.

What usually goes wrong when teams leave the OpenAI Moderation API

Moving from a hosted moderation call to self-hosted rails changes who owns thresholds, capacity, latency and evidence. The risks below share one root cause: the team assumes the new setup behaves like the old endpoint without testing that assumption.

Thresholds copied without calibration

Teams often reuse the score cutoffs they had with the hosted endpoint. Self-hosted safety models and self-check prompts score differently, so a copied threshold can block benign traffic or pass harmful traffic. Calibrate each rail against labeled examples from your own traffic before cutover, and record the chosen value and the reason for it.

NeMo Guardrails docs

Category gaps no test set covers

The hosted moderation categories do not map one to one onto NeMo Guardrails rails. A category that was caught before may have no rail at all, and nobody notices because no test case exercises it. Build a test set per original category and mark each one as covered, partly covered or uncovered before you remove the old call.

Latency added without a budget

Each input and output rail can add a model call to the request path. Without a measured latency budget per request, the team discovers the cost in production dashboards. Set a p95 budget for the full rail chain and measure it with and without each rail enabled, so you know which rail consumes the budget.

Safety models without capacity planning

A self-hosted safety model needs its own compute, and it serves every request your application sends. Hosted moderation hid this load from your team. Size the model endpoint against peak request volume, with headroom for retries and streaming, and confirm the hardware requirements with the model's documentation before purchase.

Blocked-message behavior breaking clients

The hosted endpoint returned a flagged result that your client code parsed. A guardrails refusal arrives as a different response shape, and client apps that expect the old shape can fail or show raw errors. Define the blocked-response contract with the client teams and test it in the server response format you will run in production.

Verdict logs missing audit context

Logging only that a request was blocked does not show why, which rail fired, which model version scored it, or which threshold applied. Auditors and incident responders need that context. Log the rail name, score, threshold, model identifier and configuration version for every verdict, and decide the retention period with your compliance team.

Upgrades breaking Python and Colang configs

NeMo Guardrails supports Colang 1.0 and 2.0 and lists its own Python version requirements, and each release can change them. A configuration that works today can fail after a runtime or language upgrade. Pin the Python version and Colang version in your build, and run the conversion tool with manual review before moving a configuration to a new release.

Colang 2 migration guide

Questions teams ask before moving off the OpenAI Moderation API

How much effort does moving from the OpenAI Moderation API to NeMo Guardrails take?

The effort depends mostly on how many call sites send traffic to the moderation endpoint, how many categories and thresholds your policy uses, and whether you also need image moderation. The work breaks into four parts: deploying a self-hosted safety model, wiring input and output rails into your application, mapping your current categories to rail outcomes, and calibrating thresholds against recorded traffic. Each part adds effort, and the threshold work usually takes the longest because it needs decisions from people outside engineering. Ask any partner to break its quote into these parts so you can see which ones your team already covers.

How long should a parallel run last, and what does it need?

The length of a parallel run is set by your traffic volume and by how many weeks of data you need to see the rare categories you care about, so confirm the duration with your risk owners instead of copying a number from another project. A useful parallel run needs three things: a representative sample of production prompts and responses, a logging path that records both the moderation verdict and the NeMo Guardrails verdict for each request, and a review process that classifies every disagreement as a true or false positive. Plan for the review workload as well as the infrastructure, since disagreements are where threshold decisions get made.

Do moderation settings import automatically into NeMo Guardrails?

No. No documented importer converts OpenAI Moderation API settings into NeMo Guardrails configuration, so category names, thresholds and routing rules must be written by hand in config.yml and any Colang files. The mapping is a design task: some categories will map to a built-in self-check or safety model rail, some will need a custom action, and some will need a decision about whether to block, rewrite or flag. Treat the export of your current settings as a specification you rebuild, and check the NeMo Guardrails documentation for the version you deploy before assuming any model or rail behaves the same way.

What must our team provide before the migration starts?

Four inputs decide whether the migration can finish on schedule. First, traffic samples that reflect real prompts and responses, including languages and channels you serve. Second, a written category policy that states which harms you block, which you flag, and which you allow. Third, labeled examples for each category, reviewed by people who can judge them, which become your regression set. Fourth, named owners who can approve threshold changes and accept residual risk, usually from security, compliance and the product owner. Without the fourth item, calibration stalls because engineers cannot make policy decisions alone.

Can an internal team complete this migration without a partner?

An internal team with Python, container and Kubernetes experience can complete the technical work, provided it has the time and the policy owners to support it. The areas most often underestimated are threshold calibration against labeled data, safe rollout of blocking rules, and evidence collection for security reviews. A partner can take on any of these as a fixed-scope piece, for example the deployment, the parallel run harness or the test suite, while your team keeps the policy decisions. DeployOpen implements, hardens, documents and supports self-hosted platforms in your own infrastructure, and quotes follow from a written scope.

How do cost and latency change compared with per-request moderation calls?

Per-request moderation calls are billed by the provider and add a network round trip to every request. Self-hosting moves the cost to infrastructure you run, including accelerators or CPU capacity for the safety models, storage and logging, plus the staff time to operate them. Latency depends on where the models run, how many rails execute per request and whether they run in parallel, so measure it on your own traffic before and after cutover. Ask any quote to separate one-time build costs from recurring infrastructure and support costs, and to state which sizing assumptions it uses.

Does the Apache 2.0 license cover NeMo Guardrails, and what should we confirm?

Yes, NeMo Guardrails is licensed under Apache 2.0, and the license covers the library. The license does not automatically cover the safety models, which carry their own terms, and it does not cover image moderation features unless your version documents them. Also note that NVIDIA retired the NeMo Guardrails microservice, with the NGC container sunset as of October 1, 2026, so do not build on that container. Confirm image support and each safety model's license in the exact version you plan to deploy, and ask your legal team to review both before procurement.

How DeployOpen works on this

DeployOpen plans, implements, tests, documents and supports self-hosted open-source platforms inside your own infrastructure. For this migration, we start by mapping your current moderation calls to NeMo Guardrails rails, then build and calibrate the self-hosted setup in your environment and hand over the configuration with the evidence your reviewers need.

How we scope

  • Inventory every place your application calls the moderation endpoint, including request paths, categories and actions taken on each result.
  • Agree in writing which input and output rails, models, image checks and deployment targets are in the fixed-scope engagement.
  • Confirm Python version, hosting model, network boundaries and who owns threshold decisions before any build work starts.

How we build

  • Translate category mappings into config.yml, Colang files and any custom actions, with each rail's block or allow outcome defined.
  • Stand up the guardrails server or Python API in your infrastructure and connect it to your self-hosted safety models.
  • Replay recorded traffic side by side with the current moderation calls and document every verdict difference before cutover.

How we hand over

  • Deliver the configuration repository, deployment artifacts, threshold records and a written calibration report with the decisions behind each value.
  • Walk your platform, security and compliance teams through rail behavior, logging and the known gaps against the old moderation calls.
  • Document the review steps needed when NVIDIA publishes new NeMo Guardrails releases or changes configuration formats.

How we support

  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Retesting of rails after model, configuration or threshold changes can be included in the written scope or added later.
  • Ask any partner, including DeployOpen, to confirm current support status of the NeMo Guardrails microservice and the NeMo Platform path before committing.

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.