Universal HTTP 402 Micropayment Protocol & CLI for Autonomous AI Agents
pip install apay==0.1.5 Copy PIP instructions
The Universal Micropayment & Economic Layer for Autonomous AI Agents
A-Pay is an ultra-lightweight, zero-latency, open economic rail designed for the machine-to-machine (M2M) economy. Just as UPI revolutionized human digital payments in India, A-Pay enables autonomous AI software agents to discover, consume, and pay for data, compute, APIs, and micro-services on the fly—without credit cards, human KYC, or seed phrase friction.
Protect ANY existing website or API with an instant HTTP 402 crypto paywall—zero code modifications required:
apay protect --target http://localhost:8000 --price 0.001 --wallet 0xYourWalletAddress Incoming requests from AI bots will automatically receive an HTTP 402 Payment Required challenge. Once the AI agent's cryptographic micropayment is verified (<15ms), the request is forwarded to your server and data is unlocked! 2. AI Agent Developers (The Buyers) Give your AI agent an in-memory wallet and strict spending guardrails with 2 lines of code:
from apay import APaySession, AgentWallet # Generate or load wallet with daily safety limit wallet = AgentWallet(private_key="0x...", max_per_call_usdc=0.01, daily_budget_usdc=5.0) session = APaySession(wallet) # Automatically handles HTTP 402 challenges & settles on the fly response = session.get("https://protected-api.com/market-data") print(response.json()) 📦 Directory Structure apay/ ├── src/ │ └── apay/ │ ├── __init__.py # Package exports │ ├── cli.py # ⚡ 1-Command CLI (`apay protect`, `apay wallet new`, `apay pay`) │ ├── client.py # 🤖 Auto-settling HTTP client (sync & async) │ ├── wallet.py # 🔐 In-memory wallet + local spending limits │ ├── proxy.py # 🛡️ Ultra-light reverse proxy paywall (Starlette + EIP-712) │ ├── relayer.py # 📊 Settlement journal & batch relayer │ └── integrations/ # 🔗 LangChain & CrewAI agent wrappers ├── contracts/ # Base Sepolia Smart Contracts (APAYToken & APayRouter) ├── tests/ # Automated integration & security test suite ├── spec/ # RFC wire format & security model specifications └── pyproject.toml # Hatchling packaging configuration 🛠️ Installation & Quickstart # 1. Install A-Pay via pip pip install apay # 2. Generate a new Agent Wallet with spending limits apay wallet new # 3. Protect any website or API with an instant HTTP 402 Paywall apay protect --target http://localhost:8000 --price 0.001 --wallet 0xYourPayoutWalletAddress A-Pay is an open-source decentralized economic protocol for autonomous machine agents. Built on Base L2.
ai-agents autonomous-agents base-l2 http-402 m2m-economy micropayments paywall usdc
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.




