Architecture
Lava operates as a transparent proxy between your application and AI providers. It sits in the middle of API requests, adding usage tracking and cost logging without changing the developer experience.Lava adds less than 20ms of latency to your AI requests through edge computing and Redis caching.
What Happens on Every Request
- Authorize — Lava validates your secret key or forward token and checks account balance
- Route — Lava strips its own auth headers and forwards the request to the target provider
- Respond — The provider processes the request and returns a response. For streaming requests, Lava passes SSE events through in real time
- Log — After the response is returned, Lava asynchronously records token counts, costs, provider, model, and any custom metadata
- Bill — Lava deducts usage costs from your wallet balance
Why Use the Gateway
Fund your Lava account and start making requests to any supported provider — no need to sign up for OpenAI, Anthropic, Google, or any others:- Zero markup: you pay exactly what providers charge, at cost
- One integration: swap the provider URL to switch between 285+ providers without managing separate accounts or API keys
- Automatic tracking: every request is logged with token counts, costs, and model metadata
Track Your Own Usage
Pass your secret key directly in theAuthorization header to route requests through Lava. You get usage tracking, cost logging, and provider switching. Costs are charged to your Lava wallet, and no token generation is needed. To bring your own provider key, send a forward token instead, as described in Forward Proxy & Authentication.
To review what you sent, list your requests with the Requests API or lava.requests.list() in the Node.js SDK. Each request records its provider, model, token counts, and cost.
Next Steps
Quickstart: Track Usage
Route your first AI request through Lava in under 5 minutes
Forward Proxy Guide
Forward tokens, URL construction, error handling, and provider examples
Supported Providers
Full list of 285+ AI providers with base URLs and capabilities
Node.js SDK
Route requests, list your usage, and manage keys from Node.js