langgraph-xai
langgraph-xai is a provider-neutral explainability layer for LangGraph
applications. It turns observable graph execution into structured execution,
provenance, evidence, decisions, attribution, policy-aware disclosure, and
human-readable explanations.
It is not an observability platform, a LangGraph replacement, a security middleware framework, or a chain-of-thought recorder. LangSmith, Langfuse, and OpenTelemetry are complementary integrations.
Installation
pip install langgraph-xai
The Python import namespace is:
from langgraph_xai import XAIRuntime
Optional integrations are isolated:
pip install "langgraph-xai[postgres]"
pip install "langgraph-xai[langsmith]"
pip install "langgraph-xai[langfuse]"
pip install "langgraph-xai[otel]"
pip install "langgraph-xai[llm-openai]"
Quickstart
from langgraph.graph import END, START, StateGraph
from langgraph_xai import XAIRuntime
builder = StateGraph(dict)
builder.add_node("answer", lambda state: {**state, "answer": "observable result"})
builder.add_edge(START, "answer")
builder.add_edge("answer", END)
xai = XAIRuntime(application_id="support", tenant_id="tenant-a")
graph = xai.instrument(builder.compile())
result = await graph.ainvoke({"question": "Why?"})
Runtime behavior is configured explicitly per instance. There is no global
XAI_ENABLED environment switch:
from langgraph_xai import CaptureMode, FailureMode, XAIConfig, XAIRuntime
xai = XAIRuntime(
config=XAIConfig(
capture_state=CaptureMode.DELTA,
failure_mode=FailureMode.FAIL_OPEN,
llm_explanation_enabled=False,
)
)
Structured explanations are the default. LLM explanations require both a
registered LLMExplanationEngine and
XAIConfig(llm_explanation_enabled=True). They consume only policy-filtered,
structured XAI context and never request or store chain-of-thought.
Development
uv sync
uv run ruff check .
uv run ruff format --check .
uv run pyrefly check
uv run pytest
Documentation diagrams use a global pinned Mermaid CLI rather than local
node_modules:
npm install --global @mermaid-js/mermaid-cli@11.17.0
node scripts/render-diagrams.mjs
node scripts/render-diagrams.mjs --check
The project requires Python 3.12 or newer and is licensed under Apache-2.0.
Release files for langgraph-xai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| langgraph_xai-0.1.0.tar.gz | 36.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| langgraph_xai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 85.8 kB
Release files / langgraph_xai-0.1.0.tar.gz
| Download URL | langgraph_xai-0.1.0.tar.gz |
|---|---|
| Size | 36.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b36128349b87edae728c22d02ef517ef6b82b1a4806e6d561497e497f4185eb7
|
|
BLAKE2b-256 checksum How to use checksums |
d12e55b07d382e237516f91e46f523614771b70fc00a302ceb600c0ed661e126
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / langgraph_xai-0.1.0-py3-none-any.whl
| Download URL | langgraph_xai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 49.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31888d8ae8492d73c94cf588d78b363588deacf6369e5c652cf27cc60c3e6305
|
|
BLAKE2b-256 checksum How to use checksums |
b587f34fafeca18970497d9567f5e400cf6cce29bc45b977b7a8ba0cc664dfd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.15 {"installer":{"name":"uv","version":"0.12.15","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|