AxioRank Docs
Integrations

LangChain · LangGraph

Put every tool a LangChain agent runs behind the AxioRank gateway, in TypeScript or Python.

The SDK ships LangChain adapters for both languages. They also cover LangGraph, which builds on the same tools.

npm install @axiorank/sdk @langchain/core

guardTools wraps a tools array so each call's arguments are scored before the tool runs. The guarded tool keeps the original name, description, and schema, making it a drop-in anywhere the original is used (LangChain or LangGraph).

import { AxioRank } from "@axiorank/sdk";
import { guardTools } from "@axiorank/sdk/langchain";
import { createReactAgent } from "@langchain/langgraph/prebuilt";

const axio = new AxioRank({ apiKey: process.env.AXIORANK_API_KEY! });

const agent = createReactAgent({
  llm,
  tools: guardTools(myTools, axio, { onDeny: "return" }),
});

Why wrap, not a callback

LangChain.js runs callback handlers on an async queue and executes the tool regardless of a handler throwing, so a callback can't reliably block a call. Wrapping the tool scores it before it runs. onDeny: "return" lets the model read the refusal as the tool result and re-plan.

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")

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

Next steps

On this page