@xpaysh/agent-kit-langchain
v0.1.1
Published
LangChain payment protocol tools for autonomous agents (x402, AP2, etc.)
Maintainers
Readme
@xpaysh/agent-kit-langchain
LangChain integration for AI agents with autonomous payment capabilities using the x402 protocol.
Overview
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.
Features
- 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
Installation
npm install @xpaysh/agent-kit-langchain @xpaysh/agent-kit-coreQuick Start
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);Available Tools
- 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)
Documentation
For comprehensive documentation, guides, and examples, visit:
- Documentation: https://docs.xpay.sh
- Website: https://www.xpay.sh
Links
License
MIT © xPay
