HTTP 402 ยท finally used for something

Charge AI agents
to access your site.

A Stripe-style payment gate for the agent economy. Install the SDK, add a few lines, and bots pay USDC on Solana before they get past your paywall โ€” humans never see a thing.

$npm install @agentpayments/node
How it works

Three lines of middleware. Zero new infrastructure.

The gate sits in front of whatever you're already serving โ€” an API, a PDF, a dataset. It doesn't touch your app logic, and it never sees a browser visitor.

01

Browsers pass straight through

A lightweight, invisible proof-of-work challenge tells humans from bots. Real visitors never notice the gate is there.

02

Agents get a 402, with instructions

Non-browser traffic โ€” crawlers, bots, LLM agents โ€” gets an HTTP 402 back with exactly what to pay and where, in a machine-readable format.

03

Payment verified on-chain, access granted

The agent sends USDC on Solana with its key as the memo. The gate checks the chain directly โ€” no accounts, no webhooks, no card numbers.

Install

Pick your stack.

Node, edge runtimes, and Python are first-class. The gate logic is identical everywhere.

// npm install @agentpayments/node
const { agentPaymentsGate } = require('@agentpayments/node');

app.use(agentPaymentsGate({
  challengeSecret: process.env.CHALLENGE_SECRET,
  homeWalletAddress: process.env.HOME_WALLET_ADDRESS,
}));
// npm install @agentpayments/edge
import { createAgentPaymentsWorker } from '@agentpayments/edge/cloudflare';

export default createAgentPaymentsWorker({
  assetsBinding: 'ASSETS',
});
# pip install agentpayments-python
MIDDLEWARE = [
    "agentpayments_python.django_adapter.GateMiddleware",
    # ...
]
The agent side

No signup. No API key exchange. Just pay and go.

An agent that hits a 402 doesn't need to register anywhere โ€” it reads the payment instructions straight out of the response and pays on-chain.

1

Request the resource

Same as any other HTTP call โ€” no headers, no auth, no prior setup.

2

Read the 402 response

Wallet address, amount, and a memo to attach โ€” plus a standards-compliant x402 payload for agent frameworks that already speak it.

3

Send USDC on Solana, retry

Include the issued key as X-Agent-Key on the next request. The gate checks the chain directly and lets it through.