Five lines. Then you ship.
Drop the middleware in. Point it at the coordinator. Your routes start accepting agent payments — atomic, escrowed, audit-logged. No SDK ceremony, no checkout forms, no per-provider account setup for the agent.
pip install paygate402npm install paygate402Quickstart
from paygate402 import require_payment
from fastapi import FastAPI
app = FastAPI()
@app.get("/api/v1/generate")
@require_payment(amount_usd=0.003, currency="USDC")
async def generate_image(prompt: str):
# Your existing handler — middleware handles all the 402 dance
image_url = await flux.generate(prompt)
return {"url": image_url}Try the API live
Hit the public providers endpoint right now — same coordinator that powers production. No auth needed for this read.
Rails — Coinbase x402 vs Stripe MPP
You don't pick the rail at integration time. The provider advertises which rails they accept; the agent picks per call. Both flow through the same TEE escrow.
Webhook events
Configure a webhook URL in your provider settings. Every event gets an HMAC-SHA256 signature in the X-PayGate-Webhook-Signature header.
payment.settledAtomic payment completed. Agent received resource, provider received funds.
example payload
{
"tx_id": "tx_01HXY…",
"amount_micro_usd": 3000,
"rail": "coinbase_x402"
}payment.refundedEscrow auto-refunded after provider failure or 30s timeout.
example payload
{
"tx_id": "tx_01HXY…",
"refund_reason": "provider_timeout_30s"
}escrow.heldFunds moved to TEE escrow, awaiting provider response.
example payload
{
"hold_id": "hold_01HX…",
"auto_refund_at": "2026-05-15T01:42:43Z"
}wallet.budget_exceededAgent wallet hit a configured cap. Payment never fired.
example payload
{
"agent": "agent_x",
"cap_usd_per_hour": 2,
"spent": 2.05
}dispute.openedAgent flagged a delivery as bad. Provider has 24h to respond.
example payload
{
"tx_id": "tx_01HXY…",
"agent_reason": "response_was_empty_object"
}Want help wiring this up?
I do hands-on integration calls — share a 30-min slot, your API base URL, and which rail you want first. I'll have it accepting agent payments before the call ends.