Payper

AI usage billing with x402 payments and verified Hedera settlement.

Payper

Created At

ETHGlobal Mumbai

Project Description

PerPay is a usage-based payment gateway for AI services. Instead of charging a fixed amount before every request, we calculate what a user actually owes from the input and output tokens consumed during AI generation. When a user submits a prompt, PerPay generates and temporarily stores the response, measures the actual usage through Groq, and creates an invoice for the exact amount. The response remains private until the user approves payment through x402 on Hedera. Once the facilitator settles the transaction and the payment is verified, the same stored response is unlocked. We are also building safeguards against duplicate payments, repeated unpaid requests and failed response delivery. Our goal is to make AI payments more transparent, usage-based and verifiable, while keeping the experience simple for users.

How it's Made

We are building PerPay using three connected components. The frontend is developed with React and TypeScript, with a focus on making the payment and AI experience simple to use. Our FastAPI gateway connects to Groq, generates responses, records the actual input and output token counts, calculates the usage-based charge and stores responses privately until payment. My part is the TypeScript-based x402 v2 payment integration with Hedera Testnet. We use the exact payment scheme with native HBAR, where the customer authorizes the payment and a compatible facilitator handles verification and settlement. The backend then checks the actual Hedera transaction before allowing the response to be released. We are also implementing invoice tracking, idempotency, replay protection, account restrictions and recovery for failed delivery. SQLite is used for persistent application records where appropriate, and transaction references can be checked through HashScan. Our three-member team is dividing the work across AI gateway, blockchain payments and frontend/dashboard development. We use Hedera Testnet HBAR for payment demonstrations; it does not pay Groq's API costs.

background image mobile

Join the mailing list

Get the latest news and updates