Skip to main content

noma-langchain-integration

Noma guardrail middleware for LangChain agents. Scans user and assistant messages to detect and handle unsafe content before and after agent execution.

Installation

pip install noma-langchain-integration

Quick start

from langchain.agents import create_agent
from langchain_noma.middleware import NomaGuardrailMiddleware

middleware = NomaGuardrailMiddleware(
    api_key="noma-...",  # or set NOMA_API_KEY env var
)

agent = create_agent(
    model="openai:gpt-4.1",
    tools=[...],
    middleware=[middleware],
)

The middleware runs two hooks automatically:

  • before_agent — scans user messages before the agent processes them.
  • after_agent — scans assistant messages after the agent responds.

Both sync and async hooks are supported (abefore_agent, aafter_agent).

Configuration

All parameters are optional and keyword-only:

Parameter Type Default Description
api_key str | None NOMA_API_KEY env API key for the Noma service. Required when using the Noma SaaS endpoint.
application_id str | None NOMA_APPLICATION_ID env or "langchain" Application identifier sent with each scan request.
block_failures bool True When True (fail-closed), block requests if the AIDR API is unreachable. When False (fail-open), allow requests through on scan failure.

Environment variables

Variable Required Description
NOMA_API_KEY Yes (SaaS) API key. Can also be passed via the api_key constructor parameter.
NOMA_APPLICATION_ID No Override the application identifier (defaults to "langchain").

Metadata

Release files for noma-langchain-integration 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for noma-langchain-integration 0.1.1
File Size Uploaded
noma_langchain_integration-0.1.1.tar.gz 95.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for noma-langchain-integration 0.1.1
File Interpreter ABI Platform
noma_langchain_integration-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 102.2 kB

Release files / noma_langchain_integration-0.1.1.tar.gz

Download URL noma_langchain_integration-0.1.1.tar.gz
Size 95.9 kB
Tags Source
SHA-256 checksum
How to use checksums
d8a603b79b09db0b20775aad6ad5031e50d228aa5018881f1eacf2985bd90780
BLAKE2b-256 checksum
How to use checksums
918d5090acda10fceb5232ad1994e3f922eb339f10a2e87a62ec84aeb583561e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release files / noma_langchain_integration-0.1.1-py3-none-any.whl

Download URL noma_langchain_integration-0.1.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
65ac90e2f21b59caa8417704922f04836cd570fdf45707c3a3db9b4847bc38ae
BLAKE2b-256 checksum
How to use checksums
5143b3fa42f226cb8095c1cb2ba20194b02e6560634a7bddb2860021994dc131
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 12, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page