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 | 🌟 Talent Protocol: Talent.app
| Token | Currency | Price Per Call |
|---|---|---|
| USDm 🇺🇸 | US Dollar | $0.001 |
| EURm 🇪🇺 | Euro | €0.001 |
| KESm 🇰🇪 | Kenyan Shilling | KES 0.13 |
| BRLm 🇧🇷 | Brazilian Real | R$0.005 |
| GHSm 🇬🇭 | Ghana Cedi | GHS 0.01 |
| COPm 🇨🇴 | Colombian Peso | COP 4.00 |
| PUSO 🇵🇭 | Philippine Peso | ₱0.056 |
| API | Endpoint | Price |
|---|---|---|
| Weather Info | /api/weather | 0.001 USDm |
| Global News | /api/news | 0.002 USDm |
| Crypto Pulse | /api/crypto | 0.001 USDm |
| AI Summary | /api/summary | 0.005 USDm |
| AI Translate | /api/translate | 0.003 USDm |
| Image Gen | /api/image | 0.01 USDm |
window.ethereum.isMiniPay for Opera Mini browser users./.well-known/minipay.jsonhooks/useMiniPay.tsnpm install
cp .env.example .env.local
# Fill in your API keys and contract addresses
npm run dev
Built for the Celo Onchain Agents Hackathon (May 22 - June 15, 2026)
@pay-for-api/sdk)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/sdk
import { 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.
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 USDm payment.
Requires a lat and lon query parameter. Returns current weather data. Price: 0.001 USDm.
Returns the top 10 global news headlines. Price: 0.002 USDm.
Fetches live prices for major cryptocurrencies including BTC, ETH, and CELO. Price: 0.001 USDm.
Accepts a long text payload and returns a concise AI-generated summary. Price: 0.005 USDm.
Accepts text and a target language code. Returns translated text. Price: 0.003 USDm.
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 USDm 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 USDm 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.
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID: Required for RainbowKit multi-wallet support (get from cloud.walletconnect.com).
Our smart contracts are deployed and verified on the Celo Mainnet:
APICredits (APIC): 0x486776B119aAf9eEe3c215D0e42d9Aa426A76b80
Implements the ERC20 standard with additional minting logic for daily rewards and streaks.
APIRevenueSplitter: 0x5ac6de9FAe3f424C7f07C65283B8953108aa5C78
Handles the 90/10 split between API creators and the platform treasury.
CommunityNFT: 0x0D2238a8E6a2c5951E6cBeb8e03278f5d0C8FFB6
A community membership NFT rewarding consistent API consumers.
To deploy the contracts to the Celo network, ensure your wallet is funded with CELO for gas.
Run the deployment script using Hardhat:
npx hardhat run scripts/deploy.ts --network celo
Verify your deployed contracts on CeloScan using the @nomicfoundation/hardhat-verify plugin.
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 USDm payment.
Requires a lat and lon query parameter. Returns current weather data. Price: 0.001 USDm.
Returns the top 10 global news headlines. Price: 0.002 USDm.
Fetches live prices for major cryptocurrencies including BTC, ETH, and CELO. Price: 0.001 USDm.
Accepts a long text payload and returns a concise AI-generated summary. Price: 0.005 USDm.
Accepts text and a target language code. Returns translated text. Price: 0.003 USDm.
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-P
$ claude mcp add PayForApi \
-- python -m otcore.mcp_server <graph>