HTTP 402 is not reserved for future use anymore: I put a 1-cent paywall on a live API for AI agents
说明与用途
文章介绍了使用 HTTP 402 和 x402 协议实现的 1 美分付费墙,允许 AI 代理在无需注册或密钥的情况下使用 Base 网络的稳定币支付一次性 API 调用。
问题
Traditional API key models require onboarding and are unsuitable for one‑off AI agent requests, leading to missed payments and high friction.
结果
A live API now accepts 1‑cent payments via stablecoin, eliminating onboarding, chargebacks, and merchant identity requirements, making it viable for small operators and AI agents.
工作流
- 1. Agent sends request to endpoint without payment header.
- 2. Server responds 402 with x402 challenge body (payment requirements).
- 3. Agent signs EIP‑712 authorization for exact amount and retries with X‑PAYMENT header.
- 4. Server verifies signature via facilitator, settles stablecoin transfer, and returns JSON result.
证据
The challenge is public, the paid call costs one cent, and the data behind it is a free CC BY 4.0 dataset.
An agent reads accepts, signs an EIP‑712 authorization for exactly that amount, retries with an X‑PAYMENT header, and gets the JSON.
- 记录日期: 2026-09-22T07:45:25.801Z