Integrations
Pydantic AI
Guard a Pydantic AI tool with AxioRank before it runs.
guard_tool wraps a Pydantic AI Tool so its arguments are scored by AxioRank
before the tool function runs. The name, description, and function signature (and
so the generated JSON schema) are preserved, making the result a drop-in tool.
Install
pip install "axiorank[pydantic-ai]"Guard a tool
A sync tool needs client; an async tool needs async_client. The adapter
detects which from the wrapped function.
from axiorank import AxioRank
from axiorank.integrations.pydantic_ai import guard_tool
from pydantic_ai import Agent
from pydantic_ai.tools import Tool
axio = AxioRank(api_key="axr_live_...")
def deploy(service: str) -> str:
return do_deploy(service)
agent = Agent(
"openai:gpt-4.1",
tools=[guard_tool(Tool(deploy), axio, on_deny="return")],
)Recover or fail
on_deny="return" returns a short, model-readable refusal the agent can re-plan
around. The default, on_deny="raise", raises AxioRankDeniedError instead.
Next steps
- Framework integrations: the shared model and
axio.trace(). - Python SDK: the underlying client.