OpenMeter
Open-source metering and billing engine for AI, agentic, and DevTool monetization — ingest usage events in real time and turn them into accurate invoices automatically.
OpenMeter is a real-time metering and billing platform built for AI, API, and DevTool companies that need to monetize usage with precision and reliability. It ingests high-volume usage events via a simple CloudEvents API, aggregates them in real time using ClickHouse, and converts them into automated invoices with support for tiered, graduated, and flat-fee pricing models. Designed for developers and FinOps teams, it eliminates manual billing workflows and provides full visibility into customer usage as it happens.
The platform covers the full billing lifecycle: from event ingestion and meter definition through entitlement enforcement, subscription management, and customer-facing dashboards. It includes first-class support for LLM token cost tracking with model-specific pricing (including support for cache read, cache write, and reasoning tokens), making it particularly well-suited for AI infrastructure companies. Integration with Stripe handles payment processing, while webhook notifications alert teams to usage thresholds and billing events.
OpenMeter can be deployed self-hosted via Docker Compose for development or Kubernetes via an official Helm chart for production, or used as a managed cloud service hosted on Kong Cloud. SDKs are available for Go, Node.js, and Python, and the API is spec-first using TypeSpec generating fully typed OpenAPI definitions and client SDKs from a single source of truth.
What You Get
- Usage Metering - Ingest CloudEvents from any service and define meters with SUM, COUNT, AVG, MIN, and MAX aggregations to track API calls, LLM tokens, compute time, or any measurable event in real time.
- Usage-Based Billing - Generate invoices automatically from metered usage with support for tiered, graduated, and flat-fee pricing models, including prorating, mid-cycle plan changes, and a full invoice lifecycle management workflow.
- Usage Limits and Entitlements - Enforce real-time usage quotas per feature using boolean feature flags, metered balance tracking with grace periods, and static configuration — preventing overuse and enabling clear gating logic.
- Product Catalog - Define plans, add-ons, features, and rate cards with subscription management supporting mid-cycle changes, alignment, and prorating, all without requiring code changes for pricing updates.
- Prepaid Credits - Grant paid or promotional credit balances with priority-based burn-down and configurable expiration policies to support free trials, freemium tiers, and pre-purchased usage blocks.
- Customer Portal - Provide token-based self-service dashboards so customers can see their own real-time usage, consumption trends, balance, and billing history without needing access to your admin tooling.
- LLM Cost Tracking - Track AI model token usage with model-specific pricing for input, output, cache read, cache write, and reasoning tokens across providers like OpenAI, Anthropic, and others.
- Webhook Notifications - Configure alert rules for usage thresholds, billing events, and quota breaches with customizable delivery channels, including Slack and email via webhook integration.
Common Use Cases
- AI API monetization - An AI company building a model inference API uses OpenMeter to meter per-token usage per customer, enforce free-tier limits, and automatically generate Stripe invoices at the end of each billing cycle.
- Agentic AI platform billing - A platform running autonomous AI agents meters compute time and LLM calls per agent run, gives customers real-time visibility via the customer portal, and charges based on actual consumption.
- DevTool SaaS with usage caps - A developer tool like a CI/CD platform meters build minutes per team, enforces monthly usage quotas, and notifies admins when customers approach their plan limits via webhooks.
- Infrastructure cost attribution - A cloud platform meters Kubernetes pod usage events, attributes costs to internal teams or customers, and exports aggregated usage data to FinOps dashboards for spend optimization.
- Freemium-to-paid conversion - A SaaS product uses OpenMeter to grant free-tier credits, track consumption against them in real time, and automatically gate access or trigger upgrade flows when balances run out.
Under The Hood
Architecture OpenMeter follows a domain-driven, modular architecture where each business domain — billing, entitlements, product catalog, subscriptions, LLM costs, notifications — lives in its own well-bounded Go package with explicit service interfaces and adapter abstractions. The core is event-driven: Kafka decouples ingest workers from downstream billing, notification, and balance workers, enabling independent scaling of each processing layer. Dependency injection via Google Wire resolves service graphs at compile time, enforcing clear boundaries and eliminating implicit coupling. Infrastructure adapters are pluggable, allowing components like Redis, ClickHouse, and Postgres backends to be swapped or mocked independently, and a stateless, graceful-shutdown lifecycle across all workers ensures safe rolling deployments.
Tech Stack The backend is written in Go using the standard library’s HTTP server with go-chi for routing, structured logging via slog, and Cobra for CLI command organization. PostgreSQL accessed through the ent ORM and SQLC provides the transactional store for billing, subscriptions, and entitlements. ClickHouse handles high-throughput real-time usage aggregation with support for ClickHouse’s native precision using ch-go. Kafka powers the event ingestion pipeline with both IBM Sarama and confluent-kafka-go clients available. Redis handles deduplication and ephemeral state management. The API layer is spec-first: TypeSpec definitions generate OpenAPI specs, and oapi-codegen produces typed Go handlers and client SDKs for Go, Node.js, and Python. Deployment is Docker Compose for development and Helm on Kubernetes for production.
Code Quality OpenMeter has extensive test coverage across billing, entitlements, product catalog, and ingestion domains, with comprehensive behavioral test assertions for complex domain logic like invoice splitting, entitlement balance calculation, and subscription proration. Type safety is enforced throughout: custom domain types, disciplined pointer usage with the samber/lo library, and Decimal128 arithmetic via alpacadecimal for financial precision. Error handling is explicit — wrapped errors with contextual messages propagate cleanly through service and adapter layers. The codebase enforces consistent formatting via golangci-lint and automated CI pipelines run on every PR. TypeSpec-generated APIs guarantee the contract between server and clients is always in sync, preventing drift.
What Makes It Unique OpenMeter’s most distinctive technical capability is its treatment of billing providers as first-class, pluggable app types — Stripe, sandbox, and custom invoicing integrations all implement the same app interface, allowing namespace-level billing configuration without architectural changes. The LLM cost tracking module models per-provider, per-model pricing at the token dimension level (input, output, cache read, cache write, reasoning), with both system-synced global prices and per-namespace manual overrides, making it one of the few open-source platforms with native agentic AI billing semantics. The combination of Kafka topic auto-provisioning per namespace and ClickHouse-backed real-time aggregation creates a multi-tenant event pipeline that scales horizontally without operational coordination.
Self-Hosting
OpenMeter is licensed under Apache License 2.0, which is a permissive open-source license. You can use it commercially, modify it, distribute it, and incorporate it into proprietary products without any copyleft obligations — there is no requirement to open-source your own code when using OpenMeter. The Apache 2.0 license also includes an explicit patent grant, providing additional legal protection. The full source code is available on GitHub with no gated enterprise features or proprietary modules in the repository.
Running OpenMeter yourself requires managing a non-trivial infrastructure stack: PostgreSQL for transactional data, ClickHouse for real-time analytics, and Kafka for the event streaming pipeline are all required components in production. Redis is also needed for deduplication and ephemeral state. The quickstart Docker Compose setup handles this for local development, and an official Helm chart is provided for Kubernetes deployments. You are responsible for maintaining uptime, performing database migrations (including Postgres schema migrations and ClickHouse schema management), managing Kafka topic provisioning, and scaling each component independently as usage grows. The architecture is designed to scale horizontally, but realizing that requires operational expertise with each component.
The hosted cloud option is available through Kong Cloud (cloud.konghq.com), which provides managed infrastructure with no operational burden — you get a free tier to start and can scale without managing any of the underlying stack. The self-hosted path gives you full data control, avoids per-event pricing, and allows deeper customization of the billing logic, but you trade away managed upgrades, automatic scaling, and dedicated support. For teams with existing infrastructure expertise in Postgres, ClickHouse, and Kafka, self-hosting is a viable path; for smaller teams focused on product rather than infrastructure, the managed offering is likely a better fit until scale justifies the operational investment.
Related Apps
Ollama
AI Development · Developer Tools
Run Llama, Gemma, DeepSeek, and other open LLMs on your own machine with one command and an OpenAI-compatible API.
Ollama
MITDify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
Dify
OtherFirecrawl
AI Development · Developer Tools
Turn any website into clean, LLM-ready data with a single API call — no proxy headaches, no scraping complexity.