Engine · Available

Billing

Usage meters and unit pricing for AI and OCR.

@keystone/engine-billing

Purpose

A dedicated meter for cost-associated platform ops so Document and AI do not invent their own ledgers. Peers call recordUsage through a duck-typed meter; rollups and pricing live here.

In a product

OCR a scanned PDF → Billing records ocr.textract pages → later summarizeUsage for the org’s invoice window.

How it works

  1. AI chat, embeddings, and steps call recordUsage with token quantities.
  2. Document OCR and text extract call recordUsage with pages or characters.
  3. Operators list usage, summarize by kind, and adjust unit prices.
  4. Each record can publish billing.usage.recorded for observability.

Capabilities

  • recordUsage / listUsage / summarizeUsage
  • getPricing / setPricing with sensible defaults
  • Publishes billing.usage.recorded
  • API under /v1/billing (usage, pricing)

Related

AI · Document · Event · Automation