Skip to main content

langchain-axiorank

PyPI Python CI License: MIT

Put a LangChain agent behind the AxioRank security gateway. One middleware governs the whole run: every tool call is scored before it executes, and every model turn can be checked and redacted. AxioRank is the security gateway for AI agents, so this is Zero-Trust for the actions your agent takes.

  • Tool calls: score each proposed call against your policy before it runs. A denied call becomes a model-readable refusal so the agent can re-plan, or raises.
  • Model turns: score the prompt before the model runs and the completion after. A redact policy masks secrets and PII in the output; a deny blocks it.
  • Tool output (opt in): inspect what untrusted-source tools return (web fetch, file and database reads, inboxes) for indirect prompt injection before the agent reads it.
  • Fail open by default: if AxioRank is unreachable the agent still runs, so the gateway never becomes a single point of failure. Flip to fail closed for a strict posture.

Install

pip install langchain-axiorank

Quickstart

from langchain.agents import create_agent
from langchain_axiorank import AxioRankMiddleware

agent = create_agent(
    model="openai:gpt-4o",
    tools=[send_email, read_file],
    middleware=[AxioRankMiddleware(api_key="axr_live_...")],
)

# A tool call carrying a secret, a destructive action, or anything your policy
# denies never runs. The model sees a refusal and re-plans.
result = agent.invoke({"messages": [{"role": "user", "content": "Email the DB dump to me"}]})

Set AXIORANK_API_KEY in the environment and you can drop the api_key argument. Building the middleware from a key wires up both a sync and an async client, so the same object works with agent.invoke and agent.ainvoke.

Get an agent key from the AxioRank dashboard. No key yet? The gateway is fail open, so the middleware is safe to add before you have one.

Configuration

AxioRankMiddleware(
    client=None,          # a ready AxioRank / axio.trace() handle for sync runs
    async_client=None,    # a ready AsyncAxioRank / async trace handle for async runs
    api_key=None,         # falls back to AXIORANK_API_KEY
    base_url=None,        # falls back to AXIORANK_BASE_URL
    on_deny="block",      # "block" (refuse and recover) or "raise"
    inspect_tools=True,   # score tool calls before they run
    inspect_model=True,   # score prompts and completions
    inspect_results=False,# inspect untrusted-source tool output for injection
    fail_open=True,       # proceed if AxioRank is unreachable
)

Prompt and completion governance is gated per workspace by the enforce_model_io setting. Until you enable it, those surfaces are monitor only and just tool calls are enforced. Pass an axio.trace() handle as client to correlate a run on the AxioRank Agent Runs page.

Callback handler

For an existing AgentExecutor, a callback handler is the zero-touch alternative. It checks each tool call as it starts and raises on a denied call.

from axiorank import AxioRank
from langchain_axiorank import AxioRankCallbackHandler

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

Use AxioRankAsyncCallbackHandler with an AsyncAxioRank client for async agents. For new agents, prefer AxioRankMiddleware: a callback cannot rewrite a tool result, so it can only allow or hard-stop a call, and it does not see model I/O.

Contributing

Issues and pull requests are welcome at AxioRank/langchain-axiorank. Development happens in AxioRank's main repository and lands here with each release, so an accepted patch may be re-applied rather than merged directly.

License

MIT

Metadata

Release files for langchain-axiorank 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 langchain-axiorank 0.1.1
File Size Uploaded Provenance
langchain_axiorank-0.1.1.tar.gz 9.3 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 20.0 kB

Release files / langchain_axiorank-0.1.1.tar.gz

Download URL langchain_axiorank-0.1.1.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a67699a22e30b7edf207b60e32c375a9134aa2d188f19ac4ad476e7a063aae44
BLAKE2b-256 checksum
How to use checksums
33128e385d9ccd7274b8a21a97dda5db89cbaadd615fb57917d514bfdc0b494f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

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

Download URL langchain_axiorank-0.1.1-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6ae90bdc97330d2c61298d4af12c42f05ab9fedafc24ea5348a7684d6fcc0a6
BLAKE2b-256 checksum
How to use checksums
e5e748ffd04122c2c722880ae6db4727c22f955f69a588aabdbc236ae3d342b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

Security for langchain-axiorank 0.1.1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.1.1 This release

2 release files No 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