Open-source AI usage metering · v4.4.1
Meter every token. Attribute every cost.
Open-source usage metering for AI gateways and multi-tenant products — customer-level tokens and cost, without a full billing suite.
Apache 2.0 · HTTP Custody · Python SDK · OpenAPI · Architecture
{
"customerId": "acme",
"modelId": "gpt-4o-mini",
"inputTokens": 1200,
"outputTokens": 400
} raw event
{
"customer_id": "acme",
"period": "2026-08",
"input_tokens": 1200,
"output_tokens": 400,
"tokens": 1600,
"cost_usd": "0.00042"
} customer ledger
Verified camelCase ingest and snake_case usage fields. Not a live backend. Example cost uses gpt-4o-mini catalog rates from engine config/pricing.json (input $0.15/MTok, output $0.60/MTok).
quick start
git clone \
https://github.com/10kshuaizhang/fluxmeter.git
cd fluxmeter
make demoPrimary wedge
Built for AI gateways and token resellers.
One upstream AI account often serves many downstream customers. Provider totals are not customer-level billable usage.
Upstream provider totals
provider invoice · one pool
Customer-level billable usage
acme · 1600 tok · $0.00042
From model response to usage line.
Core metering first. Control and export stay optional.
-
Ingest
SDK or Gateway via HTTP Custody.
-
Price
Model-specific input/output token rates.
-
Attribute
By customer, period, model, or span.
-
Control (optional)
Check, reserve, reconcile.
-
Export (optional)
Usage lines to billing or warehouse.
-
customer-level usage record
One path: HTTP Custody.
SDK/Gateway → HTTP Custody → Kafka ack → Flink billing/aggregation → Redis query → Usage API.
Supported path
make demo starts the only supported full stack. ClickHouse is an audit cold store — not billing truth.
- make demo = supported stack
- Gateway: estimate → gate → reserve → upstream → Custody
- Intelligence stays heuristic / secondary
Engine 4.4.1. Python/JS SDK 2.0.0 are repository versions — package-index publication not reverified.
Run customer-level usage locally.
Run make demo for the supported stack. Query usage from Redis via the Usage API.
Demo compose may leave authentication optional — enable API keys before any public or shared exposure.
Going deeper? Intelligence · Landscape · Compare · FAQ