AI 智能體如何透過 x402「upto」付款,在 Base 按次支付 AI 服務費
How AI agents can pay for AI services per call: x402 "upto" payments on Base
x402 的「upto」付款方案讓 AI 智能體可按次支付 AI 服務費:付款者簽署支付上限,服務按實際用量結算,且不得超額扣款。例子中,付款上限為 5 ARL,服務只結算 1.37 ARL;ERC-8004 提供鏈上身份和評分,ERC-8183 以託管處理較長任務。ARL Protocol 已把相關機制整合至 Base,並以開源形式在 Base Sepolia testnet 上線。
A ceiling the payer signs, a metered amount the service settles, and no API keys
Most AI services still sell access the way SaaS did in 2015: an account, an API key, a monthly plan and an invoice. That works for a human team. It does not work for an AI agent that needs to call a model it found a minute ago, pay for 3,000 tokens and move on.
The problem with fixed-price payments
HTTP 402 "Payment Required" has existed since the 1990s. The x402 standard finally gives it a format: a service answers 402 with its price, and the client retries with a signed payment. The catch is that AI usage is rarely known in advance. A request might use 200 tokens or 20,000.
"upto": sign a ceiling, settle the meter
The x402 upto scheme solves this. The payer signs an authorization for at most a ceiling, for example 5 ARL. The service does the work, measures it and settles only the metered amount, for example 1.37 ARL. The signature names the payee and can be used once. The service cannot take more than the ceiling, and cannot pay itself twice.
Who is the service? ERC-8004
Paying per call only works if the agent can trust whom it is paying. ERC-8004 gives services and compute providers an on-chain identity, with feedback and ratings that other agents can read before they pay.
Longer work: ERC-8183 escrowed jobs
Some tasks, such as a training run or a batch of renders, take hours. For these, ARL uses ERC-8183 jobs. The client locks the payment in escrow with a deadline, the provider delivers, and the escrow releases the payment or refunds it.
Try it
ARL Protocol puts these pieces together on Base. Everything is open source and live on the Base Sepolia testnet. At arlcoin.io/app you can take testnet ARL from the faucet, pay a demo service with an x402 upto payment, post an escrowed job and stake. Testnet tokens have no value.
- Code: github.com/armanalabsai/arlcoin.io
- Docs: arlcoin.io/docs
- Community: t.me/arlcoin_community · X @arlprotocol
Originally published on Medium: https://medium.com/@armanalabsai/how-ai-agents-can-pay-for-ai-services-per-call-x402-upto-payments-on-base-4cd395e3d08f
來源:DEV Community · dev.to