hamel88's picture
Upload README.md
8459353 verified
---
title: x402 AI Demo - Pay-per-inference with Base micropayments
emoji: πŸ’³
colorFrom: blue
colorTo: purple
sdk: docker
app_file: app.py
app_port: 7860
suggested_hardware: cpu-upgrade
suggested_storage: small
startup_duration_timeout: 10m
short_description: Pay-per-use Inference with Base micropayments
models:
- distilgpt2
- cardiffnlp/twitter-roberta-base-sentiment-latest
tags:
- fastapi
- x402
- micropayments
- cryptocurrency
- nova
- ai
- blockchain
- base
- usdc
- metamask
pinned: false
license: mit
fullWidth: true
---
# πŸ€— x402 AI Demo - Pay-per-use AI Services
A FastAPI demonstration of micropayments for AI services using the x402 protocol.
## πŸš€ Features
- **πŸ’­ Text Generation** - DistilGPT-2 ($0.01 per request)
- **😊 Sentiment Analysis** - RoBERTa ($0.005 per request)
- **πŸ–ΌοΈ Image Generation** - Amazon Nova Canvas ($0.02 per request)
- **πŸ’° Automatic Revenue Splitting** - CDP Wallet integration
- **πŸ” MetaMask Integration** - Seamless crypto payments
## πŸ”§ How It Works
1. Connect your MetaMask wallet to Base Sepolia testnet
2. Click a service button to make a request
3. Sign the x402 payment with your wallet
4. AI service processes your request
5. Revenue is automatically split between stakeholders
## πŸ’‘ Demo Mode
This is running on **Base Sepolia testnet** - no real money required! Get testnet USDC from the [Base Sepolia faucet](https://www.coinbase.com/faucets/base-ethereum-sepolia-faucet).
## πŸ—οΈ Technology Stack
- **Backend**: FastAPI with x402 payment protocol
- **Frontend**: HTML/CSS/JavaScript with MetaMask integration
- **AI Models**: Hugging Face Transformers (DistilGPT-2, RoBERTa)
- **Image Generation**: AWS Bedrock Nova Canvas
- **Payments**: Base Sepolia testnet with USDC
- **Revenue Splitting**: Coinbase Developer Platform (CDP)
## πŸ”— Links
- [x402 Protocol](https://github.com/sourcegraph/fastapi-x402)
- [Base Sepolia Faucet](https://www.coinbase.com/faucets/base-ethereum-sepolia-faucet)
- [MetaMask Download](https://metamask.io/)
---
Built with ❀️ using FastAPI, Hugging Face, and the x402 payment protocol.