Architecture Overview
Lava operates as a transparent proxy between your application and AI providers. It sits in the middle of API requests, adding usage tracking and billing without changing the developer experience.Lava adds less than 20ms of latency to your AI requests through edge computing and Redis caching.
Why This Architecture?
Developer Experience
Developer Experience
Merchants integrate with just a few lines of code - change the API endpoint URL and add an authorization header. No SDKs required (though we provide them).
Performance
Performance
Edge computing, Redis caching, and asynchronous processing keep latency under 20ms. Usage tracking happens after the response is sent.
Flexibility
Flexibility
Support for any REST API means Lava works with current and future AI providers without code changes.
Transparency
Transparency
Users see exactly what they’re paying for. Merchants see exactly what they’re earning. All usage is tracked and auditable.
Network Effects
Network Effects
Users who sign up through one merchant can use their wallet with any other merchant on Lava, driving adoption across the platform.
Performance Characteristics
Latency Profile
- Authentication: Less than 5ms (Redis cache lookup)
- Balance check: Less than 2ms (in-memory cache)
- Request forwarding: Direct passthrough (0ms overhead)
- Response streaming: Real-time (SSE support)
- Usage recording: Asynchronous (non-blocking)
Scalability
Lava’s architecture scales horizontally across multiple dimensions:- Edge deployment: Requests routed to nearest region
- Redis caching: Distributed cache for authentication and balance
- Asynchronous processing: Usage tracking doesn’t block responses
- Database sharding: Ready for multi-tenant scaling
Integration Patterns
For Merchants
- Sign up and connect your Stripe account
- Create a product with your pricing configuration
- Generate a secret key
- Embed the Lava checkout in your application
- When users complete checkout, receive a connection secret
- Combine your secret key + connection secret into a forward token
- Send API requests through Lava’s proxy endpoint
For End Users
- Click “Connect Wallet” in a merchant’s application
- Enter phone number for verification (SMS OTP)
- Create or connect existing Lava wallet
- Add payment method and initial funds via Stripe
- Use credits across all connected merchants
- View usage and manage wallet in Lava dashboard