x402 Explained: HTTP‑Native Micropayments for AI Agents (With Real Code)
说明与用途
x402 让自治代理通过 HTTP 标头支付服务调用,消除了对静态密钥和复杂计费方案的需求。
问题
AI agents need to pay for service calls without carrying static credentials or managing billing cycles, which clashes with their stateless, transient nature.
结果
Agents can perform stateless, per‑request payments using only HTTP headers and standard cryptographic signing, reducing credential overhead and enabling usage‑based pricing.
工作流
- 1. Agent sends initial HTTP request to service.
- 2. Service responds 402 Payment Required with a Pay header describing amount, token, and payload.
- 3. Agent builds payload (request‑id|timestamp), signs concatenated fields with its private key.
- 4. Agent retries request adding Pay header with signature.
- 5. Service verifies signature and token balance, then returns 200 OK with resource.
证据
Traditional monetisation (API keys, subscription tiers, or invoicing) forces the agent to carry static credentials, manage billing cycles, or wait for human‑approved invoices.
The x402 proposal (an extension of the HTTP 402 Payment Required status) solves this by turning payment into a first‑class HTTP concern.
- 记录日期: 2026-09-15T04:45:57.161Z