Skip to main content

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?

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).
Edge computing, Redis caching, and asynchronous processing keep latency under 20ms. Usage tracking happens after the response is sent.
Support for any REST API means Lava works with current and future AI providers without code changes.
Users see exactly what they’re paying for. Merchants see exactly what they’re earning. All usage is tracked and auditable.
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)
Total overhead: Typically under 20ms added to AI provider response time

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

  1. Sign up and connect your Stripe account
  2. Create a product with your pricing configuration
  3. Generate a secret key
  4. Embed the Lava checkout in your application
  5. When users complete checkout, receive a connection secret
  6. Combine your secret key + connection secret into a forward token
  7. Send API requests through Lava’s proxy endpoint

For End Users

  1. Click “Connect Wallet” in a merchant’s application
  2. Enter phone number for verification (SMS OTP)
  3. Create or connect existing Lava wallet
  4. Add payment method and initial funds via Stripe
  5. Use credits across all connected merchants
  6. View usage and manage wallet in Lava dashboard

Next Steps