Pay-per-call AI APIs using Celo stablecoins. No subscriptions. No credit cards. Just pay what you use.
🌐 Live Website: payforapi.online | 🎥 Demo Video: YouTube | 🏆 Karma Profile: KarmaHQ
| Token | Currency | Price Per Call |
|---|---|---|
| cUSD 🇺🇸 | US Dollar | $0.001 |
| cEUR 🇪🇺 | Euro | €0.001 |
| cKES 🇰🇪 | Kenyan Shilling | KES 0.13 |
| cBRL 🇧🇷 | Brazilian Real | R$0.005 |
| cGHS 🇬🇭 | Ghana Cedi | GHS 0.01 |
| cCOP 🇨🇴 | Colombian Peso | COP 4.00 |
| PUSO 🇵🇭 | Philippine Peso | ₱0.056 |
| API | Endpoint | Price |
|---|---|---|
| Weather Info | /api/weather | 0.001 cUSD |
| Global News | /api/news | 0.002 cUSD |
| Crypto Pulse | /api/crypto | 0.001 cUSD |
| AI Summary | /api/summary | 0.005 cUSD |
| AI Translate | /api/translate | 0.003 cUSD |
- Auto-detects
window.ethereum.isMiniPay - Auto-connects wallet — no popups
- Uses cUSD as feeCurrency for all transactions
- Discovery manifest:
/.well-known/minipay.json - Hook:
hooks/useMiniPay.ts
npm install
cp .env.example .env.local
# Fill in your API keys and contract addresses
npm run devBuilt for the Celo Onchain Agents Hackathon (May 22 - June 15, 2026)
- Track 1: Best Agent on Celo
- Track 2: Most Onchain Activity
- Track 3: Highest 8004scan Rank
The Developer SDK allows autonomous agents to seamlessly interact with x402 endpoints.
By providing an EVM-compatible private key, the SDK automatically handles 402 Payment Required interception.
npm install @pay-for-api/sdkimport { PayForApiClient } from '@pay-for-api/sdk';
const client = new PayForApiClient({
privateKey: process.env.CELO_PRIVATE_KEY
});
// The fetch call automatically handles x402 invoice settlement in the background
const response = await client.fetch('https://pay-for-api.com/api/weather');
const data = await response.json();Pay For API is not just a consumer platform; it is a two-sided marketplace. Developers can register their own Web2 or Web3 endpoints via our Creator Dashboard.
- Register: Submit your endpoint URL and desired cUSD price per call.
- Wrap: Our platform provides a reverse-proxy x402 wrapper.
- Earn: Every successful call routes payment directly to your Celo wallet.
Earnings are managed by the APIRevenueSplitter.sol contract.
- 90% routes to the API Creator instantly.
- 10% routes to the Pay For API Treasury to sustain infrastructure.
Welcome to the deep-dive documentation for Pay For API.
The platform follows a highly modular architecture separating the frontend, backend middleware, and Celo smart contracts.
Built with Next.js 15 App Router, React 19, and Tailwind CSS v4 for a highly responsive, glass-morphic UI.
We utilize ethers.js v6 for provider interactions, specifically auto-detecting the MiniPay injected provider via window.ethereum.isMiniPay.
All smart contracts are written in Solidity 0.8.24 and compiled using Hardhat. They handle API revenue splits and APIC token logic.
Our Next.js API routes are protected by custom x402 middleware that intercepts requests and validates on-chain payment hashes.
Before running the project locally, you must configure a series of environment variables.
-
NEXT_PUBLIC_RPC_URL: The Celo Mainnet RPC URL used for public data reading.
-
PRIVATE_KEY: The deployer's private key used for smart contract deployments and backend admin transactions.
-
OPENAI_API_KEY: Required for the Premium AI Chat endpoint.
-
GEMINI_API_KEY: Required for the AI Summary and AI Translate endpoints.
-
WEATHER_API_KEY: Sourced from OpenWeatherMap for real-time meteorological data.
-
NEWS_API_KEY: Used to fetch global news headlines for the News API endpoint.
To deploy the contracts to the Celo network, ensure your wallet is funded with CELO for gas.
This contract implements the ERC20 standard with additional minting logic for daily rewards and streaks.
Handles the 90/10 split between API creators and the platform treasury.
Run the deployment script using Hardhat:
�ash npx hardhat run scripts/deploy.ts --network celo
Verify your deployed contracts on CeloScan using the @nomicfoundation/hardhat-verify plugin.
�ash npx hardhat verify --network celo <DEPLOYED_CONTRACT_ADDRESS>
Detailed specifications for each premium endpoint offered on the marketplace.
Accepts a user message and returns an AI-generated response. Requires a xHash proving a 0.005 cUSD payment.
Requires a lat and lon query parameter. Returns current weather data. Price: 0.001 cUSD.
Returns the top 10 global news headlines. Price: 0.002 cUSD.
Fetches live prices for major cryptocurrencies including BTC, ETH, and CELO. Price: 0.001 cUSD.
Accepts a long text payload and returns a concise AI-generated summary. Price: 0.005 cUSD.
Accepts text and a target language code. Returns translated text. Price: 0.003 cUSD.
The x402 protocol is the backbone of Pay For API's monetization strategy.
When a client accesses a premium endpoint without a valid payment, the server returns an HTTP 402 status code.
Along with the 402 status, the server provides an invoice containing the required token address, amount, and recipient.
The client's wallet processes the payment on the Celo network and obtains a transaction hash.
The client retries the request, including the transaction hash in the X-Payment-Hash header. The server verifies this hash on-chain before serving the data.
MiniPay is an ultra-lightweight wallet built into the Opera Mini browser, designed for users in emerging markets.
Our platform uses window.ethereum.isMiniPay to seamlessly detect the wallet and bypass standard connection modals.
All transactions are formatted to use cUSD as the eeCurrency, ensuring users don't need native CELO to pay for gas.
MiniPay strictly requires Legacy (Type 0) or EIP-1559 (Type 2) transactions. We ensure all ethers.js transactions are correctly populated.
Maintaining the integrity of the marketplace and protecting user funds is paramount.
All API endpoints are protected by IP-based rate limiting to prevent abuse and DDoS attacks.
The backend maintains a registry of processed transaction hashes to ensure a single payment cannot be used multiple times.
All user inputs, especially for AI prompts and database queries, are strictly sanitized to prevent injection attacks.
The APICredits and APIRevenueSplitter contracts have undergone internal review, though external audits are recommended before high-volume mainnet usage.
The Creator Dashboard empowers developers to monetize their own endpoints on our platform.
Creators provide their endpoint URL, metadata, and set a custom cUSD price.
Pay For API acts as a reverse proxy, enforcing x402 payments before routing the request to the creator's server.
Creators can track their total calls, revenue generated, and withdraw their 90% share directly to their Celo wallet.
We are constantly iterating and expanding the capabilities of Pay For API.
While Celo is our native home, we plan to support x402 payments on Base, Optimism, and Arbitrum.
Integrating with decentralized infrastructure providers to ensure 100% uptime for our middleware gateways.
Introducing optional NFT-based monthly passes for users who prefer bulk access over pay-per-call.
- 10% routes to the Pay For API Treasury to sustain infrastructure.
Welcome to the deep-dive documentation for Pay For API.
The platform follows a highly modular architecture separating the frontend, backend middleware, and Celo smart contracts.
Built with Next.js 15 App Router, React 19, and Tailwind CSS v4 for a highly responsive, glass-morphic UI.
We utilize ethers.js v6 for provider interactions, specifically auto-detecting the MiniPay injected provider via window.ethereum.isMiniPay.
All smart contracts are written in Solidity 0.8.24 and compiled using Hardhat. They handle API revenue splits and APIC token logic.
Our Next.js API routes are protected by custom x402 middleware that intercepts requests and validates on-chain payment hashes.
Before running the project locally, you must configure a series of environment variables.
-
NEXT_PUBLIC_RPC_URL: The Celo Mainnet RPC URL used for public data reading.
-
PRIVATE_KEY: The deployer's private key used for smart contract deployments and backend admin transactions.
-
OPENAI_API_KEY: Required for the Premium AI Chat endpoint.
-
GEMINI_API_KEY: Required for the AI Summary and AI Translate endpoints.
-
WEATHER_API_KEY: Sourced from OpenWeatherMap for real-time meteorological data.
-
NEWS_API_KEY: Used to fetch global news headlines for the News API endpoint.
To deploy the contracts to the Celo network, ensure your wallet is funded with CELO for gas.
This contract implements the ERC20 standard with additional minting logic for daily rewards and streaks.
Handles the 90/10 split between API creators and the platform treasury.
Run the deployment script using Hardhat:
ash npx hardhat run scripts/deploy.ts --network celo
Verify your deployed contracts on CeloScan using the @nomicfoundation/hardhat-verify plugin.
ash npx hardhat verify --network celo <DEPLOYED_CONTRACT_ADDRESS>
Detailed specifications for each premium endpoint offered on the marketplace.
Accepts a user message and returns an AI-generated response. Requires a xHash proving a 0.005 cUSD payment.
Requires a lat and lon query parameter. Returns current weather data. Price: 0.001 cUSD.
Returns the top 10 global news headlines. Price: 0.002 cUSD.
Fetches live prices for major cryptocurrencies including BTC, ETH, and CELO. Price: 0.001 cUSD.
Accepts a long text payload and returns a concise AI-generated summary. Price: 0.005 cUSD.
Accepts text and a target language code. Returns translated text. Price: 0.003 cUSD.
The x402 protocol is the backbone of Pay For API's monetization strategy.
When a client accesses a premium endpoint without a valid payment, the server returns an HTTP 402 status code.
Along with the 402 status, the server provides an invoice containing the required token address, amount, and recipient.
The client's wallet processes the payment on the Celo network and obtains a transaction hash.
The client retries the request, including the transaction hash in the X-Payment-Hash header. The server verifies this hash on-chain before serving the data.
MiniPay is an ultra-lightweight wallet built into the Opera Mini browser, designed for users in emerging markets.
Our platform uses window.ethereum.isMiniPay to seamlessly detect the wallet and bypass standard connection modals.
All transactions are formatted to use cUSD as the eeCurrency, ensuring users don't need native CELO to pay for gas.
MiniPay strictly requires Legacy (Type 0) or EIP-1559 (Type 2) transactions. We ensure all ethers.js transactions are correctly populated.
Maintaining the integrity of the marketplace and protecting user funds is paramount.
All API endpoints are protected by IP-based rate limiting to prevent abuse and DDoS attacks.
The backend maintains a registry of processed transaction hashes to ensure a single payment cannot be used multiple times.
All user inputs, especially for AI prompts and database queries, are strictly sanitized to prevent injection attacks.
The APICredits and APIRevenueSplitter contracts have undergone internal review, though external audits are recommended before high-volume mainnet usage.
The Creator Dashboard empowers developers to monetize their own endpoints on our platform.
Creators provide their endpoint URL, metadata, and set a custom cUSD price.
Pay For API acts as a reverse proxy, enforcing x402 payments before routing the request to the creator's server.
Creators can track their total calls, revenue generated, and withdraw their 90% share directly to their Celo wallet.
We are constantly iterating and expanding the capabilities of Pay For API.
While Celo is our native home, we plan to support x402 payments on Base, Optimism, and Arbitrum.
Integrating with decentralized infrastructure providers to ensure 100% uptime for our middleware gateways.
Introducing optional NFT-based monthly passes for users who prefer bulk access over pay-per-call.
A robust, enterprise-grade SDK with built-in retry logic, caching, and fallback providers for high-availability systems.
Thank you for building with Pay For API. For support, please open an issue on our GitHub repository or reach out to the core team.
ERC-8004 Registry Link: 8004scan.io/agents/celo/9197
Self Agent ID Verification Status: I attempted to verify my agent using Self Agent ID, but I could not complete the process because my passport does not have an NFC chip. I also tried the manual verification process multiple times, but every time it showed "Your submission has been declined".
Please see the screenshot proof of the decline message here: Self Agent ID Declined Screenshot (Google Drive)