AI agents are becoming autonomous. But they're missing one critical capability: payments.
This is how we built AgentGatePay - payment infrastructure for the agent economy, with full support for both Python and JavaScript developer ecosystems.
The Problem
AI agents (LangChain, AutoGPT, Claude with MCP) can:
- Research and synthesize information
- Write code and debug
- Interact with APIs
- Make decisions autonomously
But when an agent needs to pay for something (data, APIs, compute), there's no good solution.
Why traditional payments don't work for agents:
- Require company registration (agents don't have companies)
- Need bank accounts (agents don't have bank accounts)
- Built for humans, not autonomous systems
- Slow settlement (2-7 days)
- High fees (2.9% + $0.30)
The Solution: Crypto-Native Agent Payments
1. Multi-Chain From Day One
- Ethereum (security, decentralization)
- Base (low fees, fast)
- Polygon (scalability)
- Arbitrum (L2 benefits)
Same API, different chains. Agent changes ?chain=base query param.
2. Budget Control (AP2 Protocol)
Agents need spending limits. We use mandate tokens:
# Issue mandate - cryptographic budget
mandate = client.mandates.issue(
subject="agent@example.com",
budget_usd=100,
scope="research-api"
)
# Returns signed token
Mandate token is cryptographically signed. Gateway verifies signature + checks budget on every payment.
3. Multiple Payment Flows
Client wallet mode (agent controls key):
# Agent signs transaction
tx = wallet.send_transaction(to=receiver, value=amount)
# Agent submits to gateway
payment = client.payments.submit_tx_hash(mandate_token, tx.hash)
External TX signing (Docker service):
# Agent requests gateway to sign
payment = client.payments.submit_with_tx_service(
mandate_token,
receiver=merchant,
amount_usd=1.00
)
4. Framework Integrations
LangChain (20 examples - 10 Python + 10 JavaScript):
- Basic payments (both languages)
- Marketplace (buyer/seller agents - both languages)
- Monitoring dashboards (both languages)
- TX signing service (both languages)
- Same examples, dual implementation - choose your language
Why both languages?
- Python dominates data science and ML research
- JavaScript dominates web/edge deployment (Vercel, Cloudflare Workers)
- Different use cases require different stacks
- We built native SDKs for both, not just wrappers
JavaScript ecosystem support:
- Works with Vercel AI SDK
- Compatible with LangChain.js
- Any JavaScript AI framework
N8N (4 workflows):
- Buyer agent (autonomous purchasing)
- Seller API (accept payments)
- Monitoring (spending/revenue)
MCP (15 tools):
- Claude Desktop integration
- Issue mandates, submit payments, check status
Technical Architecture
Stack:
- Backend: AWS Lambda (Python 3.12), DynamoDB
- Security: CloudFront + WAF, rate limiting, replay protection
- Blockchain: ethers.js v6 (JavaScript), web3.py (Python)
- SDKs: TypeScript, Python (both open source)
- Gateway fee: 0.5% (transparent on-chain)
Payment Verification Flow:
- Agent executes blockchain transaction (USDC transfer)
- Agent submits tx_hash to gateway
- Gateway verifies on-chain (sender, receiver, amount, token)
- Gateway grants resource access if verified
- Webhook notification sent to merchant
Multi-Chain Abstraction:
Same code, different chains:
// Ethereum
const payment = await client.payments.submitTxHash(
mandateToken, txHash, { chain: 'ethereum' }
);
// Base (same API!)
const payment = await client.payments.submitTxHash(
mandateToken, txHash, { chain: 'base' }
);
Adaptive Retry (Performance Optimization):
- <$1 payments: Optimistic mode (4s total, background verification)
- ≥$1 payments: Synchronous mode (56s max, fraud prevention)
Result: <$1 payments settle in 3-4s, ≥$1 in 10-56s (safe).
Code Examples
LangChain Payment Agent (Python)
from agentgatepay_sdk import AgentGatePay
agp = AgentGatePay(api_url="https://api.agentgatepay.com")
# Issue mandate
mandate = agp.mandates.issue("agent@example.com", budget_usd=100)
# Execute blockchain transaction
tx_hash = execute_blockchain_tx(price)
# Submit to gateway
payment = agp.payments.submit_tx_hash(mandate['mandateToken'], tx_hash)
print(f"Payment verified: {payment['verified']}")
LangChain Payment Agent (JavaScript)
import { AgentGatePay } from 'agentgatepay-sdk';
const agp = new AgentGatePay({
apiUrl: 'https://api.agentgatepay.com',
apiKey: 'pk_live_...'
});
// Issue mandate
const mandate = await agp.mandates.issue('agent@example.com', 100);
// Execute blockchain transaction
const txHash = await executeBlockchainTx(price);
// Submit to gateway
const payment = await agp.payments.submitTxHash(mandate.mandateToken, txHash);
console.log(`Payment verified: ${payment.verified}`);
Same functionality, different language. Choose what fits your stack.
N8N Workflow
- HTTP Request: Trigger on webhook
- AgentGatePay: Issue mandate
- Code: Execute blockchain transaction
- AgentGatePay: Submit payment
- If verified: Proceed to next step
- If failed: Send error notification
What's Next
Roadmap:
- More framework integrations (AutoGPT, CrewAI, expanding Vercel AI SDK examples)
- Additional JavaScript framework examples (Anthropic SDK, OpenAI Node.js)
- Fiat on-ramps (credit cards → crypto)
- More chains (Solana, Avalanche, Optimism)
- Account abstraction (gasless transactions)
- Payment streaming (pay-per-second)
Try It
Install (choose your language):
# JavaScript/TypeScript
npm install agentgatepay-sdk
# Python
pip install agentgatepay-sdk
20 Examples (10 Python + 10 JavaScript): https://github.com/AgentGatePay/agentgatepay-examples
Open source: MIT license
⚠️ Beta status: No SLA/uptime guarantees. Read DISCLAIMER.md.
Conclusion
AI agents need payment infrastructure built FOR them, not adapted from traditional systems.
Crypto-native payments solve this:
- No company/bank needed
- Instant settlement
- Global by default
- Programmable
Why we built for both Python and JavaScript:
The AI ecosystem is split. Python dominates research and data science. JavaScript dominates production web deployments. We didn't want to choose - so we built native SDKs for both.
Whether you're building a research agent in Python or deploying an edge AI agent with Vercel, AgentGatePay has you covered.
We built AgentGatePay to enable the agent economy across all development ecosystems. Try it and let us know what you build!
Links:
- Website: https://www.agentgatepay.com
- GitHub: https://github.com/AgentGatePay/agentgatepay https://github.com/AgentGatePay/agentgatepay-examples
- JavaScript (npm): https://www.npmjs.com/package/agentgatepay-sdk
- Python (PyPI): https://pypi.org/project/agentgatepay-sdk/
- Twitter: @agentgatepay
Questions? Reply below or open a GitHub issue!
Top comments (0)