@ai-billing/lago / LagoDestinationOptions
Interface: LagoDestinationOptions<TTags>
Defined in: lago-destination.ts:24 Options for createLagoDestination. Lago ingests metered usage as events tied to anexternal_customer_id plus a code (billable metric
code). This destination extracts identity from billing event tags, builds default properties from the
event (usage + tags), and always sets cost_nanos and currency from BillingEvent.cost. Callers
must supply a defined cost on each event; the implementation asserts it is present and may throw at
runtime if it is omitted.
Type Parameters
TTags
TTags extends DefaultTags = DefaultTags
The shape of the tags object, extending DefaultTags.
Properties
apiKey
apiKey: string
Defined in: lago-destination.ts:28
Lago API key used for Authorization: Bearer ....
apiUrl?
Defined in: lago-destination.ts:30 Base URL for the Lago API. Defaults tooptionalapiUrl?:string
https://api.getlago.com.
meterCode?
Defined in: lago-destination.ts:36 Lago billable metric code (optionalmeterCode?:string| ((event) =>string)
event.code), or a function that derives the code from the billing event.
Defaults to 'llm_usage'.
externalCustomerIdKey?
Defined in: lago-destination.ts:42 Tag key used to read the LagooptionalexternalCustomerIdKey?: keyofTTags
external_customer_id. When omitted, common tag keys are checked:
userId, externalCustomerId.
mapMetadata?
Defined in: lago-destination.ts:54 Optional override for theoptionalmapMetadata?: (event) =>Record<string,string|number|boolean>
properties payload sent to Lago.
When omitted, metadata is built from buildMeterMetadata and includes:
- token/usage dimensions
tag_*values from event tags
cost_nanos and currency into properties from event.cost via
non-null assertion. Missing BillingEvent.cost is not supported and will throw when converting.
Parameters
event
BillingEvent<TTags>
Returns
Record<string, string | number | boolean>