Metering & Billing

Enterprise only

Meter AI input and output tokensv3.14+

This example enables AI token metering. For each AI Gateway request, the plugin emits two events: one for input (prompt) tokens and one for output (completion) tokens. This allows you to price input and output independently.

To aggregate usage and generate invoices, you need either Konnect Metering & Billing or a self-hosted OpenMeter instance.

Prerequisites

Environment variables

  • AUTH_TOKEN: A Konnect system account token (spat_) or OpenMeter API key.

Set up the plugin

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!