LangChain payment protocol tools for autonomous agents (x402, AP2, etc.)
npm install @xpaysh/agent-kit-langchainLangChain integration for AI agents with autonomous payment capabilities using the x402 protocol.
This package provides LangChain tools and agents that can make micropayments to access premium APIs and services. Build AI agents that autonomously manage their spending while accessing high-quality data sources.
- X402 LangChain Tools: Pre-built tools for payment-protected APIs
- Autonomous Payment Agent: LangChain agent with built-in spending controls
- Cost Tracking: Automatic spending monitoring and reporting
- Pre-configured Services: Weather, crypto prices, news, and data analysis tools
- Custom Tool Support: Easily create your own payment-enabled tools
``bash`
npm install @xpaysh/agent-kit-langchain @xpaysh/agent-kit-core
`typescript
import { X402Agent } from '@xpaysh/agent-kit-langchain';
const agent = new X402Agent({
openaiApiKey: process.env.OPENAI_API_KEY,
privateKey: process.env.PRIVATE_KEY,
network: 'base-sepolia',
enabledTools: ['weather', 'crypto', 'news'],
spendingLimits: {
dailyLimit: 5,
perCallLimit: 0.1
}
});
// Agent can now autonomously pay for API access
const result = await agent.invoke(
"What's the weather in San Francisco and the current Bitcoin price?"
);
console.log('Response:', result.output);
console.log('Total spent:', result.totalCost);
console.log('Breakdown:', result.spendingBreakdown);
``
- WeatherTool: Current weather data ($0.01 per request)
- CryptoPriceTool: Real-time cryptocurrency prices ($0.005 per request)
- NewsApiTool: Latest news articles ($0.02 per request)
- DataAnalysisTool: Advanced data analysis ($0.05 per request)
For comprehensive documentation, guides, and examples, visit:
- Documentation: https://docs.xpay.sh
- Website: https://www.xpay.sh
- npm package
- GitHub repository
- xPay Website
- Full Documentation
MIT © xPay