Official Python SDK for AxioRank. Zero-Trust for AI agents: route every tool call through one governed control plane.
Project description
axiorank
Official Python SDK for AxioRank, the Zero-Trust control plane for AI agents. Route your agent's tool calls through one governed gateway so policies are enforced, risk is scored, and every call is audited.
Parity with the TypeScript @axiorank/sdk.
Install
pip install axiorank
Quickstart (sync)
import os
from axiorank import AxioRank
axio = AxioRank(api_key=os.environ["AXIORANK_API_KEY"]) # looks like axr_live_...
# Get the decision and act on it yourself:
result = axio.tool_call("github.push", {"repo": "myrepo"})
if result.decision == "deny":
print(f"Blocked: {result.reason} (risk {result.risk})")
else:
... # proceed with the real tool call
enforce(): guard in one line
from axiorank import AxioRank, AxioRankDeniedError
axio = AxioRank(api_key=os.environ["AXIORANK_API_KEY"])
try:
axio.enforce("aws.delete_bucket", {"name": "prod-data"})
delete_bucket("prod-data") # only runs if AxioRank allowed it
except AxioRankDeniedError as e:
log.warning("AxioRank blocked the call: %s", e.result.reason)
A require_approval policy holds the call for a human; tool_call/enforce
transparently wait out the hold and resolve to the final allow/deny.
Quickstart (async)
import os
from axiorank import AsyncAxioRank
async def main():
async with AsyncAxioRank(api_key=os.environ["AXIORANK_API_KEY"]) as axio:
result = await axio.tool_call("stripe.refund", {"amount": 5000})
print(result.decision, result.risk)
Preflight an external server before trusting it
result = axio.verify_card(url="https://mcp.acme.com")
print(result.decision, result.identity.signature_valid, result.protocol)
# Or guard in one line; raises AxioRankCardDeniedError on `deny`:
axio.enforce_card(url="https://mcp.acme.com")
Anthropic Messages API
The Anthropic SDK doesn't run your tools; your loop does. Guard the dispatch
step and send back the tool_result dicts it returns. Defaults to
on_deny="return"; the adapter never imports anthropic itself.
import anthropic
from axiorank import AxioRank
from axiorank.integrations.anthropic import guard_tool_handlers
client = anthropic.Anthropic()
axio = AxioRank(api_key=os.environ["AXIORANK_API_KEY"])
dispatch = guard_tool_handlers({"deploy": lambda i: deploy(i["service"])}, axio)
msg = client.messages.create(model="claude-opus-4-8", tools=tools, messages=messages)
results = [dispatch(b) for b in msg.content if b.type == "tool_use"]
# send `results` back as the next user message
Async client? Use guard_tool_handlers_async (or guard_tool_use /
guard_tool_use_async to guard a single block).
LangChain
pip install "axiorank[langchain]"
from axiorank import AxioRank
from axiorank.integrations.langchain import AxioRankCallbackHandler
axio = AxioRank(api_key=os.environ["AXIORANK_API_KEY"])
# Every tool the agent runs is checked against your policies first; a blocked
# tool raises and the step fails.
agent_executor.invoke(
{"input": "..."},
config={"callbacks": [AxioRankCallbackHandler(axio)]},
)
Prefer a model-readable refusal over a raised exception? Wrap individual tools:
from axiorank.integrations.langchain import guard_tool
safe_tool = guard_tool(my_tool, axio, on_deny="return")
LlamaIndex
pip install "axiorank[llamaindex]"
from axiorank.integrations.llamaindex import guard_tool
# Wrap any FunctionTool: its arguments are scored before it runs, and the
# schema, name, and description are preserved, so it is a drop-in replacement.
safe_tool = guard_tool(my_tool, axio) # raises on deny
recoverable = guard_tool(my_tool, axio, on_deny="return") # model-readable refusal
Pydantic AI
pip install "axiorank[pydantic-ai]"
from axiorank.integrations.pydantic_ai import guard_tool
# Wrap a Tool; its name, description, and signature (schema) are preserved.
safe_tool = guard_tool(my_tool, axio) # sync tool
safe_async = guard_tool(my_tool, async_client=axio_async) # async tool
OpenAI Agents (Python)
pip install "axiorank[openai-agents]"
from axiorank import AsyncAxioRank
from axiorank.integrations.openai_agents import guard_tool
axio = AsyncAxioRank(api_key=os.environ["AXIORANK_API_KEY"])
# The SDK runs tools async; a deny returns a refusal the model can re-plan around.
safe_tool = guard_tool(my_function_tool, axio, on_deny="return")
Configuration
| Argument | Default | Notes |
|---|---|---|
api_key |
- (required) | Your agent's key (axr_live_...). |
base_url |
https://app.axiorank.com |
Point at your own deployment. |
timeout |
10.0 |
Per-request timeout, in seconds. |
approval_timeout |
300.0 |
Max wait for a human to resolve a hold, seconds. |
client |
a fresh httpx.Client |
Inject your own httpx client (tests, proxies). |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file axiorank-0.7.1.tar.gz.
File metadata
- Download URL: axiorank-0.7.1.tar.gz
- Upload date:
- Size: 25.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f5fd1b3818a67dd4630822d864780a751f3e152320b810d2a40eaa679f9927c
|
|
| MD5 |
88c5ff8500c637fd083c7834df9e3fee
|
|
| BLAKE2b-256 |
7a250ff1fb0a398d0207c404108a87d377811a221b8af03fb6cb0f5e936b020f
|
File details
Details for the file axiorank-0.7.1-py3-none-any.whl.
File metadata
- Download URL: axiorank-0.7.1-py3-none-any.whl
- Upload date:
- Size: 37.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a5981f4150adc2920c58154605dfc26c8714bf698c16cb31bd51197a8fa7225
|
|
| MD5 |
5b927d0e1c2cb855c1f253d59ffcdd78
|
|
| BLAKE2b-256 |
5437837e24c455c2d0589dfb3e8cc71b894575e69f9b55253d115c8b0f5779d5
|