
Building Pay-Per-Call AI Agents with x402 v2.6.0
x402 v2.6.0 shipped last weekend with native Go, TypeScript, and Python SDK support all landing the same day. If you're building agents that call external APIs, this is worth understanding. The protocol is HTTP-native. An agent hits an endpoint, gets a 402 back with payment instructions in the headers, pays in USDC on Base, then retries with the payment receipt. No login flow, no API keys, no billing dashboard. Here's what that looks like in practice. The flow GET /api/v1/assets/defi-yields-live → 402 Payment Required X-Payment: {...payment instructions...} # agent pays ~$0.01 in USDC GET /api/v1/assets/defi-yields-live X-Payment-Response: {...receipt...} → 200 OK, JSON data TypeScript setup with x402 v2.6.0 Install the SDK: npm install @x402/client @x402/wallet-providers ``` { % endraw % } Wallet setup — you 'll need a CDP wallet (Coinbase Developer Platform): {% raw %} ```typescript import { createWalletClient } from "@x402/client";import { CdpWalletProvider } from "@x402/wallet-prov
Continue reading on Dev.to
Opens in a new tab



