How it works
Setup
Create a paying fetch
Make requests
UsefetchWithPayment exactly like fetch. When the server returns 402, payment is handled transparently:
Testnet
Usebase-sepolia for development and testing:
Wrapping a custom fetch
If you have a custom fetch (e.g., with auth headers or logging), pass it asfetchFn:
Advanced re-exports
The x402 subpackage re-exports lower-level primitives for custom integrations:Next steps
Wallets & Payments
Generate wallets, check balances, send USDC.
Build an LLM Agent
Combine pay-per-call APIs with your agent’s reasoning loop.
x402 Protocol
The HTTP 402 payment protocol specification.
API Reference
Full x402 API signatures and options.