Genbase - AI Video Generator with x402

This guide will help you understand Genbase, an AI video 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 only $0.10 per video generation
  • 🚫 No accounts: Just connect your Web3 wallet

Who is this for?

Developers: Learn how to integrate x402 into your own applications for programmatic payments.
Users: Generate AI videos with pay-per-use pricing - no subscriptions required.
AI Agents: Demonstrate how autonomous agents can pay for API access programmatically.

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 an AI video using Google Veo
  • 🆓 Free status queries to check video progress
  • 📊 Real-time progress tracking with automatic updates
  • 💾 Automatic history of all your videos

How Does It Work?

High-Level Flow

1. User Request
2. 402 Payment Required Response
3. Wallet Signs Payment
4. Request with Payment Header
5. Payment Verification
6. Video Generation Starts
7. Free Status Polling (no payment)
8. Video Completed & Auto-play

Creating a Video (Paid - $0.2 USDC)

// Frontend makes request
const response = await payingFetch("/api/video/create", {
  method: "POST",
  body: JSON.stringify({ prompt, model, aspect_ratio })
});

// Server middleware intercepts
// Returns: 402 Payment Required + payment info

// payingFetch automatically:
// - Signs payment with wallet
// - Retries with Authorization header
// - Returns final response

How to Use Genbase

Simple Steps to Generate Videos:

  1. 1. Connect Wallet - Click "Connect Wallet" and approve MetaMask connection
  2. 2. Get Test USDC - Visit Coinbase Faucet to get free testnet USDC
  3. 3. Enter Video Prompt - Describe the video you want to create
  4. 4. Pay & Create - Pay $0.2 USDC and sign the transaction
  5. 5. Watch Progress - Status updates automatically every 5 seconds
  6. 6. Enjoy Video - Video plays automatically when complete!

All your generated videos are automatically saved to your browser's local storage, so you can easily re-query them later from the History panel.

API Reference

POST /api/video/create

Create a new AI video (requires payment: $0.2 USDC)

Request Body:

{
  "prompt": "A golden retriever playing in a park",
  "model": "veo3-fast-frames",
  "aspect_ratio": "16:9",
  "enable_upsample": true,
  "enhance_prompt": true
}

Response (200 OK):

{
  "success": true,
  "data": {
    "id": "veo3-fast-frames:1234567890-AbCdEfGh",
    "status": "pending",
    "detail": {
      "req": {
        "prompt": "A golden retriever playing in a park",
        "model": "veo3-fast-frames",
        "aspect_ratio": "16:9"
      }
    }
  }
}

GET /api/video/query

Query video generation status (FREE - no payment required)

Request Parameters:

?id=veo3-fast-frames:1234567890-AbCdEfGh

Status Values:

  • pending - Waiting to process (Progress: 20%)
  • processing - Generating video (Progress: 50%)
  • video_upsampling - Enhancing quality (Progress: 80%)
  • completed - Ready to watch (Progress: 100%)
  • failed - Generation failed

Features

Video Generation ($0.2 USDC)

  • 🎬 Veo 3 Fast and Veo 2 Fast models
  • 🌟 Sora 2 model - OpenAI's advanced video generation model with enhanced quality and realism
  • 📐 Aspect ratios: 16:9, 9:16, 1:1
  • ✨ Automatic prompt enhancement
  • 📈 4K upsampling option

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 video generation take?

A:

  • • Veo 3 Fast: ~2-5 minutes
  • • Veo 2 Fast: ~3-8 minutes
  • • Time varies based on prompt complexity

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!