AgentForge with the Vercel AI SDK
DeFi safety tools for AI SDK agents, paid per call in USDC over x402. No API key or account.
Install
npm install agentforge-tools ai
Use
import { generateText, isStepCount } from 'ai';
import { agentForgeAiSdkTools } from 'agentforge-tools/ai-sdk';
const { text } = await generateText({
model: 'anthropic/claude-haiku-5.5',
tools: agentForgeAiSdkTools({
privateKey: process.env.AGENTFORGE_PRIVATE_KEY as `0x${string}`, // Base wallet holding USDC
maxPaymentUsd: 0.1, // refuse any single payment above $0.10
}),
stopWhen: isStepCount(5),
prompt: 'Is 0x71927529167fde40ebd4d2acdabfc88afd340f35 close to liquidation on Aave?',
});
console.log(text);
agentForgeAiSdkTools() returns every tool below as an AI SDK tool() with a JSON Schema input, keyed by name. Pass a subset if you only want some: const { agentforge_simulate_transaction } = agentForgeAiSdkTools(opts).
How payment works
Each tool calls an AgentForge HTTPS endpoint. The endpoint answers with HTTP 402 and its exact price; the package signs a USDC payment authorization from your wallet (gasless, x402 exact scheme on Base) and retries. Any single payment above maxPaymentUsd is refused before anything is signed, and calls that fail (4xx/5xx) are never charged. The wallet only needs USDC on Base — no ETH for gas.
Already have an x402-paying fetch (for example a Coinbase CDP wallet)? Pass it instead of a key: agentForgeAiSdkTools({ fetch: myPayingFetch }).
Tools
| Tool | What it does | Price |
|---|---|---|
agentforge_simulate_transaction | Simulate 1-5 EVM transactions before signing: revert reasons, assets leaving or entering the wallet, approvals granted, counterparty sanctions/scam screening, proceed/caution/avoid | $0.005 |
agentforge_check_addresses | Screen 1-100 EVM or Solana addresses against OFAC sanctions, scam wallets, and fresh address-poisoning wallets | $0.003 + $0.001/extra |
agentforge_trade_check | Rug-check metrics, AI risk assessment, and gas for a token, with a verdict | $0.025 |
agentforge_new_launches | Newly launched tokens on Base, Ethereum, or Arbitrum, already risk-scored; poll with since | $0.005 |
agentforge_score_tokens | Risk scores for 2-25 tokens in one call | $0.004/token |
agentforge_lending_health | Aave v3 liquidation risk on nine chains | $0.003 |
agentforge_approval_scan | Risky ERC-20 approvals held on a wallet | $0.015 |
agentforge_decode_transaction | Plain-English decode of an EVM transaction | $0.05 |
No wallet yet?
Every tool is also available free (up to a daily cap) over MCP at https://agentforge-taupe.vercel.app/mcp, which the AI SDK can consume with its MCP client.