How much code do I need to integrate Lava?
Minimal Integration, Maximum Value
One of the most common questions we hear from potential customers is: "What do we still have to build ourselves?" The short answer: very little.
What Lava Handles For You
- Usage metering — Every API call is tracked automatically through the gateway
- Credit management — Wallet balances, top-ups, and real-time balance checking
- Payment processing — Stripe integration, checkout flows, and payment collection
- Subscription management — Plans, tiers, upgrades, downgrades, and cycle management
- Overage handling — Automatic credit bundle prompts or auto top-up
- Payout calculation — Revenue tracking and merchant payouts via Stripe Connect
- Dashboard and analytics — Real-time usage, revenue, and customer data
What You Need to Do
Integration typically involves three steps:
- Route your AI calls through Lava — Change the base URL in your existing API calls to point to Lava's gateway. This is usually one line of code per call site.
- Add a forward token — Include a Lava authorization header that identifies the customer. This is constructed from your secret key, meter ID, and plan ID.
- Embed checkout — Add Lava's checkout element to your app so customers can fund their wallet. We provide React components and a hosted checkout page.
What About Business Logic?
Because Lava uses a wallet-based system, most of the complex billing logic is handled for you automatically:
- Balance checking — Lava checks wallet balance before every API call. If the customer is out of credits, the request is blocked automatically — you don't need to build this logic.
- Pricing changes — Change rates in the Lava dashboard and they apply immediately. No code changes needed.
- Tier entitlements — Query the Lava SDK to check what meters are in a customer's plan to determine feature access.
Time to Integrate
Most teams complete their initial integration in a few hours to a day. For comparison, building equivalent billing infrastructure from scratch typically takes 3+ months of engineering time, plus ongoing maintenance for edge cases like chargebacks, upgrades, downgrades, mid-cycle changes, and reconciliation.