@ai-billing/openmeter / OpenMeterDestinationOptions
Interface: OpenMeterDestinationOptions<TTags>
Defined in: openmeter-destination.ts:24 Options for createOpenMeterDestination. OpenMeter ingests usage as CloudEvents where the eventtype identifies the meter and the subject
identifies the customer. This destination extracts identity from billing event tags, builds default
data 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: openmeter-destination.ts:28
OpenMeter API key.
apiUrl?
Defined in: openmeter-destination.ts:30 OpenMeter API base URL. Defaults to ‘https://eu.api.konghq.com’.optionalapiUrl?:string
eventType?
Defined in: openmeter-destination.ts:36 OpenMeter metering event type (CloudEventsoptionaleventType?:string
type).
Defaults to 'llm_usage'.
customerIdKey?
Defined in: openmeter-destination.ts:42 Tag key used to read the OpenMeter customer identifier (CloudEventsoptionalcustomerIdKey?: keyofTTags
subject). When omitted, common
tag keys are checked: openMeterCustomerId, userId.
mapMetadata?
Defined in: openmeter-destination.ts:54 Optional override for theoptionalmapMetadata?: (event) =>Record<string,string|number|boolean>
data payload sent to OpenMeter.
When omitted, metadata is built from buildMeterMetadata and includes:
- token/usage dimensions
tag_*values from event tags
cost_nanos and currency into data 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>