AxioRank Docs

LangChain

Put every tool a LangChain agent runs behind the AxioRank gateway.

The Python SDK ships a LangChain integration. Install the extra:

pip install "axiorank[langchain]"

Zero-touch: a callback handler

Attach AxioRankCallbackHandler and every tool the agent runs is checked first. A denied call raises AxioRankDeniedError, aborting the step.

from axiorank import AxioRank
from axiorank.integrations.langchain import AxioRankCallbackHandler

axio = AxioRank(api_key="axr_live_...")

agent_executor.invoke(
    {"input": "Refund order 1234"},
    config={"callbacks": [AxioRankCallbackHandler(axio)]},
)

For async agents, use AxioRankAsyncCallbackHandler with an AsyncAxioRank client.

Why it raises

A callback can allow a tool to run or stop it — it can't substitute the tool's output. So a blocked call raises. If you want the agent to recover from a denial, wrap the tool instead (below).

Per-tool: a model-readable refusal

guard_tool wraps a single tool. With on_deny="return", a denied call returns a short refusal string the model can read and react to, instead of raising.

from axiorank.integrations.langchain import guard_tool

safe_tool = guard_tool(my_tool, axio, on_deny="return")
# safe_tool runs the gateway check, then the original tool on allow.

Pass async_client=AsyncAxioRank(...) to guard a tool's async path too.

Next steps

On this page