Charge AI agents for your API.
Try it on testnet in 5 minutes: your API answers 402, the agent pays in USDC on Stellar, settled in ~4s. Funds go straight from payer to you - Nirium never touches them.
Third-party facilitator use of x402Serve() on mainnet is invite-only while legal review closes - same gate as Treasury and Payouts.
import express from 'express';
import { x402Serve } from 'nirium';
const app = express();
app.use(x402Serve({
payTo: process.env.PAY_TO, // your G... address
facilitatorApiKey: process.env.FACILITATOR_KEY, // free testnet key
routes: { 'GET /weather': '$0.05' }, // testnet by default
}));
app.get('/weather', (_req, res) => res.json({ tempC: 21 }));
app.listen(3000);Ran verbatim with nirium@0.16.0 on testnet: 402, then paid, then 200.
x402Serve() is a library that runs on your own server, with your own facilitator key. You remain responsible for compliance in your jurisdiction; restricted jurisdictions apply.
Try it on testnet
Three steps, no real money. Node.js 22.12 or newer.
Install
The package plus the x402 pieces x402Serve() loads on demand.
npm i nirium express @x402/express @x402/core @x402/stellar
Charge per request
Get a free testnet facilitator key from OpenZeppelin, set PAY_TO to a testnet address with a USDC trustline, and run server.js. Without payment, GET /weather answers 402 with the price.
channels.openzeppelin.com/testnet/genPay it from an agent
Any x402 client works. With the same package, from a testnet account that holds USDC:
import { Agent } from 'nirium';
const agent = new Agent({ apiKey: 'unused' });
agent.initX402({ secretKey: process.env.PAYER_SECRET, network: 'stellar:testnet' });
const res = await agent.x402Fetch('http://localhost:3000/weather'); // 402 → sign → 200What Nirium adds on top of x402
x402 moves the payment. These are the parts you would otherwise write yourself.
Replay guard and rate limit
Pass a guard store to x402Serve() and a replayed payment proof is refused: one payment, one response. Add a per-IP sliding-window rate limit on top. Replay protection fails closed (503) if the store is down. Generalized from a production integrator’s own implementation, credited in the changelog.
CHANGELOGVerifiable receipts with Audit Trail
Anchor the settlement hash, or the sha-256 of any record, and get back an IPFS receipt anyone can check from the CID alone. Sign it with any Stellar key and the receipt also proves who declared it. One API call. Anchor hashes, not raw personal data.
GET /api/audit/infoBuyer-side policy hook
On the paying side, initX402({ policy }) asks your policy engine after the Stellar authorization is built and before anything is signed. Only an ALLOW bound to that exact authorization reaches the signer. Not solved yet: L01, concurrent requests that see the same remaining capacity, and L02, code in the same process that holds the raw signer. The shape can still change before 1.0.
PR #98 · #96Don't trust us. Verify us.
Every claim below resolves to something public.
Built with Nirium
Projects charging for their own API with x402Serve(). Each listing goes up once its team approves the text.
More from Nirium
Everything here is non-custodial. Each status is what runs today, not a roadmap.
Audit Trail
Immutable IPFS receipts for any record, optionally signed by the agent that declared it.
Reporting
Summaries and CSV/JSON exports of payments, payout runs and receipts. What you file with a regulator stays your responsibility.
Treasury
Idle capital moves into a CETES strategy and back over a DeFindex vault you own. Invite-only while legal review closes.
Payouts
Pay up to 100 recipients in one batch you sign yourself: your own contractors and suppliers. Independent service payments only, not employee salary.
MPP Charge
A client for MPP Charge ships in the package. It has not been verified end to end against our hosted endpoints; use x402 for paid access.
Update, 2026-10-04 (checked against the nirium 0.16.0 changelog that day): this page used to say MPP Charge was live on mainnet. That was wrong.
Legal notice - Nirium is B2B software-only infrastructure and never custodies funds; financial services (SPEI onramp, CETES custody) are operated by regulated partners. Read full legal notice →
Your API, paid per request.
Start on testnet in five minutes. Mainnet for third-party facilitators is invite-only while legal review closes.
See live usageBuilt on Open Standards
All rate data shown is protocol reference information only - not a return projection or guarantee.