L402 Setup
Install and configure the Axo pay-per-call stack with Axo Pay, Axo Fetch, and Axo CLI.
Use this page to stand up the full pay-per-call flow quickly.
1) Install Packages
npm install @axobot/paynpm install @axobot/fetchnpm install -g @axobot/cli2) Configure Environment
| Variable | Required | Default | Used By |
|---|---|---|---|
ZBD_API_KEY | Yes | none | Axo Pay, Axo Fetch example, axo |
ZBD_API_BASE_URL | No | https://api.zbdpay.com | Axo Pay, Axo CLI |
ZBD_WALLET_TOKEN_CACHE | No | ~/.zbd-wallet/token-cache.json | axo fetch |
Info
Axo Pay can also take apiKey directly in PaymentConfig. If omitted, it falls back to ZBD_API_KEY.
3) Initialize Wallet Identity (Optional but Recommended)
axo init --key <your_api_key>
axo info
axo balance4) Run the End-to-End Local Demo
From the agents workspace:
npm --prefix axobot-pay run build
ZBD_API_KEY=<your_api_key> npm --prefix axobot-pay run example:http-serverIn a second terminal:
npm --prefix axobot-fetch run build
PROTECTED_URL="http://localhost:8787/protected" ZBD_API_KEY=<your_api_key> npm --prefix axobot-fetch run example:zbdOr use wallet CLI directly:
axo fetch "http://localhost:8787/protected" --max-sats 1005) Understand Package Roles
@axobot/pay: generates invoice challenge + verifies payment proof on incoming requests.@axobot/fetch: handles402parsing, invoice payment hook, retry with proof, and token caching.@axobot/cli: CLI workflows (axo) includingaxo fetchpowered by Axo Fetch.