PydanticAI Integration
Protect PydanticAI tools with direct Veto API checks.
PydanticAI is a Python framework. The local package in this repository is the TypeScript veto-sdk, so it does not currently publish veto.integrations.pydanticai.
Use a small API guard around PydanticAI tool handlers until a Python SDK is published.
Guard a PydanticAI tool
import httpx
import os
from pydantic_ai import Agent
agent = Agent("openai:gpt-4.1")
async def veto_guard(tool_name: str, args: dict):
response = await httpx.AsyncClient().post(
"https://api.veto.so/v1/validate",
headers={"X-Veto-API-Key": os.environ["VETO_API_KEY"]},
json={"toolName": tool_name, "arguments": args},
timeout=10,
)
response.raise_for_status()
decision = response.json()
if decision["decision"] != "allow":
raise RuntimeError(decision.get("reason") or decision["decision"])
@agent.tool_plain
async def transfer_funds(amount: float, to_account: str) -> str:
await veto_guard("transfer_funds", {
"amount": amount,
"to_account": to_account,
})
return f"Transferred ${amount} to {to_account}"Register tools for Charter
Use the TypeScript SDK, CLI, or API to register the tool schema so Charter can compile policies against it:
import { Veto } from "veto-sdk";
const veto = await Veto.init();
await veto.registerTools([
{
name: "transfer_funds",
description: "Transfer money between accounts",
parameters: [
{ name: "amount", type: "number", required: true },
{ name: "to_account", type: "string", required: true },
],
},
]);
const res = await fetch("https://api.veto.so/v1/charter/turn", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Veto-API-Key": process.env.VETO_API_KEY!,
},
body: JSON.stringify({
message: "Transfers over $1,000 require finance approval.",
mode: "compile",
surface: "api",
}),
});
const draft = await res.json();Charter returns a verification link for policy-changing results; the policy is not live until approved.

