2026-07-05 · 5 min read
Customer billing queries without a data warehouse
If you resell LLM tokens or run an agent platform, customers eventually ask: "How much did I spend this month?" or "What did that agent run cost?"
The usual answer is to pipe events into a warehouse, build dashboards, and hope the numbers match your enforcement layer. FluxMeter v2.6.1+ adds a simpler path: query APIs backed by the same Redis rollups that power budget enforcement.
What shipped in v2.6.1–2.6.2
Four query patterns cover most customer-facing billing UI needs:
GET /usage/customer/{id}/period/{YYYY-MM} — monthly totals aligned to UTC calendar months. GET /usage/customer/{id}/day/{YYYY-MM-DD} — daily spend for "today's usage" widgets.
GET /usage/session/{id} — aggregate cost for a conversation or project when you set sessionId on lite ingest. GET /usage/span/{id} — total cost of one agent task when child LLM calls share a parentSpanId.
From v2.6.2, Lite /ingest increments span counters for parentSpanId — the same GET /usage/span/{id} works without Flink.
When to use each field
Monthly and daily queries need no extra ingest fields — rollup buckets accumulate from deploy forward in both Lite and Full modes.
Session queries work on lite ingest with sessionId (90-day TTL by default). For Kafka/Flink paths, use parentSpanId on every child call and query GET /usage/span/{id}.
Day and month buckets do not backfill history — plan a cutover date or accept that pre-deploy usage is unavailable via these endpoints.
How this fits your stack
FluxMeter remains the enforcement layer, not the invoice system. Use these APIs for customer dashboards, prepaid wallet UIs, and agent cost breakdowns.
Export to Stripe, Lago, or Orb for formal billing. The query APIs answer "what do we show the user right now?" without waiting for a nightly ETL job.
Try it locally
Run make demo, ingest a few events with sessionId or parentSpanId, then curl the period, day, session, or span endpoints. Full API reference is in the main repo docs.