Build x402-paying agents in 5 minutes - Complete TypeScript monorepo with working agent examples
agent-kit is an early-stage TypeScript project in the AI payments / x402 ecosystem, focused on agents, ai, langchain, micropayments. It currently has 3 GitHub stars and 6 forks, and sits alongside related tools like mcp-client, pinion-os, dna-x402.
Build payment-enabled agents in 5 minutes
Complete TypeScript monorepo with working agent examples that can autonomously pay for API access using payment protocols like x402, AP2, and more.
Get a working payment-enabled agent in under 5 minutes:
# 1. Clone and install
git clone https://github.com/xpaysh/agent-kit.git
cd agent-kit
pnpm install
# 2. Set up environment
cp .env.example .env
# Edit .env with your keys (see setup section below)
# 3. Start the mock API
npm run docker:up
# 4. Run an example agent
npm run start:demo
Your agent will start making autonomous payments for premium API access! 🎉
This monorepo provides everything you need to build x402-paying agents:
@xpaysh/agent-kit-core - Core payment protocol client with spending controls@xpaysh/agent-kit-langchain - LangChain tools for autonomous payments@xpaysh/agent-kit-testing - Mock payment-protected API server for testing@xpaysh/agent-kit-examples - Working agent implementationsapps/demo - Next.js web interface for testing agentsCreate .env file:
# Required
OPENAI_API_KEY=your_openai_api_key
PRIVATE_KEY=your_ethereum_private_key
# Optional (uses defaults)
FACILITATOR_URL=http://localhost:3000
CHAIN_ID=84532
PAY_TO_ADDRESS=0x742d35Cc6631C0532925a3b8D000cE3D
⚠️ Security: Never use mainnet keys in development. Use testnet only.
Interactive agent that pays for multiple services:
npm run multi-api-agent
# Try asking:
# "What's the weather in Tokyo and current Bitcoin price?"
# "Get me tech news and analyze the sentiment"
# "Compare Ethereum and Bitcoin price trends"
APIs Used:
Automated research workflows:
npm run research-agent
Demonstrates:
Advanced data analysis:
npm run data-agent
Shows:
# Start all services
npm run docker:up
# Development mode
npm run dev
This starts:
Visit http://localhost:3001/api for complete API documentation.
# Build all packages
npm run build
# Run tests
npm run test
# Type check
npm run typecheck
# Lint
npm run lint
agent-kit/
├── packages/
│ ├── core/ # Payment client & utilities
│ ├── langchain/ # LangChain integration
│ ├── mock-api/ # Test API server
│ └── examples/ # Agent implementations
├── apps/
│ └── demo/ # Web interface
└── docker-compose.yml # Local development
sequenceDiagram
participant Agent
participant API
participant Blockchain
Agent->>API: Request data
API->>Agent: 402 Payment Required
Agent->>Blockchain: Pay USDC
Agent->>API: Retry with payment proof
API->>Agent: Return data
import { X402Agent, WeatherTool, CryptoPriceTool } from '@xpaysh/agent-kit-langchain';
const agent = new X402Agent({
openaiApiKey: process.env.OPENAI_API_KEY!,
privateKey: process.env.PRIVATE_KEY!,
spendingLimits: {
dailyLimit: 1.0, // $1/day
perCallLimit: 0.1 // $0.10/call
},
enabledTools: ['weather', 'crypto']
});
const result = await agent.invoke(
"What's the weather in NYC and current Bitcoin price?"
);
import { X402Tool } from '@xpaysh/agent-kit-langchain';
const customTool = new X402Tool({
toolName: 'premium_data',
toolDescription: 'Access premium dataset ($0.10/request)',
apiUrl: 'https://api.example.com/premium',
privateKey: process.env.PRIVATE_KEY!,
spendingLimits: { perCallLimit: 0.10 }
});
For production deployments, use {xpay✦} Smart Proxy to route all your agent's API calls through a managed infrastructure with enterprise-grade spending controls and observability:
import { X402Agent } from '@xpaysh/agent-kit-langchain';
const agent = new X402Agent({
openaiApiKey: process.env.OPENAI_API_KEY!,
// Point all API calls through Smart Proxy
proxyConfig: {
proxyUrl: 'https://proxy.xpay.sh/your-customer-id/your-agent-id',
apiKey: process.env.XPAY_API_KEY!
},
spendingLimits: {
dailyLimit: 50.0, // $50/day managed by Smart Proxy
perCallLimit: 5.0 // $5/call safety limit
}
});
// All API calls are automatically:
// ✅ Routed through Smart Proxy
// ✅ Payment-enabled (x402/AP2)
// ✅ Spending-controlled
// ✅ Logged and monitored
// ✅ Cached for performance
const result = await agent.invoke(
"Get weather for London, crypto prices for BTC/ETH, and latest tech news"
);
Benefits:
Smart Proxy Features:
Learn more about Smart Proxy →
Part of the {xpay✦} opensource ecosystem:
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
git clone https://github.com/xpaysh/agent-kit.git
cd agent-kit
pnpm install
npm run dev
MIT License - see LICENSE for details.
🚀 Built by {xpay✦} - Enabling autonomous agents to pay for services across all payment protocols
Discover and pay AI agents on nullpath's marketplace via MCP. x402 micropayments with USDC.
Client SDK, Claude plugin and skill framework for the Pinion protocol. x402 micropayments on Base.
DNA — Payment rails for AI agents. x402 micropayment protocol on Solana. Netting, transfer, stream settlement. Receipt anchoring on-chain.
The agent-native LLM router for OpenClaw. 41+ models, <1ms routing, USDC payments on Base & Solana via x402.
The AI agent with a wallet — spends USDC autonomously to get real work done. Apache-2.0, TypeScript.
DePIN for Vintage Hardware — Proof-of-Antiquity blockchain where old machines outmine new ones. AI-powered hardware fingerprinting, 15+ CPU architectures, Solana bridge (wRTC). $0 VC.
🚀 Curated list of x402 resources: HTTP 402 Payment Required protocol for blockchain payments, crypto micropayments, AI agents, API monetization. Includes SDKs (TypeScript, Python, Rust), examples, facilitators (Coinbase, Cloudflare), MCP integration, tutorials. Accept USDC payments with one line of code. Perfect for AI agent economy.
Client SDK for the Vybe x402 API. Pay-per-call USDC over HTTP and prepaid-credit WebSocket streaming for Vybe's Solana analytics API. Built for AI agents.
The neutral micropayment router for autonomous agents. A single HTTP client that intercepts '402 Payment Required', routes across x402, L402, and MPP, persists credentials as recoverable assets, enforces per-envelope budgets, and emits a structured trace.