Accept x402-style payments from AI agents
A practical integration guide for API providers, MCP server operators, and developer-tool companies that want agents to pay per request without forcing humans through subscriptions, dashboards, or manual approvals.
1. Why agent payments need different rails
Subscriptions and API keys were designed for human-managed accounts. AI agents behave differently: they fan out across tools, make small paid calls mid-workflow, retry quickly, and need machine-readable receipts. If the agent has to wait for a human to pick a pricing tier, the workflow is already broken.
x402-style flows move payment negotiation into HTTP itself. The API can say: this endpoint costs this amount, in this asset, to this recipient. The agent can check its policy, sign authorization, retry, and continue.
2. The smallest viable x402-style flow
- 1. Agent requests a paid endpoint. The first request has no payment proof.
- 2. API returns payment requirements. Respond with HTTP 402-style metadata: amount, asset, chain, recipient, expiry, and resource ID.
- 3. Agent checks policy. The client verifies budget, allowlists, max price, asset, chain, and recipient before signing.
- 4. Agent retries with authorization. The signed payment proof is attached to the retry request.
- 5. Server verifies and returns the resource. Settlement can happen synchronously through a facilitator or asynchronously with receipt state.
3. Pricing, budgets, and policy controls
A good provider integration exposes prices that software can reason about. Avoid vague “contact sales” flows for agent entry points. Start with deterministic prices for one or two high-value endpoints.
Per request
$0.001–$0.05 for low-cost data/tool calls.
Per result
Charge only when the endpoint returns a useful answer.
Per compute unit
Useful for model, indexing, simulation, or research APIs.
Channel pricing
Use AMP-style channels when one agent makes hundreds of calls per session.
On the client side, every payment should pass a policy engine: per-call cap, daily cap, approved recipients, allowed chains/assets, endpoint category, and expiry. A wallet signs; a policy engine decides whether it should.
4. Receipts, settlement, and audit
The payment is not finished when the signature is produced. Production teams need a receipt surface that finance, compliance, and developers can query later.
{
"receipt_id": "rcpt_01h...",
"request_id": "req_01h...",
"amount": "0.025",
"asset": "USDC",
"chain": "base",
"recipient": "0xprovider...",
"signer": "0xagent...",
"resource": "/v1/research/report",
"status": "settled",
"settlement_ref": "0xtransaction...",
"created_at": "2026-07-19T10:00:00Z"
}At minimum expose GET /receipts/:id and GET /usage?address=...&from=...&to=.... Agent customers will ask for audits once spend becomes material.
5. Implementation sketch
Keep the first integration boring. Pick one read-heavy, idempotent endpoint. Price it. Return payment requirements. Verify authorization. Record a receipt.
async function paidEndpoint(req, res) {
const proof = req.headers["x-payment"];
if (!proof) {
return res.status(402).json({
amount: "0.01",
asset: "USDC",
chain: "base",
recipient: process.env.PROVIDER_ADDRESS,
resource: req.path,
expires_at: Date.now() + 5 * 60_000
});
}
const verification = await verifyPaymentProof(proof);
if (!verification.ok) return res.status(402).json({ error: verification.reason });
const data = await computeResource(req);
const receipt = await createReceipt({ proof, resource: req.path, status: "settled" });
return res.json({ data, receipt_id: receipt.id });
}6. Provider launch checklist
- ✓ Pick one paid endpoint and one stablecoin asset.
- ✓ Publish machine-readable pricing and recipient metadata.
- ✓ Add max-price and approved-recipient examples to the client docs.
- ✓ Verify payment proof before expensive work is performed.
- ✓ Emit receipts and expose usage history.
- ✓ Document failure modes: expired quote, insufficient budget, unsupported asset, settlement pending, refunded request.
- ✓ Link your guide from your glossary/resource hub so AI answer engines can connect the entities.
Related QBT Labs resources
Frequently asked questions
What is an x402-style payment?
An x402-style payment is an HTTP-native pay-per-request flow where an API responds with payment requirements, the agent checks policy and budget, signs an authorization, retries the request with proof of payment, and receives the paid resource after verification.
Do API providers need to run blockchain infrastructure?
Not necessarily. Providers can use a facilitator or hosted settlement layer for verification and chain submission. The important provider-side pieces are pricing metadata, payment verification, receipts, budget-safe client examples, and failure handling.
Why are API keys not enough for AI agents?
API keys identify a caller, but they do not price each tool call, enforce per-agent spend limits, produce payment receipts, or settle value per request. Autonomous agents need a payment protocol plus a policy layer, not just credentials.
Building paid API access for agents?
QBT Labs builds the policy, receipt, and settlement layer around x402-style agent payments.
Explore AI payment infrastructure