Skip to content

pay-gate

Drop-in x402 payment gateway for any HTTP API. Deploy in front of your service, define pricing per route, and every request is gated via x402.

Agent ──> pay-gate ──> Your API
             |
       pay-skill.com/x402
         (facilitator)

Why pay-gate

  • No code changes to your backend. Deploy a proxy, set prices, done.
  • Micropayments that work. Tab settlement: one on-chain tx for thousands of API calls.
  • Any x402 agent can pay. Direct settlement is standard x402. Tab settlement is the Pay differentiator.

Deployment Options

TargetBest forSetup
Cloudflare WorkerMost providers. Zero-ops, auto-scaling, free tier.npm create pay-gate
Rust binarySelf-hosted, Docker, systemd.cargo install pay-gate
DockerContainer orchestration.docker run payskill/gate
SidecarExisting nginx/traefik/envoy/caddy.pay-gate start --sidecar

How It Works

Unpaid request

Agent hits your API without payment:

GET /api/v1/data → 402 Payment Required
  PAYMENT-REQUIRED: base64({ x402Version: 2, accepts: [{ scheme: "exact", amount: "10000", payTo: "0x...", ... }], ... })

The agent's SDK parses the 402, pays automatically, and retries.

Agent retries with payment proof:

GET /api/v1/data
  PAYMENT-SIGNATURE: <x402 proof>

→ pay-gate verifies with facilitator
→ proxies to your API with X-Pay-* headers
→ 200 OK

Your backend sees

HeaderValue
X-Pay-Verifiedtrue
X-Pay-FromAgent wallet 0x...
X-Pay-AmountMicro-USDC amount
X-Pay-Settlementdirect or tab
X-Pay-TabTab ID (tab-backed only)

Use these for per-agent analytics, access control, or audit logging. pay-gate does not modify your response body.

Settlement Modes

Route PriceDefault ModeWhy
<= $1.00tabMicropayments. On-chain gas per call would exceed the price.
> $1.00directHigh-value. Immediate on-chain settlement.

Override per route with settlement: "direct" or settlement: "tab".

Fees

pay-gate itself is free. Standard Pay fees apply to each payment:

FeeWho paysAmount
ProcessingProvider (deducted)1% (0.75% above $50k/month)
Tab activationAgentmax($0.10, 1% of tab amount)
GasPay protocolIncluded

x402 Discovery

Every pay-gate instance serves a standard x402 descriptor at GET /.well-known/x402 (per the IETF internet-draft). Agents can fetch this to discover pricing and endpoints before making any requests.

For maximum discoverability, add a DNS TXT record:

_x402.api.example.com. 300 IN TXT "v=x4021;descriptor=api;url=https://api.example.com/.well-known/x402"

See the pay-gate Guide for full setup details.

Ᵽay — USDC payments for AI agents on Base.