Skip to main content

What is a Product?

A product in Lava defines the pricing and billing rules for AI services. Merchants can configure:
  • Fee models: Fixed per-unit costs or percentage markups
  • Tiered pricing: Volume-based discounts (e.g., first 1M tokens at X,next1MatX, next 1M at Y)
  • Billing basis: Charge for input+output tokens, output-only, characters, or time
  • Cost attribution: Who pays base costs and service charges (wallet or merchant)
  • Overdraft behavior: Block requests or allow overdraft when funds run low
Each product has a unique product secret that can be included in forward tokens to apply specific pricing rules.

Fee Structure Options

Fixed Fee Model

Charge a flat amount per billing unit:
fee = fixedAmount × units
Example configurations:
  • $0.50 per API call (regardless of usage)
  • $5 per 1M tokens (flat rate)
  • $0.10 per minute of audio
Best for:
  • Predictable pricing for users
  • Simplified billing calculations
  • Services with consistent resource usage

Percentage Markup Model

Add a percentage on top of the base provider cost:
fee = baseCost × percentageMarkup
Example configurations:
  • 20% markup on provider costs
  • 50% markup for premium features
  • 10% markup for resale
Best for:
  • Scaling fees with actual costs
  • Maintaining margins across providers
  • Variable usage patterns

Hybrid Model

Combine fixed and percentage fees:
fee = fixedAmount + (baseCost × percentageMarkup)
Example:
  • $0.10 base + 15% markup
  • Covers processing overhead (fixed) + cost scaling (percentage)

Tiered Pricing

Create volume discounts by defining pricing tiers:
{
  "tiers": [
    {
      "upTo": 1000000,
      "fixedFee": 0.05,
      "percentageFee": 0
    },
    {
      "upTo": 10000000,
      "fixedFee": 0.03,
      "percentageFee": 0
    },
    {
      "upTo": null,
      "fixedFee": 0.01,
      "percentageFee": 0
    }
  ]
}
Interpretation:
  • First 1M units: $0.05 per unit
  • Next 9M units (1M-10M): $0.03 per unit
  • Above 10M units: $0.01 per unit
Benefits:
  • Incentivize higher usage
  • Reward loyal customers
  • Competitive with direct provider pricing at scale

Billing Basis

Define what metric drives pricing:
Billing BasisUnitUse Cases
input-outputTokensLLMs (charge for both prompt and completion)
output-onlyTokensLLMs (charge only for completion)
charactersCharactersText-to-speech, text processing
durationSeconds/MinutesVoice calls, real-time services
requestsAPI callsPer-request pricing regardless of usage
Example: LLM with output-only billing
// User sends 500 token prompt, receives 200 token response
// Billing basis: output-only
// Charge: 200 tokens × rate (not 700 total)

Cost Attribution

Control who pays for different cost components:

Base Costs

Who pays the AI provider’s charges?
  • Wallet pays (default): User covers provider costs
  • Merchant pays: Merchant absorbs provider costs

Merchant Fees

Who pays the merchant’s markup?
  • Wallet pays (always): User covers merchant fees
  • Cannot be attributed to merchant (that would be self-payment)

Service Charge

Who pays Lava’s 1.9% platform fee?
  • Follows merchant fees: If wallet pays fees, wallet pays service charge
  • Attribution: Same as merchant fee payer
Example configurations:
ModelBase CostsMerchant FeesUser PaysMerchant Pays
Pass-throughWalletWalletBase + Fees + Service$0
Merchant Absorbs BaseMerchantWalletFees + ServiceBase
FreemiumMerchantMerchant$0Base + Fees + Service

Overdraft Behavior

Configure what happens when wallet balance is insufficient:

Block Requests (Default)

  • Request is rejected with insufficient funds error
  • User must add funds before continuing
  • Protects users from unexpected charges

Allow Overdraft

  • Request proceeds even with insufficient balance
  • Transfer created as “under-settled”
  • Settled when user adds funds (oldest first)
  • Useful for preventing service interruption
Configuration:
{
  "overdraftAllowed": false,
  "minimumBalance": 5.00
}

Product Secret Usage

Each product has a unique secret that can be optionally included in forward tokens:
// Without product secret (uses merchant default pricing)
const token = btoa(`${secretKey}.${connectionSecret}`);

// With product secret (applies specific product pricing)
const token = btoa(`${secretKey}.${connectionSecret}.${productSecret}`);
Use cases:
  • A/B testing: Different pricing for user cohorts
  • Premium tiers: Charge different rates based on subscription level
  • Custom contracts: Special pricing for enterprise customers
  • Feature gating: Different products for different features
Product secrets can be included in client-side code - they don’t grant access alone, just specify which pricing to apply.

Next Steps