In this article, you will learn how to build a ‘pay-as-you-go’ billing system. This template is suitable for companies whose pricing fully depends on usage, such as cloud service providers and API companies, that only charge their customers for the resources they consume.Documentation Index
Fetch the complete documentation index at: https://getlago.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Pricing structure
For one of its products, Algolia Search, the platform offers its customers to subscribe for free and only pay based on usage.| Model | Search API |
|---|---|
| Monthly price | $1.50 / 1,000 requests |
| Free usage (each month) | 10,000 requests |
Get started
Create billable metrics
Create billable metrics to track request usage for Search and Recommend APIs.
- Set the
aggregation_typetosum_aggto sum all request volumes - Set the
field_nametosearch_requests_volumefor Search API tracking - Set the
recurringtofalsefor metered billing
Create a plan
Create a plan to price packages of requests used.Refer to the API reference and guide on package charges to learn more.
- Set the
amount_centsto0since there is no subscription fee - Set the
chargesto usepackagepricing model with Algolia’s rates - Configure
free_unitsof 10,000 requests per month included
Create a customer
Create a subscription
Create a subscription for the customer with the plan’s Refer to the API reference to create a subscription.
code.Ingest usage via events
Send usage events to Lago to track API requests.Refer to the API reference to create an event.
- Set the
codeto match your billable metric code - Include
search_requests_volumeproperty with the number of requests
Monitor current usage
Track real-time customer usage for the current billing period.Refer to the API reference to get the current usage.
Wrap-up
‘Pay-as-you-go’ pricing strategies are popular among API companies like Algolia. With Lago, you can adapt this template to your products and services, using some of our most popular features:- Plan models, with or without subscription;
- Billable metrics, including the ‘sum’ aggregation type; and
- Charges, including our package and graduated pricing models.