What You’ll Learn
This guide shows you how to create and configure products with flexible pricing rules. You’ll learn to:- Create products through the dashboard or API
- Configure fee structures (fixed, percentage, or hybrid)
- Set up tiered pricing for volume discounts
- Choose billing basis (tokens, characters, time, requests)
- Configure cost attribution (who pays what)
- Control overdraft behavior
- Test your pricing configuration
Products define pricing rules. Each product has a unique secret that can be included in forward tokens to apply specific pricing. Merchants can create multiple products for different use cases (e.g., “Free Tier”, “Pro”, “Enterprise”).
Dashboard Product Creation
The fastest way to create a product is through the Lava dashboard.Step 1: Navigate to Products
- Log in to your Lava dashboard
- Click Products in the sidebar
- Click Create Product button
Step 2: Configure Basic Information
Product Name: Descriptive name for internal reference (e.g., “Pro Plan API Access”) Description: Optional details about this product’s purpose Product Secret: Auto-generated unique identifier (used in forward tokens)Step 3: Choose Fee Structure
Select one of three pricing models: Fixed Fee- Charge a flat amount per billing unit
- Example: $0.05 per 1,000 tokens
- Best for predictable pricing
- Add a percentage on top of provider costs
- Example: 20% markup
- Best for scaling fees with actual costs
- Combine both fee types
- Example: $0.10 base + 15% markup
- Best for covering overhead + cost scaling
Step 4: Select Billing Basis
Choose what metric drives pricing:| Billing Basis | Unit | Best For |
|---|---|---|
| input-output | Tokens | LLMs (charge for prompt + completion) |
| output-only | Tokens | LLMs (charge only for completion) |
| characters | Characters | Text-to-speech, text processing |
| duration | Seconds | Voice calls, real-time services |
| requests | API calls | Per-request pricing |
Step 5: Configure Cost Attribution
Base Costs (AI provider charges):- Wallet pays (default): User covers provider costs
- Merchant pays: You absorb provider costs (freemium model)
- Always paid by wallet (users can’t self-charge)
- Automatically follows merchant fees payer
Step 6: Set Overdraft Behavior
Block Requests (recommended):- Reject requests when balance insufficient
- Protects users from unexpected charges
- Process requests even with insufficient funds
- Create under-settled transfers
- Settle when user adds funds (oldest first)
Step 7: Save and Copy Product Secret
Click Create Product and copy the product secret. You’ll need this for:- Including in forward tokens to apply pricing
- Creating checkout sessions with specific pricing
- A/B testing different pricing models
API Product Creation
For programmatic product creation, use the Lava Node.js SDK:Basic Product Example
Product with Percentage Markup
Hybrid Fee Model
Tiered Pricing Setup
Tiered pricing lets you offer volume discounts as usage increases.Dashboard Configuration
- Enable Tiered Pricing toggle when creating product
- Define tiers with Up To thresholds and Fee amounts
- Last tier should have
nullfor unlimited
- Tier 1: Up to 1M units → $0.05 per unit
- Tier 2: Up to 10M units → $0.03 per unit
- Tier 3: Above 10M units → $0.01 per unit
API Configuration
- User consumes 5M tokens total
- First 1M tokens: 1,000,000 × 50.00
- Next 4M tokens: 4,000,000 × 120.00
- Total merchant fee: $170.00
Billing Basis Options
Input-Output Tokens (LLMs)
Charge for both prompt tokens (input) and completion tokens (output):- User sends 500 token prompt
- Receives 200 token completion
- Billing: (500 + 200) × 0.014
Output-Only Tokens (LLMs)
Charge only for completion tokens (free prompts):- User sends 500 token prompt (free)
- Receives 200 token completion
- Billing: 200 × 0.006
Characters (Text Processing)
Charge per character for text-to-speech or processing:Duration (Time-Based)
Charge per second or minute for real-time services:Requests (Per-Call)
Charge per API request regardless of usage:Cost Attribution Strategies
Configure who pays for different cost components:Pass-Through Model (Default)
User pays everything:Merchant Absorbs Base Costs
Merchant covers provider costs, user pays fees:- User pays: Merchant fees + service charge
- Merchant pays: Base provider costs
Freemium Model
Merchant covers all costs:- User pays: $0
- Merchant pays: Base costs + merchant fees + service charge
Testing Your Configuration
Always test pricing configuration before deploying to production.Step 1: Create Test Product
Step 2: Create Test Checkout Session
Step 3: Complete Checkout Flow
- Open checkout URL in browser
- Complete phone verification with test phone number
- Use Stripe test card:
4242 4242 4242 4242 - Confirm wallet created and balance shows $10.00
Step 4: Make Test Requests
Step 5: Verify Billing
Check the dashboard Usage page:- Request should show with correct fee ($0.01)
- Wallet balance should decrease appropriately
- Transfer should show base cost + merchant fee + service charge
Step 6: Delete Test Product
Use Stripe test mode during development. Test cards won’t process real payments. Switch to live mode only after thorough testing.
Troubleshooting
Product creation fails with validation error
Product creation fails with validation error
Common causes:
billingBasismust be one of:input-output,output-only,characters,duration,requestsfixedFeeandpercentageFeecannot both be 0costAttributionfields must be eitherwalletormerchant- Tiered pricing
upTovalues must be in ascending order
Pricing doesn't match expected calculations
Pricing doesn't match expected calculations
Possible reasons:
- Tiered pricing applies cumulatively (check total connection usage)
- Service charge (1.9%) added on top of merchant fees
- Base costs vary by AI provider (not fixed)
billingBasisset tooutput-onlyinstead ofinput-output
Users hitting insufficient funds errors
Users hitting insufficient funds errors
Reasons:
overdraftAllowed: falseblocks requests when balance low- Users underestimate token usage (prompts + completions)
- Base provider costs fluctuate (especially for premium models)
- Set
minimumBalancethreshold to warn users before blocking - Enable
overdraftAllowedfor critical services (with limits) - Display estimated costs before API calls
- Implement autopay for seamless top-ups
Product secret not applying correct pricing
Product secret not applying correct pricing
Check:
- Product secret correctly included in forward token (third component)
- Forward token format:
base64({secretKey}.{connectionSecret}.{productSecret}) - Product not deleted (check dashboard Products page)
- Product belongs to correct merchant account