Usage-based billing from LiteLLM with Lago or OpenMeter

LiteLLM can send cost and usage events for successful calls to Lago or OpenMeter, so you can bill customers or internal teams from one meter. This page covers how the callbacks work, what to charge by, and how to keep billing self-hosted.

On this page

How LiteLLM usage billing with Lago or OpenMeter works

If you need to bill customers or internal teams for LLM usage and want the metering kept in systems you control, LiteLLM's lago and openmeter callbacks send the cost and usage of successful calls to your billing or metering system. The callbacks are the method LiteLLM's docs describe for this purpose, and they run inside the proxy, so every gateway request that completes is a candidate event. The two tools do different jobs. Lago is billing infrastructure: it meters usage, applies pricing, produces invoices and hands the amount due to a payment processor. OpenMeter is a metering layer: it records and aggregates usage events so other systems can rate and bill them. Choose Lago when you need invoices and collections in the same product, and OpenMeter when your billing system already exists and only needs clean usage data.

Before you configure either callback, decide what you charge by. The LiteLLM Lago documentation describes charging by user, team or customer ID, so the identifier you map each virtual key or team to becomes the basis of every invoice line. Confirm with your team which identifiers exist in the gateway today, how keys map to customers or cost centers, and whether a request carrying no identifier will be billed to a default account or dropped. Also confirm that the callback reports cost in the currency and unit your pricing plan expects. These mappings are design work, and they are easier to fix before the first invoice than after events have been sent.

Plan the self-hosting boundary early. Lago's self-hosted Docker deployment runs its own API, workers, PostgreSQL, Redis and Gotenberg, and its FAQ states that a separate payment processor is still needed for collection. Lago's AGPLv3 license applies to the platform itself, so have your legal team review it before you modify the code. Your team will operate the Lago stack and keep its version pinned, following the self-hosted guidance to pin the last tagged release. The LiteLLM callback is only the sending side, so the receiving service, its retention and its access controls are your responsibility to define.

What you need before connecting LiteLLM to Lago or OpenMeter

Usage events only reach a billing system if the gateway, its database, the billing platform and the payment path are all ready before the callback is switched on. The cards below cover the gateway baseline, the self-hosted Lago stack, the payment processor, network access and the open items for OpenMeter.

LiteLLM version and production baseline

Start from a LiteLLM release on a supported minor line and confirm it runs with PostgreSQL as the database, because virtual keys and spend records depend on it. Once more than one proxy instance runs, Redis 7.0 or newer is required for shared state. Check the production guide before sizing, and confirm which release your callback configuration was written against.

Production guide

Self-hosted Lago stack

Lago needs its own deployment: a front end, an API, an API worker, a clock worker, PostgreSQL, Redis as the job queue and Gotenberg for PDF generation. Decide between Docker Compose for a single environment and Helm charts with dedicated workers for larger volumes. Pin the last tagged release rather than the latest image so billing behavior does not change between deploys.

Lago Docker guide

Separate payment processor

Lago calculates what to charge and when, but it does not collect money itself. If customers or internal invoices are paid through Lago, you need a payment gateway such as Stripe, Adyen or GoCardless, with its own account, credentials and webhook path. Internal chargeback that only moves cost between cost centers may not need one, so confirm the billing model before procuring.

Network paths and credentials

The LiteLLM proxy must reach the Lago API over a route your network policy allows, and the callback needs an API key stored in a secret manager, not in the config file. Confirm egress rules, TLS trust for any internal certificate authority, and which service account the gateway uses. Test the path from the gateway pod or host before enabling any callback.

Data flow to the billing system

Callbacks send cost and usage for successful calls, and the identifier you charge by (user, team or customer ID) must exist in the billing system before events arrive. Map those identifiers and decide what happens to events for unknown customers. Confirm which prompt or metadata fields leave the gateway with each event.

LiteLLM billing docs

OpenMeter requirements to confirm

The LiteLLM OpenMeter callback logs cost and usage of successful calls, but the OpenMeter deployment model, its hosting requirements and its database and streaming dependencies are not covered here. Check the OpenMeter documentation and your own environment for sizing, licensing and self-hosting support before committing to it. Treat it as an open item until those answers are in writing.

LiteLLM OpenMeter docs

Choosing whether to charge by user, team or customer ID

The first decision is who the invoice is addressed to. LiteLLM's Lago callback sends the cost and usage of successful calls to Lago and can charge by user, team or customer ID, so the identity you pick becomes the billing account. For internal chargeback, the billable party is usually a team or cost center, and the invoice is a transfer between budgets. For external customer invoices, the billable party is a paying customer, and each customer may contain several teams or users. Decide which of these you are building before you touch key design, because the same gateway can serve both, but a single identity field rarely fits both without distortion.

Next, map each identity to a billable customer in Lago. A user ID is the most granular option but breaks down when several people share one application key or when a customer buys seats in bulk. A team ID fits internal departments that already own keys and budgets. A customer ID fits external accounts, but only if every virtual key a customer uses is issued under that customer's identity. Keys shared across customers, or keys created without a customer link, produce usage that cannot be invoiced correctly. Write the mapping table before issuing keys, and test it with a sandbox customer and two keys.

This choice also sets how you use request tags and key ownership. If billing reads team or customer identity from the key, keys must be issued per billable unit, and tags should only carry finer detail such as project or feature for reporting. If you need a separate invoice line per feature, plan that with tags rather than with extra keys. Confirm the exact field names, how the callback reads each identity, and what happens to calls with no matching identity in the LiteLLM billing docs and the LiteLLM Lago docs before you commit to a design.

How to configure the LiteLLM callback step by step

This sequence takes you from a running billing system to a verified path where a LiteLLM call produces a matching usage event in Lago or OpenMeter. Each step closes with a check so you know the data is flowing before you rely on it for invoices or chargeback.

  1. Confirm the billing system is running

    Your platform team deploys Lago or OpenMeter in infrastructure you control, or confirms an existing instance is reachable from the LiteLLM proxy. For Lago, the self-hosted Docker Compose deployment runs a front end, an API, an API worker, a clock worker, PostgreSQL, Redis and Gotenberg, and the docs recommend pinning the last tagged version rather than the latest image tag. Done means you can log into the admin console, load the API health endpoint, and reach it from the network segment where the LiteLLM proxy runs.

  2. Create billing customers and plan identifiers

    Decide whether each billable unit is a user, a team or a customer ID, because the LiteLLM Lago callback can charge by any of these. Create matching customer or subject records in the billing system and write down the naming convention, such as team IDs that match your identity provider groups. Keep one identifier per unit so that spend and invoices can be traced back to the right owner. Done means every identifier you plan to send exists in the billing system and appears in a written mapping your finance team has reviewed.

  3. Create the metered features and pricing in the billing system

    In Lago or OpenMeter, define the billable metric that receives LiteLLM cost and usage, and attach it to the plan or price your organization uses. Confirm which fields the callback sends, such as cost and token counts, so the metric aggregates the value you intend to charge on. Test the metric on a dummy customer before you attach it to real records. Done means the metric exists, has a clear name, and a manual test event is accepted and aggregated for the test customer.

  4. Set the callback and credentials in LiteLLM configuration

    In the LiteLLM proxy configuration, add the lago or openmeter success callback as documented in the LiteLLM billing and observability pages, and supply the endpoint and API key for your billing system. Store the API key in your secret manager and inject it at runtime rather than writing it into the config file. Restart or reload the proxy using your normal change process. Done means the proxy starts cleanly with the callback enabled and its logs show no authentication or connection errors at startup.

  5. Create a virtual key for the test caller

    Create a virtual key scoped to one test team or customer in LiteLLM, restricted to a single inexpensive model and given a small budget so a test cannot create unexpected spend. Record which billing identifier the key maps to, because that mapping decides which customer receives the event. Done means the key exists, its model restriction and budget are visible in the admin UI, and the key is stored in your secret manager.

  6. Send a known test call through the virtual key

    Send one short, fixed prompt through the proxy using the virtual key, and note the time, model, prompt length and response. Record the cost LiteLLM reports for that call in its spend logs. Use a prompt you can repeat so you can compare results across runs. Done means the call returns a successful response and the spend log entry for that request exists with a cost value.

  7. Confirm the event arrives with the expected cost and usage

    Open the billing system and find the event for the test customer or team. Compare the event's cost, token counts, model and timestamp against the spend log entry from the test call. If the values match, run the same call a second time and confirm a second event appears, which shows the callback fires on every successful request. If the event is missing, check the proxy logs for the callback and the billing system's ingestion logs before changing any pricing. Done means one test call produces one matching event with the expected cost and usage.

Mapping LiteLLM identities and spend to billing objects

This table compares each LiteLLM identity and spend field with the Lago or OpenMeter object it usually becomes, and marks which mappings the docs confirm and which your team must define. Read it before the first event is sent, because the customer ID chosen here determines who gets billed. Mistakes at this step are hard to fix later, since historical events are tied to the identifiers they were sent with.

LiteLLM fieldLago objectOpenMeter object
Customer ID or end userCustomer (external ID you choose)Subject or customer key you define; confirm the mapping in the OpenMeter callback docs
TeamCustomer or billing entity for internal chargeback; defined by your teamSubject or customer for internal chargeback; defined by your team
Virtual keyNot a billing object; use only for attribution in metadata, if the callback passes itNot a billing object; confirm whether key fields reach event properties
Model nameBillable metric filter or charge property; confirm which field the callback sendsEvent property used by a meter filter; confirm the property name in the docs
Cost (USD)Metered value read by an aggregation on the billable metric; confirm which field carries costNumeric value read by a meter aggregation; confirm the field name
Input and output tokensEvent properties for token-based charges; confirm they are sent per callEvent properties for token-based meters; confirm they are sent per call
Subscription or planSubscription assigned to the customer in Lago; defined by your pricing modelNo direct equivalent; plan logic lives in your billing layer or entitlements
Event timestamp and IDTransaction ID and timestamp; confirm deduplication behavior for retriesEvent ID and time; confirm deduplication behavior for retries

How a successful LLM call becomes a billing event

The flow starts with a caller sending a request to the LiteLLM proxy, which forwards it to the model provider. Only successful calls trigger the callback, which sends cost and usage data to Lago or OpenMeter inside the self-hosted boundary. Lago then applies pricing and produces invoices, but it hands payment collection to an external payment processor. Check that the event carries the customer, team or user ID you plan to charge by, and that the provider's cost matches what LiteLLM logged.

Successful calls flow from the proxy through the callback into self-hosted billing, then to an external payment processor.

Securing the billing feed and keeping billing self-hosted

The billing feed carries customer and team identifiers and spend figures from the gateway to a billing system, so it needs the same care as the gateway itself. The cards below cover credentials, network paths, Lago version pinning, license obligations, payment processor separation and how failed calls are handled.

Keep master and billing credentials in a secret manager

The LiteLLM master key must start with sk- and should live in a secret manager, not in a config file or environment dump. Billing callbacks also need API credentials for Lago or OpenMeter, and those should be scoped to event ingestion only. Check who can read these secrets, how they rotate, and whether the gateway pod logs would ever print them.

LiteLLM production guide

Restrict network paths between gateway and billing

Only the LiteLLM proxy should be able to reach the billing system's event ingestion endpoint. Allow that single path in network policy or security groups and deny the rest, including from other application namespaces. Confirm that the billing API is not exposed on a public address, since a reachable ingestion endpoint lets anyone submit fake usage events.

Pin Lago to a tagged release

Lago's self-hosting guidance recommends pinning the last tagged version rather than the latest image tag, so upgrades happen on purpose and are tested against your callback. Record the version in your deployment manifest and review the release notes before each change. Confirm the release you pin against the Lago releases page at the time of deployment.

Lago Docker guide

Understand the AGPLv3 obligations

The Lago platform is licensed under AGPLv3, which applies to modified versions that users interact with over a network. Internal use with unmodified code carries different obligations than a changed build offered to customers. Have legal counsel confirm what your organization must publish if you patch Lago, and whether your use case needs an Enterprise plan for premium features.

Lago on GitHub

Keep payment processor credentials out of the core

Lago calculates what to charge and when, then hands payment to a separate gateway such as Stripe, Adyen or GoCardless. Keep those processor keys in their own integration configuration with its own access list, outside the billing core's database and the LiteLLM environment. Limit which staff can change payment settings, and verify that metering data never carries card or bank details.

Test failed-call handling

The Lago and OpenMeter callbacks send cost and usage only for successful calls, so requests that fail, time out or are retried may never reach billing. Test what happens when the billing system is down, and confirm whether your reconciliation process counts those gaps. Document the expected loss, alert on callback errors, and check the gateway logs against billed events for a sample period.

Why billing events go missing or show wrong amounts

This table lists the failures teams most often hit when LiteLLM cost events flow into Lago or OpenMeter, with the likely cause and the check or fix for each. Read it as a triage list: confirm the event path first, then the customer mapping, then pricing and the Lago worker. The main takeaway is that most wrong amounts trace to customer ID mapping or a pricing mismatch rather than the callback itself.

SymptomLikely causeCheck or fix
Events missing for successful callsThe callback is not enabled in the LiteLLM proxy config, or the billing system rejected the eventConfirm the lago or openmeter callback is set in the proxy config, then compare proxy logs with the billing system's event list for the same window
Events missing for failed or retried callsThe callbacks record only successful calls, so errors never reach the billing systemExpect this by design, and agree with finance that failed requests are not billable before reconciling counts
Duplicate charges for one customerThe same customer appears under two IDs, such as an email and an internal team keyStandardize the customer ID that LiteLLM sends for user, team or customer, and merge duplicate customers in Lago or OpenMeter
Usage recorded against no customerThe user, team or customer ID sent by LiteLLM does not match any customer or subscription in the billing systemCreate a mapping table from virtual key owner to billing customer, and alert on events with unmatched IDs
Totals differ from the provider invoiceTracked cost uses LiteLLM's model cost map, which may not match negotiated rates or cache token pricingCompare one stable time window token by token, then review pricing overrides before changing the billing meter
Charges do not match the meter definitionMeter aggregation, such as sum or count, or its property key does not match what LiteLLM sendsTest one known call end to end, and check that the meter's property names match the fields in the event payload
Lago invoices or events stallRedis, which acts as Lago's job queue, is unavailable, or the API worker or clock worker is not runningCheck Redis health and the worker containers first, and confirm queued jobs drain after restart
Lago events arrive lateBackground jobs are backed up or ClickHouse is not configured for high event volumeMonitor queue depth and worker logs, and confirm with the Lago docs whether your volume needs the optional external event store
Event schema changes after an upgradeLago or LiteLLM was upgraded without checking the callback payload and the billing version in usePin both versions, test the callback in staging, and review release notes before each upgrade

Testing the billing path before invoices go out

Test the billing path in stages before any customer or internal team receives an invoice. The first stage sends a known set of test calls through the LiteLLM proxy, each with a defined number of input and output tokens, so the expected cost of every call can be calculated by hand from the model price in use. Run these calls against a non-production virtual key tied to a test team or test customer ID, and confirm that the lago or openmeter callback records one event per successful call with the correct user, team or customer identifier. Failed or retried calls should not appear as billable events, so include a few deliberate failures to check that behavior.

The second stage compares the billing system's totals with LiteLLM spend logs for the same calls. In Lago, check that the metered quantity and the calculated charge match the expected figures for each test customer, using the pricing plan you intend to invoice under. In OpenMeter, check that the aggregated meter values match the events logged for the same window. Any mismatch should be traced before going further: confirm the callback is pointed at the right instance, the customer mapping is correct, and the price configuration in the billing system matches the figures you planned. Record each test run so a later change can be compared against a known baseline.

The third stage is a reconciliation window of at least one full billing period, run in parallel with real traffic and without invoices being sent. Compare billing system totals with LiteLLM spend logs each day, and then compare the LiteLLM totals with the provider invoices. Spend tracked in LiteLLM can differ from a provider bill because of time windows, cached token categories or pricing data, so do not treat a gap as a billing defect until it has been explained. The separate reconciliation topic covers how to work through those differences. Confirm the exact window and sign-off owners with finance before the first invoice run.

Questions buyers ask about LiteLLM billing with Lago or OpenMeter

Are the LiteLLM Lago and OpenMeter callbacks the supported way to send usage for billing?

Yes, LiteLLM ships a lago callback and an openmeter callback that send cost and usage data for successful calls to those systems. The Lago callback works with a self-hosted Lago and can attribute charges by user, team or customer ID. The OpenMeter callback logs cost and usage to OpenMeter. Both are documented by LiteLLM, but the callbacks only move events. Pricing rules, plan design, invoicing and payment collection still live in the billing system, so you must confirm that the event fields you need are present in your LiteLLM version before you commit to a design.

How much effort does a LiteLLM to Lago or OpenMeter integration take?

Effort depends less on the callback setting and more on the billing model you choose. The main drivers are how many customers or internal teams you bill, whether charges are per token, per request or per fixed plan, how you map LiteLLM keys and teams to billing customers, how you handle failed or retried events, and how you reconcile billed amounts with provider invoices. Each of these adds design, testing and operating work. A written scope should list the billing entities, the metrics, the reconciliation method and the environments covered. Ask any vendor or partner to show how each of those items is estimated and what is included in the quote.

What does our team need to provide for a usage billing project?

Plan to supply the people and facts that define how charges should work. Finance or product owners need to decide what to charge by, such as user, team, customer, model or tag, and which prices and discounts apply. Platform engineers need access to the LiteLLM proxy, its PostgreSQL database and the environment where Lago or OpenMeter will run. Security teams should review where usage events and customer identifiers are stored. Your team also needs a sample of provider invoices so spend in LiteLLM can be checked against what you pay. Ask for a list of these inputs in any written scope before work starts.

Is the free open-source edition of Lago enough for usage billing?

Lago describes a forever-free open-source edition with fundamental billing features, and Enterprise plans that add premium features. Whether that is enough depends on what you need: basic metering and pricing may fit, while advanced requirements such as specific invoicing rules, premium integrations or support terms may need a paid plan. Check the feature list against your billing rules before you choose an edition. Confirm with Lago which features each edition includes, since editions and feature sets can change between releases.

Do we need a payment processor if we use Lago?

Yes, if you collect payments from customers. Lago's FAQ says businesses using Lago need a separate payment processor: Lago calculates how much to charge and when, then sends that to a payment gateway. The README names Stripe, Adyen and GoCardless as supported providers. Internal chargeback is different, because you may only need invoices or cost allocation reports and no card or bank collection. Decide which case applies before you design the invoice flow, and confirm the payment provider's fees, contract terms and data handling with that provider.

How does the AGPLv3 license of Lago apply to our deployment?

The Lago platform is licensed under AGPLv3, while its agent SDKs and MCP server are MIT licensed in separate repositories. AGPLv3 has network-use terms that can apply when you modify the software and make it available to users over a network, so changes to Lago itself need legal review before you expose a modified version to customers. Running an unmodified copy for internal billing usually raises fewer questions. Your legal or licensing team should confirm how the terms apply to your use case, and it is a good idea to record which repositories and versions you deploy.

Can our own team build and run this integration without an outside partner?

Often yes, if you already run PostgreSQL, Redis and container platforms and have engineers who understand LiteLLM spend data and billing rules. Lago's self-hosted Docker Compose deployment includes a front end, an API, an API worker, a clock worker, PostgreSQL, Redis and Gotenberg, and larger deployments are pointed to Helm charts and dedicated workers. The harder parts are usually billing logic, reconciliation and upgrades. Lago's docs recommend pinning the last tagged version rather than the latest image tag. Compare your staff time against a fixed-scope quote, and ask any partner what they will hand over for your team to operate.

What operating tasks does a self-hosted Lago or OpenMeter setup add?

A self-hosted billing system adds recurring work beyond the initial build. Plan for version upgrades, which you should pin to tagged releases and test before rollout, backups of the billing database, monitoring of background workers and the event queue, and handling of event delivery failures. Lago has released new versions in quick succession recently, including v1.54.0 on October 6, 2026 and v1.55.0 on October 7, 2026, so an upgrade calendar matters. Confirm the expected upgrade cadence, support channels and on-call responsibilities before go-live.

How DeployOpen scopes and delivers this integration

DeployOpen plans, builds and documents the connection between a self-hosted LiteLLM gateway and either Lago or OpenMeter inside your own infrastructure. The work starts with agreeing in writing which usage events are billed, what they are charged by, and which billing system holds the records.

How we scope

  • Agree in writing which models, teams, keys or customer IDs become billable units and billing metrics.
  • Confirm whether Lago or OpenMeter fits your invoicing, payment and self-hosting requirements before build begins.
  • Define how LiteLLM cost values reconcile with provider invoices and which discounts or margins apply first.

How we build

  • Configure the LiteLLM callback for your chosen billing system and map each event field to its billing metric.
  • Deploy the billing system in your environment, pinned to a tagged release rather than the latest image.
  • Test successful and failed calls, duplicate handling and customer or team identifiers against a non-production gateway.

How we hand over

  • Deliver written documentation of event mapping, pricing dependencies, credentials handling and operating steps.
  • Walk your platform, finance and security teams through invoice runs, reconciliation checks and rollback steps.
  • Record the configuration as code so changes to callbacks or billing metrics can be reviewed and repeated.

How we support

  • Engagements are fixed-scope, and the scope, deliverables and timelines are agreed before work starts.
  • Ongoing support, upgrades and continuous testing are available as a retainer after handover.
  • Ask for a written quote tied to the agreed scope, and confirm which parts recur after go-live.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.