PerkOS

x402 on Stellar

Pay-per-call API monetization using the HTTP 402 Payment Required protocol. Powered by the PerkOS Stellar Relayer.

What is x402?

HTTP status code 402 Payment Required has been reserved in the HTTP specification since 1999, but was never formally implemented — until now. The x402 protocol defines a standard way for servers to require payment before serving a response, and for clients to fulfill that requirement programmatically.

How it works

  1. Client sends a request to a paid API endpoint
  2. Server responds with HTTP 402 and a JSON body describing the payment requirements: price, asset, network, and recipient address
  3. Client signs the required payment (a Stellar USDC authorization in this demo)
  4. Client retries the original request with the signed payment in the X-PAYMENT header
  5. Server forwards the payment to a relayer for verification and on-chain settlement
  6. Once confirmed, the server returns the API response

Why this matters for agents and automation

x402 enables fully programmatic payments. There are no wallet popups, no manual approvals, and no redirect flows. An AI agent or script can pay for API access the same way it sets an HTTP header — making machine-to-machine commerce a first-class pattern.

Why Stellar

Stellar offers near-zero transaction fees (roughly $0.00001 per operation), settlement in under five seconds, and native USDC support via regulated on/off ramps. These properties make it a strong fit for high-frequency micro-payments where cost and speed are critical.

How PerkOS Fits In

The PerkOS Stellar x402 Relayer is the verification and settlement layer that sits between your application and the Stellar network. When a client submits a signed payment via the X-PAYMENT header, the relayer validates the authorization, submits the transaction to Stellar, and confirms settlement — all in a single round-trip.

Cross-chain protocolThe same x402 standard works across EVM chains and Stellar. PerkOS infrastructure supports both.
Zero gas for usersThe relayer covers all Stellar network fees. Agents and end-users never need to hold XLM.

Live relayer: stellar-relayer.perkos.xyz

How x402 Works

1

Request

Client calls a paid API endpoint without payment

2

402 Response

Server returns HTTP 402 with payment requirements (price, asset, address)

3

Pay & Retry

Client signs a Stellar payment, attaches it as X-PAYMENT header, and retries

Demo Endpoints

GET/api/weather$0.01 USDC

Get current weather data for any city

GET/api/joke$0.001 USDC

Get a random programming joke

Stack

Protocol: x402 (HTTP 402 Payment Required)
Network: Stellar Mainnet (Pubnet)
Asset: USDC on Stellar
Relayer: PerkOS Stellar x402 Relayer
Wallet: Freighter (browser extension)
Framework: Next.js 15 + Tailwind CSS