Skip to content
FluxMeter
中文

Open-source LLM token metering · v4.8.5

Stop runaway AI spend

Open-source LLM token metering for customer-level usage. Sit the Gateway on the path, or wrap the SDK without a proxy. A prepaid budget can refuse the next call and cut a stream mid-flight. Measured locally — not a zero-overspend guarantee.

Discuss your usage reconciliation

Apache 2.0 · HTTP Custody · Python SDK · OpenAPI · Architecture

Your agent loop just tried to spend $24.42. FluxMeter stopped it at $0.27.

make demo-runaway · measured

make demo-runaway

Budget $0.30 · $0.03 per call · infinite loop · local mock

No provider key. [A] hits the mock directly. [B] goes through FluxMeter Gateway.

A no FluxMeter B FluxMeter Gateway
Calls admitted 814 9
Spend USD $24.42 $0.27
Time to stop 3.05s 0.15s
Outcome still burning (3.0s cap) 402 budget_exceeded · debt $0.00

Your agent loop just tried to spend $24.42. FluxMeter stopped it at $0.27.

Ledger customer=runaway-… events=9 cost_usd=0.27 debt_usd=0.0 held_usd=0.0 (settled)

Local measurement from fluxmeter PR #9 on a warm stack. Unguarded call count is machine-dependent (3.0s / 2,500-call cap). Gateway path — not the SDK wrap path. Does not guarantee zero overspend under cache fallbacks, streaming estimates, or concurrency. Source: fluxmeter PR #9 sample output (merged).

quick start

bash
git clone \
  https://github.com/10kshuaizhang/fluxmeter.git
cd fluxmeter
make demo
make demo-runaway

No provider key. After make demo, wait for /ready and poll for 1,600 tokens and $0.00042. On a warm stack, run make demo-runaway. Look for PASS. Does not guarantee zero overspend.

Full steps, prerequisites and troubleshooting →

Positioning

How this differs from LiteLLM budgets and OpenMeter entitlements

Pre-request budget checks are no longer unique. LiteLLM documents proxy-side customer budgets and budget reservation. OpenMeter documents metered entitlements (hasAccess / balance) for the application — or edge gating — to enforce. FluxMeter’s documented differences are narrower:

  1. 01

    No proxy required

    SDK wrap(OpenAI()) is an HTTP path: pre-call check and post-call track without putting a proxy in front of the model. Gateway is the other path — the measured runaway demo uses Gateway, not wrap.

  2. 02

    Cutoff mid-stream

    Documented: wrap() raises StreamKilledError mid-stream when estimated cost exceeds the reserve; Gateway orchestration is estimate → gate → reserve → upstream → Custody, and can return an OpenAI-compatible 402. The PR #9 demo stopped the next call with 402 after nine admits — it is not itself a mid-stream kill of one response.

  3. 03

    Exact ledger, including debt

    Usage lines expose event_count, cost_usd, and debt_usd. The PR #9 Gateway run settled 9 events, $0.27, debt $0.00. Metering makes overspend auditable; it does not promise it never happens.

  4. 04

    Export to an existing billing stack

    Stripe, Metronome, and Orb exporters are first-class in engine evidence. Lago is a documented example recipe. FluxMeter does not invoice, collect payment, or replace those systems.

When LiteLLM or OpenMeter may fit better

LiteLLM may fit when traffic already flows through its proxy and you want budgets on that path. OpenMeter may fit when you want metering coupled to entitlements, subscriptions, and invoices in one platform — as its public docs emphasize. FluxMeter sits beside those tools: token-native metering and hot-path control, then export. See the dated OpenMeter comparison; there is no LiteLLM compare page.

Public-docs reading, not a ranking. We do not claim LiteLLM or OpenMeter lack a given control. FluxMeter budget checks do not guarantee zero overspend.

Compare pages → FluxMeter and OpenMeter →

From model response to a cutoff you can audit.

Ingest, price, and attribute. Control sits on the path. Export to billing stays optional.

  1. 01 Ingest

    SDK or Gateway via HTTP Custody.

  2. 02 Price

    Model-specific input/output token rates.

  3. 03 Attribute

    By customer, period, model, or span.

  4. 04 Control

    Check, reserve, cut off.

  5. 05 Export (optional)

    Usage lines to billing or warehouse.

  6. record

    customer-level usage record

Primary 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

Illustrative use cases

One path: HTTP Custody.

SDK/Gateway → HTTP Custody → Kafka ACK + identity finalize → Flink usage aggregation → Redis query → Usage API.

Supported path

make demo starts the only supported full stack. ClickHouse is an audit cold store — not the metering source of truth.

  • make demo = supported stack
  • Gateway: estimate → gate → reserve → upstream → Custody
  • Intelligence stays heuristic / secondary

Engine 4.8.4. Python SDK 2.0.2 / JS SDK 2.0.0 are repository versions.

Run the cutoff locally.

make demo starts the stack and verifies one customer’s tokens and cost. On a warm stack, make demo-runaway is the Gateway A/B demo. No provider key. Not a zero-overspend guarantee.

Demo compose may leave authentication optional — enable API keys before any public or shared exposure.

Not a magnetic fluxmeter

FluxMeter is LLM token metering software for AI APIs — not a magnetic fluxmeter or physics instrument. The name is a brand, not a lab tool. FAQ

Going deeper? Intelligence · Landscape · Compare · FAQ