POST /v1/requests instead of using the Gateway. However, Gateway is the recommended integration approach with more powerful enforcement capabilities.
| Gateway routing | Post-request reporting | |
|---|---|---|
| When Lava sees the request | Before, during, and after | After only |
| Usage tracking | Automatic (tokens, cost, model) | You extract and report it |
| Pre-request balance checks | Yes — block if insufficient credits | No — request already ran |
| Works with | Supported AI providers | Anything — AI, APIs, compute, storage |
| Endpoint | POST /v1/forward | POST /v1/requests |
What you get with gateway routing
Block requests when customers are out of credits
Gateway: Customer exhausted their plan and hit their card limit. They try to make a request. Lava rejects it before it reaches OpenAI, Claude, or Gemini. No wasted API call. Post-request: The request already ran. You’re out the provider cost for a customer who can’t pay.Know if a customer can afford an operation before running it
Gateway: Before an expensive agent loop, Lava checks if they have budget. If not, the request is rejected and you can show “please upgrade.” Post-request: You find out after you’ve already burned provider costs.One source of truth for usage
Gateway: The request that hit the provider is the same request that generated the billing record. Token counts, cost, and model are captured automatically. Nothing to reconcile. Post-request: You have provider logs and Lava records. You’re extracting usage data from each provider’s response format, normalizing it, and reporting it yourself. If the two don’t match, you’re debugging two systems.Works across all providers with one integration
Gateway: Same billing flow whether you’re calling OpenAI, Claude, Gemini, Mistral, or any of 30+ supported providers. One integration, all providers metered the same way. Post-request: Each provider returns usage differently. You normalize and report each one.When post-request reporting makes sense
Post-request reporting viaPOST /v1/requests is the right choice when:
- Non-AI usage — You’re billing for API calls, compute time, storage, or any operation that doesn’t go through an AI provider
- Your own API keys — You call AI providers directly with your own keys (BYOK) and want Lava to handle billing only
- Unsupported providers — You use a provider Lava doesn’t proxy yet
- Can’t change the request path — You’re deeply integrated with provider SDKs and can’t swap the base URL
How it works
After each billable operation, report it to Lava:| Fields | Use case |
|---|---|
input_tokens, output_tokens | LLM APIs (GPT-4, Claude, etc.) |
input_characters, output_seconds | Text-to-speech |
input_seconds, output_characters | Speech-to-text |
output_seconds | Video generation |
| (none) | Flat per-request pricing (meter handles it) |