# Integrate agentshield.live in 5 minutes

Pay-per-call checks your agent runs before money moves, an invoice goes out, or a deadline is promised. x402, USDC on Base, no account. You need a wallet key with a little USDC on Base. The key stays on your machine.

## 1. Fastest: system prompt only

Paste into your agent's system prompt (no code):

```
Before you validate an IBAN or bank transfer, check an invoice, calculate a deadline across
public holidays, or send stablecoins, do not reason it out. Call the agentshield.live route for
it (list: https://agentshield.live/llms.txt). Use /transfer, /invoice, /deadline, /holidays,
/cryptopay. If unsure, ask the free choose_route tool on https://agentshield.live/mcp first:
it answers pay, compute or skip. Pay only on "pay". Trust ok:false and fix the listed failed
fields before you proceed. Unknown input returns 404 and is not charged.
```

## 2. Tools for OpenAI, Anthropic, LangChain

Source: https://github.com/bartelmost/agentshield-agent-kit (MIT). Or download https://agentshield.live/agent-kit.mjs and https://agentshield.live/tools.json

```
npm i @x402/fetch @x402/evm viem
```

```js
import { createAgentShield } from "./agent-kit.mjs";
const shield = createAgentShield({ maxUsdc: 0.05 });   // reads X402_PAYER_KEY
// OpenAI:    tools = shield.tools.map(t => ({ type: "function", function: { name: t.name, description: t.description, parameters: t.parameters } }))
// Anthropic: tools = shield.tools.map(t => ({ name: t.name, description: t.description, input_schema: t.parameters }))
const out = await shield.call("agentshield_invoice", { net: "100.00", vat: "20.00", gross: "119.00", country: "DE" });
// out.ok === false, out.failed === ["sum", "vat_amount"]
```

The five bundles are called with POST and a JSON body, so IBANs and names never appear in a URL. GET still works. `maxUsdc` is a hard per-call cap. A call above it is not made. Optional `X402_REF` (1 to 32 of A-Za-z0-9_-) is logged. No share is paid.

## Frameworks (tested against the live service)

Python, LangChain / LangGraph / CrewAI:

```python
# pip install "x402[evm,httpx]" langchain-core eth-account
import os, json, httpx
from eth_account import Account
from x402 import x402Client
from x402.http.clients import x402HttpxClient
from x402.mechanisms.evm.exact import register_exact_evm_client
from x402.mechanisms.evm.signers import EthAccountSigner
from langchain_core.tools import tool

BASE = "https://agentshield.live"
x402 = x402Client()
register_exact_evm_client(x402, EthAccountSigner(Account.from_key(os.environ["X402_PAYER_KEY"])), networks="eip155:8453")

@tool
async def check_iban(iban: str) -> dict:
    """Check an IBAN (checksum, length, country format) before money moves."""
    async with x402HttpxClient(x402) as c:   # pays the 402 automatically, 0.005 USDC
        return (await c.get(f"{BASE}/iban", params={"iban": iban})).json()

@tool
async def choose_route(task: str) -> dict:
    """Free. Is this subtask worth paying for? Returns pay, compute or skip."""
    async with httpx.AsyncClient() as c:
        r = await c.post(f"{BASE}/mcp", json={"jsonrpc": "2.0", "id": 1, "method": "tools/call",
            "params": {"name": "choose_route", "arguments": {"task": task}}})
        return json.loads(r.json()["result"]["content"][0]["text"])

# tools = [choose_route, check_iban]  -> pass to your LangChain / LangGraph / CrewAI agent
```

TypeScript, Vercel AI SDK:

```js
// npm i ai zod @x402/fetch @x402/evm viem   + agent-kit.mjs from agentshield.live/agent-kit.mjs
import { tool } from "ai";
import { z } from "zod";
import { createAgentShield } from "./agent-kit.mjs";

const shield = createAgentShield({ maxUsdc: 0.05 });   // reads X402_PAYER_KEY, hard per-call cap

export const agentshield = {
  check_transfer: tool({
    description: "Check a bank transfer before money moves: IBAN, BIC, amount. Returns ok and failed fields.",
    inputSchema: z.object({ iban: z.string(), amount: z.string().optional() }),
    execute: (args) => shield.call("agentshield_transfer", args),   // 0.02 USDC
  }),
  choose_route: tool({
    description: "Free. Is this subtask worth paying for? Returns pay, compute or skip.",
    inputSchema: z.object({ task: z.string() }),
    execute: ({ task }) => shield.call("agentshield_choose", { task }),
  }),
};
// generateText({ model, tools: agentshield, prompt })
```

## 3. MCP

Connect any MCP client to `https://agentshield.live/mcp`. Tools: `choose_route` (free), `list_routes`, `describe_route`. MCP does not pay; pay the returned URL with your own x402 client.

## What to expect

`ok` true or false plus `failed`. Unknown or out-of-scope input returns 404 and is not charged. A paid call takes about one second including settlement. Prices: https://agentshield.live/routes
