Genbase - AI Video & Image Generator with x402
This guide will help you understand Genbase, an AI video and image generation platform powered by x402 open payment standard for programmatic payments.
This application showcases x402, the open payment standard that enables services to charge for access to their APIs directly over HTTP. It uses the HTTP 402 Payment Required status code to allow clients to programmatically pay for video generation without accounts, sessions, or credential management.
Why Use x402?
This application demonstrates how x402 addresses key limitations of existing payment systems:
Traditional payment problems:
- • High fees and friction with credit cards and fiat payment processors
- • Incompatibility with machine-to-machine payments
- • Lack of support for micropayments
- • Account creation and authentication overhead
x402 solutions:
- ⚡ Low fees: ~$0.001-0.01 gas fees on Base L2
- 🤖 Machine-friendly: AI agents can pay autonomously
- 💰 Micropayments: Pay $0.02-0.2 per generation (video/image)
- 🚫 No accounts: Just connect your Web3 wallet
Who is this for?
What Can You Build?
This application showcases one use case, but x402 enables many more:
- ✅ API services paid per request (demonstrated here with video generation)
- ✅ AI agents that autonomously pay for API access
- ✅ Paywalls for digital content
- ✅ Microservices monetized via microtransactions
- ✅ Proxy services that aggregate and resell API capabilities
In this app specifically:
- 🎬 Pay $0.2 USDC to generate AI videos using Sora 2
- 🖼️ Pay $0.02 USDC to generate AI images using Flux Pro (10x cheaper!)
- 🆓 Free status queries to check progress
- 📊 Real-time progress tracking with automatic updates
- 💾 Automatic history of all your generations
How Does It Work?
High-Level Flow
⚠️ Important: Content Policy Notice
Your prompts may violate OpenAI's content policy, which could result in video generation failure. This includes prompts containing unsafe content such as violence, adult content, minors, etc.
If your video fails due to policy violations and you need a refund, please contact: contact@genbase.fun with your Video ID and wallet address.
Creating a Video with Sora 2 (Paid - $0.2 USDC)
// Frontend makes request
const response = await payingFetch("/api/video/create-sora2", {
method: "POST",
body: JSON.stringify({
prompt: "A cat playing piano in a jazz club",
model: "sora-2",
seconds: "10",
size: "1280x720"
})
});
// Server middleware intercepts
// Returns: 402 Payment Required + payment info
// payingFetch automatically:
// - Signs payment with wallet
// - Retries with Authorization header
// - Returns final responseCreating an Image with Flux Pro (Paid - $0.02 USDC)
// Frontend makes request
const response = await payingFetch("/api/image/create", {
method: "POST",
body: JSON.stringify({
prompt: "A cute cat wearing sunglasses, digital art"
})
});
// Server middleware intercepts
// Returns: 402 Payment Required + payment info
// payingFetch automatically:
// - Signs payment with wallet
// - Retries with Authorization header
// - Returns final responseHow to Use Genbase
Simple Steps to Generate Videos & Images:
- 1. Connect Wallet - Click "Connect Wallet" and approve MetaMask connection
- 2. Get Test USDC - Visit Coinbase Faucet to get free testnet USDC
- 3. Select Provider - Choose Sora 2 (video) or Flux Pro (image)
- 4. Enter Prompt - Describe what you want to create
- 5. Pay & Create - Pay $0.02-0.2 USDC and sign the transaction
- 6. Watch Progress - Status updates automatically every 5 seconds
- 7. Enjoy Result - Video plays or image displays automatically when complete!
All your generated videos and images are automatically saved to your browser's local storage, so you can easily re-query them later from the History panel.
API Reference
Genbase provides three AI generation endpoints: Sora 2 (video), Veo (video), and Flux Pro (image).
🎬 POST /api/video/create-sora2
Create AI videos using OpenAI's Sora 2 model (requires payment: $0.2 USDC)
Request Body:
{
"prompt": "A cat playing piano in a jazz club",
"model": "sora-2", // or "sora-2-pro"
"seconds": "10", // "10", "15", or "25" (pro only)
"size": "1280x720" // "1280x720", "720x1280", "1792x1024", "1024x1792"
}Response (200 OK):
{
"success": true,
"data": {
"id": "sora-2:task_01j9abc123xyz456def789ghi0",
"status": "pending", // "pending" | "processing" | "Ready" | "failed"
"video_url": null, // Available when status is "Ready"
"thumbnail_url": null
}
}Models:
- •
sora-2- Standard quality, 10-15 seconds - •
sora-2-pro- Enhanced quality, up to 25 seconds
🖼️ POST /api/image/create
Create AI images using Flux Pro (requires payment: $0.02 USDC)
Request Body:
{
"prompt": "A cute cat wearing sunglasses, digital art"
}Response (200 OK):
{
"success": true,
"data": {
"id": "abc123xyz456def789ghi012jkl345-mn6op7",
"status": "pending", // "pending" | "processing" | "Ready"
"result": {
"sample": null // Image URL when status is "Ready"
}
}
}🔍 GET /api/video/query
Query video generation status (FREE - no payment required)
Request Parameters:
?id=sora-2:task_01j9abc123xyz456def789ghi0
Response:
{
"success": true,
"data": {
"id": "sora-2:task_01j9abc123xyz456def789ghi0",
"status": "Ready",
"video_url": "https://...",
"detail": {
"input": {
"prompt": "Original prompt",
"model": "sora-2",
"duration": "10",
"size": "1280x720"
}
}
}
}Status Values:
- •
pending- Waiting to process (Progress: 20%) - •
processing- Generating video (Progress: 50%) - •
video_upsampling- Enhancing quality (Progress: 80%) - •
Readyorcompleted- Ready to watch (Progress: 100%) - •
failed- Generation failed
🔍 GET /api/image/query
Query image generation status (FREE - no payment required)
Request Parameters:
?id=abc123xyz456def789ghi012jkl345-mn6op7
Response:
{
"success": true,
"data": {
"id": "abc123xyz456def789ghi012jkl345-mn6op7",
"status": "completed", // Normalized from "Ready"
"image_url": "https://...", // Direct image URL
"result": {
"sample": "https://..."
}
}
}💰 Pricing Comparison
Sora 2 Video
$0.20
USDC per video
Flux Pro Image
$0.02
USDC per image
Status Query
FREE
No payment required
Features
Video Generation ($0.2 USDC)
- 🌟 Sora 2 & Sora 2 Pro - OpenAI's advanced models
- ⏱️ Duration: 10-25 seconds (model dependent)
- 📐 Multiple sizes: 1280x720, 720x1280, 1792x1024, 1024x1792
- ✨ Enhanced quality and realism
- 🎬 Professional-grade video output
Image Generation ($0.02 USDC)
- 🖼️ Flux Pro Kontext model
- 💰 10x cheaper than video
- ⚡ Fast generation time
- 🎨 High-quality digital art
- 📸 Perfect for quick iterations
Free Status Queries
- 🆓 Completely free - no payment needed
- 🔄 Auto-polling every 5 seconds
- 📊 Progress bar: 20% → 50% → 80% → 100%
- 🎥 Auto-play when complete
Video History
- 💾 Auto-save all generated videos
- 🔍 Click to quickly re-query
- 📅 Shows creation time & parameters
- 🗑️ Clear all history button
- 📱 Stored in browser localStorage
Wallet Integration
- 🦊 MetaMask and other Web3 wallets
- 🔗 Auto-connect and network switching
- 💰 Real-time balance display
- 🔐 Secure signing flow
FAQ
Q: Why is querying free?
A: Querying doesn't consume AI resources, so we made it free to improve UX. This demonstrates x402's flexibility - you can set different prices for different operations.
Q: How long does generation take?
A:
- • Sora 2 Video: ~3-10 minutes
- • Sora 2 Pro Video: ~5-15 minutes (higher quality, longer videos)
- • Flux Pro Image: ~30-90 seconds
- • Time varies based on prompt complexity and server load
Q: Why use Base instead of Ethereum mainnet?
A: Base offers:
- ⚡ Low gas fees (~$0.001-0.01 vs $1-10 on Ethereum)
- 🚀 Fast confirmations (~2 seconds)
- 🔐 Ethereum-level security (Base is an Ethereum L2)
- 💰 Native USDC support
Q: Which wallets are supported?
A: Any EIP-1193 compatible wallet:
- • MetaMask ✅
- • Coinbase Wallet ✅
- • Rainbow Wallet ✅
- • Trust Wallet ✅
- • WalletConnect wallets ✅
Ready to create AI videos? 🎬
Start using Genbase now and experience pay-per-use AI video generation!
