Skip to main content

Core Entities

Merchants

Merchants are businesses that offer AI-powered services to end users. They:
  • Configure products with pricing rules (tiers, markups, fixed fees)
  • Generate API keys for authentication
  • Embed checkout flows to onboard users
  • View usage analytics and revenue
Merchant Account Setup:
  1. Sign up via Clerk (user or organization account)
  2. Complete Stripe Connect onboarding for payouts
  3. Create products with pricing configuration
  4. Generate secret keys for API authentication
  5. Embed checkout flow in application

Wallets

Wallets hold prepaid credits that users spend on AI services. They support:
  • Stripe integration for adding funds
  • Autopay for automatic top-ups when balance falls below a threshold
  • Subscriptions for monthly prepaid usage
  • Multiple connections to different merchants
Wallet Creation Flow:
  1. User clicks “Connect Wallet” in merchant app
  2. Phone number verification via SMS OTP
  3. Create wallet OR link existing wallet
  4. Add payment method via Stripe
  5. Fund wallet with initial balance
  6. Receive connection secret to merchant
Wallets are user-owned, not merchant-specific. A single wallet works across all Lava merchants.

Connection Model

A connection links a specific wallet to a specific merchant. Each connection:
  • Has a unique connection secret used in forward tokens
  • Tracks its own usage and balance
  • Can be in “ok” or “limited” status based on funds
  • Supports custom reference IDs for your internal systems

Connection Lifecycle

Connection States

StateDescriptionCan Make Requests?
okWallet has sufficient balance✅ Yes
limitedBalance below thresholdDepends on product config
disabledMerchant disabled connection❌ No
deletedSoft-deleted record❌ No

Connection Management

Merchants can:
  • View all connections to their account
  • See real-time usage per connection
  • Disable connections (block future requests)
  • Set custom reference IDs (link to internal user IDs)
  • Track revenue per connection
Wallet owners can:
  • View all their connections to different merchants
  • See usage breakdown by merchant
  • Disconnect from merchants (soft delete)
  • Fund all connections from single balance

Account Types

Lava supports two account types via Clerk:

Individual Accounts

  • Personal user accounts
  • Single owner
  • Suited for solo developers or small projects
  • Can create merchant OR wallet (not both)

Organization Accounts

  • Team-based accounts
  • Multiple members with roles
  • Suited for businesses and companies
  • Organization creates merchant, members can have wallets
  • Centralized billing and management
An individual account can only be either a merchant or have a wallet, not both. Organizations typically operate as merchants while individual team members have personal wallets.

Relationship Patterns

One-to-Many

One Wallet → Many Merchants
  • User creates single wallet
  • Connects to multiple merchant applications
  • Uses same balance across all connections
  • Sees consolidated usage in dashboard
One Merchant → Many Wallets
  • Merchant serves multiple end users
  • Each user has their own wallet + connection
  • Merchant sees aggregate usage and revenue
  • Revenue tracked per connection for analysis

Network Effects

When users sign up through one merchant:
  • They can use their wallet with any other merchant on Lava
  • No need to create new accounts or add payment methods
  • Drives adoption across the platform
  • Benefits all merchants through shared user base

Next Steps