Skip to main content

English · Français

LangChain × NeoMundi

Measure what your LangChain application actually does at runtime.

One callback handler. Five measured signals per interaction. Verifiable evidence.

Quickstart · What it refuses to do · Notebook · Limitations · Cost

NeoMundi SDK · Product architecture · Create an account


What this is

langchain-neomundi attaches the NeoMundi measurement API to a LangChain application through a standard callback handler. Every LLM interaction your chain performs becomes a measured observation: five signals, each with explicit provenance and an explicit measured / not_measured state.

It is a thin driver for neomundi's own client.trace(). The SDK measures latency, enforces the request contract and submits the observation. Nothing is reimplemented here, which is the reason this package is small enough to audit in one sitting.

your chain  ──▶  LangChain callback  ──▶  client.trace()  ──▶  POST /v1/govern
                 (this package)           (neomundi SDK)        (measurement API)

What it is not

  • Not an evaluator. It transports measurements; it does not interpret them. No threshold, no verdict, no is_safe(). That boundary is inherited from the SDK on purpose.
  • Not a tracer. There is no trace-only route on the NeoMundi API. Closing a measurement is a billed observation. See what it costs.
  • Not a truth checker. NeoMundi verifies the integrity and authenticity of a record. It does not verify that your model's answer was true.

Install

🟡 Not published on PyPI yet. pip install langchain-neomundi does not work today; the name is reserved and a gated release workflow is in place. Install from this repository:

pip install "git+https://github.com/neomundi-io/neomundi-integrations.git#subdirectory=integrations/langchain"

Python 3.11 or newer — the floor comes from LangChain 1.x, not from NeoMundi. Two dependencies: langchain-core and neomundi.

Quickstart

from langchain_neomundi import NeoMundiCallbackHandler

handler = NeoMundiCallbackHandler(
    api_key="ct_live_...",  # your NeoMundi key
    base_url="https://api.neomundi.io",  # mandatory: no host is ever assumed
)

answer = chain.invoke(
    {"question": "What changed in our refund policy?"},
    config={"callbacks": [handler]},
)

outcome = handler.last_outcome
print(outcome.status)  # 'submitted'
print(outcome.request_id)  # the server's id -- your only correlation key
print(outcome.latency_ms)  # measured, not declared

Wire it up for free first. submit=False measures latency locally and opens no socket:

handler = NeoMundiCallbackHandler(client_or_credentials, submit=False)

RAG chains

Retrieved documents are picked up automatically from on_retriever_end and attached to the measurement as rag_context, so grounding signals have something to work with. No extra wiring:

chain = {"context": retriever | format_docs, "question": RunnablePassthrough()} | prompt | model
chain.invoke(question, config={"callbacks": [handler]})

Four refusals

This is the part worth reading. An instrumentation layer that guesses, or that fails quietly, produces fabricated measurements — which is worse than measuring nothing. So:

Situation What happens Status
The provider reports no token count Nothing is submitted. No estimate is ever made: the API counts nothing on this route, and an invented count would be a fabricated measurement. not_submitted_no_token_count
Your own LLM call failed Nothing is submitted. There is no complete interaction to measure. not_submitted_application_error
The measurement API is down, 401, 402 or 429 Your chain is unaffected and still returns its answer. The failure is reported, never raised. not_submitted_transport_error
sample_rate excluded the run No socket, nothing billed. skipped_sampling

Every decision produces an Outcome. Nothing is silent:

handler = NeoMundiCallbackHandler(..., on_outcome=my_metrics_sink)

for outcome in handler.outcomes:
    print(outcome.status, outcome.submitted, outcome.request_id)

No exception from this handler, the SDK or the network ever reaches your chain. That is tested against a real LCEL chain under six distinct API failures — see tests/test_never_raises.py.

What it costs

🔴 Every submitted observation is a billed measurement. There is no trace-only route on the NeoMundi API: closing a measurement submits POST /v1/govern.

With the default sample_rate=1.0, every LLM call your application makes is metered. On a TIER_03 account that is 0.030 CHF per call. An application serving 10 000 LLM calls a day would meter all 10 000.

Sampling is therefore a first-class control, not an afterthought:

# Measure one call in twenty.
handler = NeoMundiCallbackHandler(..., sample_rate=0.05)

The decision is deterministic in the run id, so a sampled trace is reproducible rather than a coin flip you cannot replay. sample_rate=0.0 opens no socket at all, which makes it a usable kill switch.

handler.submitted_count tells you how many observations were actually billed.

Honest status

Offline test suite 54 tests, green on Python 3.11–3.13. No network, no key, no cost.
Real execution 6 observations submitted to https://api.neomundi.io and 6/6 read back as persisted, from a real LangChain chain driving a real local LLM. See evidence/.
Measurement version Production currently serves 3.5.0, which the SDK deliberately has not yet qualified. The handler warns once per instance. See LIMITATIONS.md.
Maturity Beta. The callback surface is stable; the package is new.

Read LIMITATIONS.md before drawing a conclusion from any score. It is short, and it is not marketing.

How this was built, what broke along the way and what it cost: MISSION_REPORT.md. Why it is worth paying for: VALUE.md.

Reference

NeoMundiCallbackHandler

Parameter Default Meaning
client — An existing neomundi.NeoMundiClient. Mutually exclusive with the two below.
api_key, base_url — Build a client here instead. Both required: the SDK never assumes a host.
sample_rate 1.0 Fraction of runs submitted. Deterministic in the run id.
submit True False measures locally and opens no socket.
mode "OBS" Measurement mode passed through to the API.
metadata None Merged into the observation's metadata.
capture_prompt / capture_response True Set False to keep content in your process.
on_outcome None Called with each Outcome. Its own exceptions are caught.
max_outcomes 256 Bound on retained history.
raise_errors False True re-raises instead of reporting. For debugging only.

Outcome

run_id, status, submitted, request_id, latency_ms, token_count, model_name, measurement_version, reason, error_type.

request_id is the only reliable correlation key against the API. run_id is LangChain's; the server never stores it as an identity. error_type carries the exception class name and never its message, which could contain a prompt.

Running the tests

cd integrations/langchain
pip install -e ".[dev]"
pytest

The examples drive a local Ollama model, which is optional and not a dependency of the package — the handler is provider-agnostic. To run them:

pip install -e ".[dev,examples]"

Offline by design: every test goes through httpx.MockTransport, and the base URL is https://example.invalid (RFC 2606) so a forgotten mock fails DNS rather than reaching a server.

To reproduce the real-execution proof — this spends money:

python scripts/real_execution_proof.py --dry-run     # free
python scripts/real_execution_proof.py --max-billed 10

License

Apache-2.0. See LICENSE.

Metadata

Release files for langchain-neomundi 0.2.0

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

Source distribution (sdist)

Source distribution for langchain-neomundi 0.2.0
File Size Uploaded Provenance Actions
langchain_neomundi-0.2.0.tar.gz 25.5 kB With provenance Details for langchain_neomundi-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for langchain-neomundi 0.2.0
File Interpreter ABI Platform Actions
langchain_neomundi-0.2.0-py3-none-any.whl Python 3 none any Details for langchain_neomundi-0.2.0-py3-none-any.whl

Total release size: 39.3 kB

Release files / langchain_neomundi-0.2.0.tar.gz

Download URL langchain_neomundi-0.2.0.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
5b68f418c37a4078369b936c636b64420d82285482c0a1f506ce8c6eaca6f79b
BLAKE2b-256 checksum
How to use checksums
88200fbba4213a7c6bfbb59a8cbe70fd50c6fff2c45b9e8c5cfb7f63365dd3fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Release files / langchain_neomundi-0.2.0-py3-none-any.whl

Download URL langchain_neomundi-0.2.0-py3-none-any.whl
Size 13.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a892a7e566fe16c85af7b87f503672d5b34d96baf915910dec7c9623116fd00
BLAKE2b-256 checksum
How to use checksums
1ba6acf01e417521473976c4d95ac22236acb47decce82be91f245372f840d0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 26, 2026.

Transparency log

Security for langchain-neomundi 0.2.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for langchain_neomundi-0.2.0.tar.gz

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 Nov 26, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

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